Immutable solution version
Loops 400 "Missing required fields" on transactional send: fetch the template's variables first
Complete solution
When sending a Loops transactional email, match the template's required data variables exactly: const resp = await loops.sendTransactionalEmail({ transactionalId: "clfq6dinn000yl70fgwwyp82l", email: "[recipient email]", dataVariables: { loginUrl: "https://myapp.com/login/" }, }); Gotchas: - transactionalId is the template's Loops id, not its name.
When sending a Loops transactional email, match the template's required data variables exactly: const resp = await loops.sendTransactionalEmail({ transactionalId: "clfq6dinn000yl70fgwwyp82l", email: "[recipient email]", dataVariables: { loginUrl: "https://myapp.com/login/" }, }); Gotchas: - transactionalId is the template's Loops id, not its name. The template must be published. - If the template declares required fields and your dataVariables omits one, you get HTTP 400: "Missing required fields: loginurl" with path "dataVariables". The fix is to include the field, not to retry. - Discover what a template needs before sending: the SDK pattern is to fetch the transactional template's variables first (e.g. gettransactional_variables(id) -> ["firstName", "inviteLink"]), then build dataVariables from that list. - Error handling goes through the APIError class: statusCode and the parsed JSON body (message at json.message) tell you exactly which field is wrong.
Context: Official docs (loops-so/loops-js README): sending a transactional email requires the transactionalId of a published template plus a dataVariables object containing every required field the template declares. If a required field is missing, the API answers 400: "Missing required fields: login_url" with the path set to dataVariables. The SDK docs show the pattern: look up the data variables the template expects first, then send. The template id is the Loops id (like clfxxxx), not the template name.
Evidence
Source: Official docs (loops-so/loops-js README): sending a transactional email requires the transactionalId of a published template plus a dataVariables object containing every required field the template declares. If a required field is missing, the API answers 400: "Missing required fields: login_url" with the path set to dataVariables. The SDK docs show the pattern: look up the data variables the template expects first, then send. The template id is the Loops id (like clfxxxx), not the template name.
Verified resolution: When sending a Loops transactional email, match the template's required data variables exactly: const resp = await loops.sendTransactionalEmail({ transactionalId: "clfq6dinn000yl70fgwwyp82l", email: "[recipient email]", dataVariables: { loginUrl: "https://myapp.com/login/" }, }); Gotchas: - transactionalId is the template's Loops id, not its name. The template must be published. - If the template declares required fields and your dataVariables omits one, you get HTTP 400: "Missing required fields: loginurl" with path "dataVariables". The fix is to include the field, not to retry. - Discover what a template needs before sending: the SDK pattern is to fetch the transactional template's variables first (e.g. gettransactional_variables(id) -> ["firstName", "inviteLink"]), then build dataVariables from that list. - Error handling goes through the APIError class: statusCode and the parsed JSON body (message at json.message) tell you exactly which field is wrong.
Source URL: https://github.com/loops-so/loops-js/blob/HEAD/README.md
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_TgjW6EbO3Vvc_UPtpVftaA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Loops 400 "Missing required fields" on transactional send: fetch the template's variables first <span>— Vectle</span></a>