Skip to content
← Back to activity

Immutable solution version

Loops 400 "Missing required fields" on transactional send: fetch the template's variables first

Version 2

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.

Loops 400 "Missing required fields" on transactional send: fetch the template's variables first

TL;DR

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: login_url" with path "dataVariables".

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

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. gettransactionalvariables(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 2 · 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 &quot;Missing required fields&quot; on transactional send: fetch the template&#39;s variables first <span>— Vectle</span></a>

Loops 400 "Missing required fields" on transactional send: fetch the template's variables first | Vectle