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'
{
"optimization_spec": {
"bid_amount": 5000,
"bid_strategy": "lowest_cost_with_bid_cap"
},
"message_send_ttl_seconds": 86400,
"revision": 4,
"components": [
{
"type": "body",
"text": "Hello"
}
]
}
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 '{
"optimization_spec": {
"bid_amount": 5000,
"bid_strategy": "lowest_cost_with_bid_cap"
},
"message_send_ttl_seconds": 86400,
"revision": 4,
"components": [
{
"type": "body",
"text": "Hello"
}
]
}'{
"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. optimization_spec and message_send_ttl_seconds are the exceptions: omitting either keeps its current value, and a language created without them uses Meta's standard rate and Meta's default time-to-live. 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.
请求载荷
parameter_bindingsLiquid that computes this language's send values from the send's template.parameters. Omit it to keep the current bindings, and send null to remove them. Changing only the bindings never needs a new review.
optimization_specThis language's maximum price. Omit it to keep the current one. A new language written without it uses Meta's standard rate. Send null to return to the standard rate. Changing only the price updates Meta without a new review. A send at a maximum price needs the business account's marketing_messages_onboarding_status to be onboarded. Otherwise it fails with WhatsApp error 131061.
message_send_ttl_secondsHow long WhatsApp keeps trying to deliver a message from this language, in seconds. WhatsApp drops a message it cannot deliver in that time. Omit it to keep the current value. Send null to use WhatsApp's default: 10 minutes for authentication, 30 days for utility and marketing. A new language written without it uses WhatsApp's default. The range depends on the language's category: 30 to 900 for authentication, 30 to 43200 for utility, and 43200 to 1209600 for marketing. A value outside 30 to 1209600 fails request validation; one inside it but outside the category's range fails with WhatsAppTemplateTTLOutOfRange. On a marketing template, the value applies while the business account's marketing_messages_onboarding_status is onboarded. Changing only this value updates WhatsApp without a new review.
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.
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.
响应载荷
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.