Upsert a language's content
/v1/whatsapp/templates/{template_ref}/versions/{version_id}/languages/{language}const saved = await bird.whatsapp.templates.versions.languages.set(
"order_update",
"wav_01krdgeqcxet5s7t44vh8rt9mg",
"es",
{
components: [
{
type: "body",
text: "Tu pedido {{order_id}} ya fue enviado.",
example_parameters: [{ type: "text", name: "order_id", text: "A-4192" }],
},
],
},
);
console.log(saved.language, saved.revision);saved = client.whatsapp.templates.versions.languages.set(
"order_update",
"wav_01krdgeqcxet5s7t44vh8rt9mg",
"es",
components=[
{
"type": "body",
"text": "Tu pedido {{order_id}} ya fue enviado.",
"example_parameters": [{"type": "text", "name": "order_id", "text": "A-4192"}],
}
],
)
print(saved.language, saved.revision)saved, err := client.Whatsapp.Templates.Versions.Languages.Set(context.Background(), "order_update", "wav_01krdgeqcxet5s7t44vh8rt9mg", "es",
bird.WhatsappTemplatesVersionsLanguagesSetParams{
Components: []bird.WhatsAppTemplateComponentWrite{{
Type: "body",
Text: bird.String("Tu pedido {{order_id}} ya fue enviado."),
ExampleParameters: &[]bird.WhatsAppTemplateExampleParameterWrite{
{Type: "text", Name: bird.String("order_id"), Text: bird.String("A-4192")},
},
}},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(*saved.Language, *saved.Revision)$saved = $bird->whatsapp->templates->versions->languages->set(
'order_update',
'wav_01krdgeqcxet5s7t44vh8rt9mg',
'es',
(new WhatsAppTemplateLanguageUpsert())->setComponents([
(new WhatsAppTemplateComponentWrite())
->setType('body')
->setText('Tu pedido {{order_id}} ya fue enviado.')
->setExampleParameters([
(new WhatsAppTemplateExampleParameterWrite())->setType('text')->setName('order_id')->setText('A-4192'),
]),
]),
);
echo $saved->getLanguage(), ' ', $saved->getRevision(), "\n";bird whatsapp templates versions languages set <template-ref> <version-id> <language> --body-file - <<'JSON'
{
"components": [
{
"type": "body",
"text": "Your order {{order_id}} has shipped.",
"code_expiration_minutes": 60
}
],
"revision": 4
}
JSONcurl -X PUT "https://us1.platform.bird.com/v1/whatsapp/templates/{template_ref}/versions/{version_id}/languages/{language}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"components": [
{
"type": "body",
"text": "Your order {{order_id}} has shipped.",
"code_expiration_minutes": 60
}
],
"revision": 4
}'{
"language": "pt-BR",
"revision": 4,
"content_hash": "sha256:9f2c4e1a7b03d85fbc6e29d417a05e8c3b1d9f76a2e4c018d53b7f9a6c2e18d4"
}
Writes one language of the template's draft, creating it when absent (201) and replacing it when present (200). A full replacement, so send the language's complete content every time. Only the draft is writable: submitted versions are immutable, and a language under active review at Meta refuses the write until that review finishes. Pass revision to make the write a compare-and-set against the copy you read. Tags are canonicalised, and the response echoes the canonical form: use it in later calls for this language.
पैरामीटर
template_refstringTemplate ID (wat_ prefix) or slug. A value that parses as a valid ID resolves by ID; any other value resolves as a slug.
version_idstringID of the template version (wav_ prefix), as returned by the version list.
languagestringThe language, as a BCP-47 tag. Case and separator variance is accepted and normalised, and the canonical form is returned.
Request Payload
componentsThe template's content blocks for this language. Header, footer and buttons are optional. Every variable needs an example value, which is what Meta reviews against. May be omitted or empty on a draft; a body block is required before the language can be submitted.
चाइल्ड पैरामीटर दिखाएँ
components.typeA content block's type. A body block is required on every language; header, footer, buttons and carousel are optional and appear at most once each. A carousel holds the cards a marketing template scrolls through, and is the one block type that nests: its cards carry blocks of their own. Any other value is rejected.
Possible values: header, body, footer, buttons, carousel
components.formatThe header's kind. Required on a header block and refused on any other.
Possible values: text, image, video, gif, document, location
components.textThe block's text, with each variable written as a placeholder. Send it on a body, a footer, and a text header. Four blocks refuse it. A buttons block carries text on the buttons themselves. A media or location header shows a file or map and has nowhere to put copy. A carousel carries text on its cards. For an authentication template's body and footer, WhatsApp writes the copy from the two settings below. May be empty on a draft; required before submission.
components.add_security_recommendationEnds an authentication template's body with WhatsApp's own advice not to share the code. Send it only on an authentication template's body block, whose copy is otherwise WhatsApp's to write.
components.code_expiration_minutesHow long the passcode stays valid. Send it on an authentication template's footer block and WhatsApp writes the footer stating it; omit the footer block entirely to leave it off. WhatsApp enforces the range it accepts and refuses the submission otherwise.
components.example_parametersAn example value per {{n}} in text, in placeholder order. Meta reviews the filled message rather than the template, so a block with variables and no examples is refused. A media header also carries its file here as one entry. Its type matches the header's format, and its url addresses the file. A media header has no placeholder, so this entry is the header's own sample rather than a value that fills one.
components.buttonsThe buttons this block carries. Send it only on a buttons block. Ten in total, of which at most two open a link and at most one dials a number. Quick replies must sit together rather than being interleaved with the other types, so Quick reply, Quick reply, Link is accepted where Quick reply, Link, Quick reply is refused. A template with four or more buttons, or one that mixes a quick reply with another type, cannot be opened on WhatsApp's desktop clients, and the recipient is asked to switch to their phone. May be omitted or empty on a draft; at least one button is required before submission.
components.cardsThe cards a carousel block scrolls through. Send it only on a carousel block, and only on a marketing template. Every card must carry the same blocks in the same order, and a card's header shows an image or a video. A document header works at the top of a template but not on a card. The number of cards is fixed once the language is approved. A template approved with three cards always sends three. Changing the count requires a new template rather than a new version of this one. May be omitted or hold fewer than two on a draft; at least two are required before submission.
revisionThe revision you last read for this language, making the write a compare-and-set: a mismatch is refused with a conflict, leaving an edit you have not seen in place. Omit it for last-write-wins, which is what a single writer wants. Supplying it for a language that does not exist is also refused with a conflict rather than recreating the language. Inside a template's initial languages seed on create, a value here is refused, since no prior revision exists yet to compare against.
Response Payload
languageThe canonical form of the tag you addressed. Use it in later calls for this language.
revisionThe language's new revision, to pass back on your next write.
content_hashA hash over the content as saved, so you can tell whether your next write would change anything without diffing the document.
updated_atWhen this language was last written.
संबंधित संसाधन
इस विषय के लिए दस्तावेज़, गाइड और उदाहरणों के साथ आगे बढ़ें।