When to use
Use this to build channel-portable message templates once and reuse them everywhere: a
single Content resource (ContentSid) renders as SMS text, an MMS media message, a WhatsApp
interactive template, or an RCS card/carousel depending on the destination channel. Use it
whenever you need approved WhatsApp templates, variable substitution ({{1}}, {{2}}), or
rich interactive content (quick replies, call-to-action buttons, list pickers, cards,
carousels, catalogs) that the send-time APIs reference by SID.
Not for: the act of delivering messages (see twilio-rcs-messaging for RCS/SMS sends and
twilio-whatsapp-messaging for WhatsApp sends); free-form one-off messages that never repeat
(just pass Body); voice prompts (see twilio-voice-twiml).
Method
- Choose a content type for the primary variant. Add channel-specific variants in the same
Content resource so one SID serves multiple channels.
- Author variables as
{{1}}, {{2}}, ... (or named). Provide sample values in variables
so approval reviewers and previews render correctly.
- Create the template: POST to the Content API. Capture the returned
sid (starts HX).
- Decision point: does the destination channel require approval? WhatsApp templates must be
approved by Meta before use; SMS and RCS do not require Content-level approval (RCS still
needs a verified RBM agent — see twilio-rcs-messaging).
- For WhatsApp, submit an ApprovalRequest with category (utility/marketing/authentication)
and name; poll approval status until
approved or rejected.
- Send by SID: pass
ContentSid plus ContentVariables (JSON map of index→value) to the
Messages API. Twilio substitutes variables and picks the right channel variant for the
destination.
- Decision point: variable count mismatch? Every
{{n}} in the body must have a key in
ContentVariables or the send errors; unused keys are ignored.
Example
# Create a quick-reply template with one variable.
curl -X POST https://content.twilio.com/v1/Content \
-u "$ACCOUNT_SID:$AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"friendly_name": "order_status_qr",
"language": "en",
"variables": {"1": "Ada"},
"types": {
"twilio/quick-reply": {
"body": "Hi {{1}}, your order shipped. Track it?",
"actions": [
{"id": "track", "title": "Track order"},
{"id": "help", "title": "Talk to support"}
]
},
"twilio/text": {"body": "Hi {{1}}, your order shipped."}
}
}'
# Send it later by SID with runtime variables.
client.messages.create(
messaging_service_sid="MGxxxx",
to="+15551234567",
content_sid="HXxxxx",
content_variables='{"1": "Ada"}',
)
Pitfalls
- WhatsApp approval is Meta-side and can be rejected for policy/formatting; marketing
templates face stricter review than utility. Fix and resubmit under a new ApprovalRequest.
ContentVariables must be a JSON string, not a nested object, when sent as form params.
- Variable indices are 1-based and must be contiguous as authored; a body with
{{2}} but no
{{1}} confuses substitution.
- A channel that lacks a matching variant falls back to
twilio/text if present; without a
text variant, sends to that channel fail. Always include a text variant for SMS reach.
- Editing an approved WhatsApp template can invalidate approval; create a new template for
substantive changes.
- Catalog/authentication types have channel-specific required fields; validate against the
content-type schema before POST.
Output format
A Content resource with sid (HX...), types map, and variables. WhatsApp
ApprovalRequests return a status: received/pending → approved or rejected with a
rejection reason. At send time the ContentSid + ContentVariables produce a rendered Message.
Reference
- Create:
POST https://content.twilio.com/v1/Content; list GET /v1/Content; fetch
GET /v1/Content/{Sid}; delete DELETE /v1/Content/{Sid}.
- WhatsApp approval:
POST https://content.twilio.com/v1/Content/{Sid}/ApprovalRequests/whatsapp;
fetch status GET /v1/Content/{Sid}/ApprovalRequests.
- Content types:
twilio/text, twilio/media, twilio/quick-reply,
twilio/call-to-action, twilio/list-picker, twilio/card, twilio/carousel,
twilio/catalog, whatsapp/card, whatsapp/authentication.
- Variables:
{{1}}-style placeholders substituted at send via ContentVariables (JSON).
- WhatsApp limits: quick-reply up to 3 buttons; call-to-action up to 2 buttons (1 URL +
1 phone); list-picker up to 10 items; body text limits per WhatsApp template policy.
- Content template creation/storage has no per-template fee; delivery bills at the
destination channel's message rate (WhatsApp conversation pricing, SMS segment, RCS RBM).
1---2name: twilio-content-template-builder3version: 1.0.04description: Author reusable Twilio Content API templates with typed content, variable placeholders, and channel approval, then send them by ContentSid across SMS, WhatsApp, and RCS.5author: matrixx00706tags: [twilio, content-api, templates, whatsapp, variables]7capabilities: []8metadata:9 source: https://skillmd.com/skills/matrixx0070/twilio-content-template-builder10---1112## When to use1314Use this to build channel-portable message templates once and reuse them everywhere: a15single Content resource (ContentSid) renders as SMS text, an MMS media message, a WhatsApp16interactive template, or an RCS card/carousel depending on the destination channel. Use it17whenever you need approved WhatsApp templates, variable substitution ({{1}}, {{2}}), or18rich interactive content (quick replies, call-to-action buttons, list pickers, cards,19carousels, catalogs) that the send-time APIs reference by SID.2021**Not for:** the act of delivering messages (see twilio-rcs-messaging for RCS/SMS sends and22twilio-whatsapp-messaging for WhatsApp sends); free-form one-off messages that never repeat23(just pass `Body`); voice prompts (see twilio-voice-twiml).2425## Method26271. Choose a content type for the primary variant. Add channel-specific variants in the same28 Content resource so one SID serves multiple channels.292. Author variables as `{{1}}`, `{{2}}`, ... (or named). Provide sample values in `variables`30 so approval reviewers and previews render correctly.313. Create the template: POST to the Content API. Capture the returned `sid` (starts `HX`).324. Decision point: does the destination channel require approval? WhatsApp templates must be33 approved by Meta before use; SMS and RCS do not require Content-level approval (RCS still34 needs a verified RBM agent — see twilio-rcs-messaging).355. For WhatsApp, submit an ApprovalRequest with category (utility/marketing/authentication)36 and name; poll approval status until `approved` or `rejected`.376. Send by SID: pass `ContentSid` plus `ContentVariables` (JSON map of index→value) to the38 Messages API. Twilio substitutes variables and picks the right channel variant for the39 destination.407. Decision point: variable count mismatch? Every `{{n}}` in the body must have a key in41 ContentVariables or the send errors; unused keys are ignored.4243## Example4445```bash46# Create a quick-reply template with one variable.47curl -X POST https://content.twilio.com/v1/Content \48 -u "$ACCOUNT_SID:$AUTH_TOKEN" \49 -H "Content-Type: application/json" \50 -d '{51 "friendly_name": "order_status_qr",52 "language": "en",53 "variables": {"1": "Ada"},54 "types": {55 "twilio/quick-reply": {56 "body": "Hi {{1}}, your order shipped. Track it?",57 "actions": [58 {"id": "track", "title": "Track order"},59 {"id": "help", "title": "Talk to support"}60 ]61 },62 "twilio/text": {"body": "Hi {{1}}, your order shipped."}63 }64 }'65```6667```python68# Send it later by SID with runtime variables.69client.messages.create(70 messaging_service_sid="MGxxxx",71 to="+15551234567",72 content_sid="HXxxxx",73 content_variables='{"1": "Ada"}',74)75```7677## Pitfalls7879- WhatsApp approval is Meta-side and can be rejected for policy/formatting; marketing80 templates face stricter review than utility. Fix and resubmit under a new ApprovalRequest.81- `ContentVariables` must be a JSON string, not a nested object, when sent as form params.82- Variable indices are 1-based and must be contiguous as authored; a body with `{{2}}` but no83 `{{1}}` confuses substitution.84- A channel that lacks a matching variant falls back to `twilio/text` if present; without a85 text variant, sends to that channel fail. Always include a text variant for SMS reach.86- Editing an approved WhatsApp template can invalidate approval; create a new template for87 substantive changes.88- Catalog/authentication types have channel-specific required fields; validate against the89 content-type schema before POST.9091## Output format9293A Content resource with `sid` (`HX...`), `types` map, and `variables`. WhatsApp94ApprovalRequests return a status: `received`/`pending` → `approved` or `rejected` with a95rejection reason. At send time the ContentSid + ContentVariables produce a rendered Message.9697## Reference9899- Create: `POST https://content.twilio.com/v1/Content`; list `GET /v1/Content`; fetch100 `GET /v1/Content/{Sid}`; delete `DELETE /v1/Content/{Sid}`.101- WhatsApp approval: `POST https://content.twilio.com/v1/Content/{Sid}/ApprovalRequests/whatsapp`;102 fetch status `GET /v1/Content/{Sid}/ApprovalRequests`.103- Content types: `twilio/text`, `twilio/media`, `twilio/quick-reply`,104 `twilio/call-to-action`, `twilio/list-picker`, `twilio/card`, `twilio/carousel`,105 `twilio/catalog`, `whatsapp/card`, `whatsapp/authentication`.106- Variables: `{{1}}`-style placeholders substituted at send via `ContentVariables` (JSON).107- WhatsApp limits: quick-reply up to 3 buttons; call-to-action up to 2 buttons (1 URL +108 1 phone); list-picker up to 10 items; body text limits per WhatsApp template policy.109- Content template creation/storage has no per-template fee; delivery bills at the110 destination channel's message rate (WhatsApp conversation pricing, SMS segment, RCS RBM).