Platform API · Product API · Campaigns
Message content
Write the copy a campaign draft carries: template variables and short links, the sender that speaks for it, SMS Unicode, the RCS message with its cards, carousels, media and buttons, the SMS fallback for contacts RCS cannot reach, and how to declare languages to translate later.
channel decides the shape of everything on this page. A campaign is sms or rcs, the choice is made at creation and cannot change afterwards, and each channel accepts fields the other ignores: allowUnicode is meaningless for RCS, suggestions and template are meaningless for SMS, and only a channel that cannot reach every contact takes a fallback.
What both share is the core: one block of copy, in one language, and a sender to speak for it.
One block of copy
{
"message": {
"text": "Your order is ready for pickup at our downtown store."
}
}message.text is required whenever you send a message at all — except on an RCS campaign that sends the RCS message object in message.template instead. You can also omit message entirely — the result is a valid draft with an audience, a sender and a date, and no copy, for someone to write in the dashboard. That is a legitimate way to use this endpoint: prepare the boring parts programmatically and leave the words to a human.
What this endpoint never does is invent copy. Nothing is generated, completed or translated on your behalf; a draft contains exactly the text you supplied.
Template variables
The text supports the same template variables as the rest of the platform. Two of them matter for almost every campaign:
| Variable | Effect |
|---|---|
{{short:https://example.com/page}} | Replaces the URL with a short link. |
{{unsubscribe}} | Inserts an unsubscribe link. |
A short link costs 10–15 characters instead of the full URL, and every tap on it is measurable in the campaign's reporting. In SMS, where length is billed, that is usually worth doing for every link you include.
{
"message": {
"text": "Summer sale starts today: 30% off everything.\nShop now: {{short:https://example.com/sale}}"
}
}Choosing a sender
sender is a top-level field, not part of message, and it takes the id of a sender that belongs to this project. An id from another project is refused with unknown-sender rather than silently ignored.
Omit it and the project's default sender for the channel applies. If the project has no default either, the draft is still created — with no sender, and a no-default-sender entry in metadata.warnings. The campaign cannot be sent until someone picks one, in the dashboard or with an edit, which is why that warning is worth surfacing in your own UI rather than dropping.
Whichever sender ends up on the campaign is also inherited by every language declared through translateTo that does not name its own.
SMS
An SMS body has no hard maximum in this API; length maps to cost instead.
allowUnicodebooleandefault: falseSMS only. Set it to true when the text may contain non-GSM-7 characters — accents, emoji, most non-Latin scripts. Ignored on RCS campaigns.
A GSM-7 part holds 160 characters; a Unicode part holds 70. Longer copy is split into several parts, and each part is billed as a message — so a 200-character GSM-7 message costs two, and the same text carrying one emoji costs three. That is simply the price of the copy you chose; a {{short:...}} link is the cheapest way to claw characters back.
{
"channel": "sms",
"title": "Flash sale for Spanish contacts",
"message": {
"text": "Solo hoy: 30% de descuento en toda la tienda.",
"allowUnicode": true
}
}RCS
An RCS message comes in one of two forms, and a request uses exactly one of them:
- Text and buttons:
message.text, a text bubble of up to 3072 characters, with up to 11urlordialerbuttons inmessage.suggestions. The quickest way to write a plain RCS message. - The RCS message object:
message.template, the full RCS message. It carries a text bubble, a single card, a carousel of cards or a media file, and buttons of every kind. It is the same object a flow's RCS send stores, validated by the same rules, so one shape serves both.
Sending message.template together with message.text or message.suggestions is refused with invalid-message (Pass either message.text with message.suggestions, or message.template, not both.), and so is message.template on an SMS campaign (message.template is only accepted on rcs campaigns.). With template, message.text is not required.
Unlike SMS, an RCS message is never split into parts: a text over 160 bytes (accented letters take 2 bytes, most emojis 4) is billed as one rich message instead of a text one. The full billing rules are in RCS: text and rich messages.
Text and buttons
suggestionsarrayRCS only. The buttons shown under the message, in order, up to 11.
typestringrequiredurl opens a link; dialer starts a phone call. The other kinds go in the RCS message object.
displayTextstringrequiredThe label the recipient sees, up to 25 characters.
urlstringRequired when type is url. A plain absolute http or https URL — not wrapped in a template variable. With urlVariable, it is the page the button opens for contacts without a link of their own, and its query parameters are added to each contact's link too, replacing any of the same name.
urlVariablestringOnly for type url. Makes the button open each contact's own link: the name of the contact attribute that holds it, without braces. Each contact's link is shortened and tracked, and a contact with no link (or a value that is not a URL) opens url instead, so the button is never missing. Campaigns have no trigger event, so only contact attributes resolve here.
interactionTokenstringOptional interaction tag, up to 32 characters of lowercase letters, numbers, - and _. It lands on the taps the button produces, so reports can tell which button was used. Never generated for you.
phoneNumberstringRequired when type is dialer. The number to call, in E.164 format.
{
"channel": "rcs",
"title": "Order pickup reminder",
"audience": {
"include": ["pending-pickups"]
},
"message": {
"text": "Your order is ready for pickup at our downtown store.",
"suggestions": [
{
"type": "url",
"displayText": "View order",
"url": "https://example.com/orders"
},
{
"type": "dialer",
"displayText": "Call the store",
"phoneNumber": "+34600000000"
}
]
}
}Three behaviours to know when you generate suggestions programmatically:
- Incomplete or unrecognised entries are dropped, not fatal. A button without
displayText, adialerwithoutphoneNumber, or a type this form does not take, is left out and the rest of the draft is created. Count the buttons on the response if your caller needs to know what survived. - A
urlbutton is never dropped. Without a validhttp(s)url, or with a malformedurlVariable, the request fails with a message on that field, so a link button cannot vanish silently. - More than 11 accepted buttons is an error (
invalid-message). The cap is a channel limit, not a preference, so it fails loudly rather than truncating your list at an arbitrary point.
The RCS message object
message.template holds exactly one body — text, richMessage or media — and, optionally, suggestions: the buttons under the message. A campaign that needs cards, a carousel, an image or a button other than url and dialer is written this way.
textobjectA text bubble: { "text": "..." }, up to 3072 characters. Never a bare string.
richMessageobjectA single card ("type": "card") or a carousel ("type": "cardCarousel") whose cards holds 2 to 10 cards.
typestringrequiredcard or cardCarousel.
titlestringA card's title, up to 200 characters.
descriptionstringA card's text, up to 2000 characters. Put links in a button, never here: a URL in a card's text cannot be tapped on most handsets.
mediaobjectA card's image or video, in the shape of media below.
suggestionsobjectA card's own buttons, up to 4, in the shape of suggestions below.
cardsobject[]cardCarousel only, required. 2 to 10 cards, each { "type": "card", ... } with the fields above. Every card's media uses the same mediaHeight.
mediaobjectA media file, as the message body or on a card. The file is referenced by a public URL, which the RCS provider downloads when it sends.
typestringrequiredimage, video, file or audio. On a card, image or video.
mediaUrlstringrequiredThe public URL of the file.
mediaContentTypestringrequiredThe file's MIME type, such as image/png or video/mp4.
mediaHeightstringdefault: automaticimage and video only. SHORT_HEIGHT, MEDIUM_HEIGHT or TALL_HEIGHT. Leave it out and the platform picks the height that crops the image least (a video by its thumbnail), as the dashboard's "Automatic" does, with one height for the whole carousel; MEDIUM_HEIGHT when the image cannot be read. A height you send is kept.
descriptionstringUp to 2000 characters.
suggestionsobjectThe buttons: { "suggestions": [ ... ] }, never a bare array. Up to 11 under the message, up to 4 on a card. Each button takes a type, a displayText of up to 25 characters, an optional interactionToken, and the fields its type asks for (next section).
A carousel of two cards with buttons, and an unsubscribe button under the message:
{
"channel": "rcs",
"title": "New running collection",
"message": {
"template": {
"richMessage": {
"type": "cardCarousel",
"cards": [
{
"type": "card",
"title": "Running shoes",
"description": "Light, for every day.",
"media": {
"type": "image",
"mediaUrl": "https://example.com/shoes.png",
"mediaContentType": "image/png"
},
"suggestions": {
"suggestions": [
{ "type": "reply", "displayText": "I want them", "interactionToken": "shoes-yes" },
{ "type": "url", "displayText": "See more", "url": "https://example.com/shoes", "interactionToken": "shoes-web" }
]
}
},
{
"type": "card",
"title": "Trail shoes",
"description": "Grip for the mountain.",
"media": {
"type": "image",
"mediaUrl": "https://example.com/trail.png",
"mediaContentType": "image/png"
}
}
]
},
"suggestions": {
"suggestions": [
{ "type": "unsubscribe", "displayText": "Unsubscribe" }
]
}
}
}
}A plain text bubble in this form is "template": { "text": { "text": "..." } }, and a single card is "richMessage": { "type": "card", ... }. Reading the campaign back, the stored message sits at channel.options[0].template of the campaign, in this same shape.
Button kinds
type | What the tap does | Fields it needs |
|---|---|---|
reply | Sends the label back as the contact's answer. | — |
url | Opens a link. | url, a plain absolute http(s) URL; optional urlVariable, as in text and buttons. |
dialer | Starts a phone call. | phoneNumber, in E.164. |
calendar | Adds an event to the contact's calendar. | startDate and endDate, with an offset and no fractional seconds (2026-12-01T10:00:00Z); title, up to 100 characters. |
viewLocation | Opens a map. | latitude and longitude, in decimal degrees (a number is accepted and comes back as a string); optional label. |
clipboard | Copies a text. | text, the text copied. |
unsubscribe | Opens the opt-out page. | None: it carries no url, because the platform fills the opt-out link when the message is prepared. |
interactionToken works as in the short form — lowercase letters, numbers, - and _, up to 32 — and is never set on unsubscribe. As with any button, a url is never wrapped in {{short:...}}.
Template limits
| Element | Limit |
|---|---|
| Text bubble | up to 3072 characters |
| Carousel | 2 to 10 cards, all with the same mediaHeight |
Card title | up to 200 characters |
Card description, media description | up to 2000 characters |
| Buttons under the message | up to 11 |
| Buttons on a card | up to 4 |
displayText | up to 25 characters |
interactionToken | a-z, 0-9, -, _, up to 32 characters |
What a template does not keep
Some keys of a template never reach the draft: a misspelt key, a field at the wrong level, or a field this API does not take. The draft is still created, and the response says what was left out instead of passing it off as a success. metadata.ignoredTemplateFields lists the path of each key, relative to template, and metadata.warnings carries template-fields-ignored:
{
"entity": { "...": "..." },
"metadata": {
"warnings": ["template-fields-ignored"],
"ignoredTemplateFields": ["richMessage.cards[0].buttons"]
}
}ignoredTemplateFields is present whenever the request carried message.template, and empty when everything was kept. The card width and the card and button layouts (cardWidth, and layout on a card or on its buttons) are set in the dashboard, not here: sent through this endpoint, they come back in the list. A read-only key sent back with the value a read already shows — a campaign's template re-posted as it was read — lost nothing, so it is not listed.
When a template is refused
What the dashboard or a flow would refuse is refused here too, and no draft is created. A refusal coded invalid-message carries its reason in errors.fields.errorMessage:
- A value with the wrong shape — a text bubble sent as a bare string, a
typethat does not exist (arichMessageof typecarouselinstead ofcardCarousel) — is aninvalid-message, with the message starting A value in message.template has the wrong shape: and naming the value, worded as for a flow draft. - A
templatethat is not a JSON object is aninvalid-message: message.template must be an object. - A value past a limit — a carousel with one card, a label over 25 characters, five buttons on a card, cards with different media heights — is a field-level
422naming the field, such ascardsordisplayText.
Falling back to SMS
RCS does not reach every contact: the handset and the network have to support it. A fallback covers the rest with an SMS, forming an rcs -> sms chain — the contacts RCS can reach get the rich message, everyone else gets the SMS.
fallbackobjectRCS only. Sending it on an SMS campaign is refused with fallback-not-supported: SMS already reaches everyone, so there is nothing to fall back to.
textstringrequiredThe SMS body. Required whenever fallback is present.
senderstringId of the SMS sender for this leg. Must belong to the project.
allowUnicodebooleanAllow non-GSM characters in the fallback SMS.
{
"channel": "rcs",
"title": "Order pickup reminder",
"audience": {
"include": ["pending-pickups"]
},
"message": {
"text": "Your order is ready for pickup at our downtown store.",
"suggestions": [
{
"type": "url",
"displayText": "View order",
"url": "https://example.com/orders"
}
]
},
"fallback": {
"text": "Your order is ready for pickup at our downtown store: {{short:https://example.com/orders}}"
}
}The fallback copy is required and is never derived from the RCS body. Beyond the standing rule that this endpoint writes no copy nobody supplied, there is a cost reason: an RCS body may run to 3072 characters, and pushing that into SMS would bill a long multi-part message nobody asked to send. Write the SMS version deliberately, short, with a short link.
Which sender the fallback uses
The SMS leg resolves its sender from the most specific answer available:
The explicit one
fallback.sender, when you send it.The one the RCS sender designates
The SMS sender configured on the RCS sender itself — whoever set up the RCS sender already chose which SMS speaks for it.
The project default
The project's default SMS sender.
If none of the three exists the draft is still created, with no-fallback-sender in metadata.warnings.
Declaring other languages
translateTo lists the other languages the campaign should eventually go out in, as two-letter lowercase codes:
{
"channel": "sms",
"title": "Product launch",
"audience": {
"include": ["newsletter-subscribers"]
},
"message": {
"language": "en",
"text": "Our new collection is live. Take a look: {{short:https://example.com/new}}"
},
"translateTo": ["fr", "de"]
}Each entry becomes a declared but empty language on the draft — a recorded intention to translate, not a translation. No copy is generated. Someone writes the French and the German in the dashboard, and until they do, the campaign cannot be estimated, quoted or prepared: an empty declared language is a deliberate gate, so a half-translated campaign can never be sent by accident.
message.language is the two-letter code of the copy you already wrote. Its only job is this de-duplication: without it, the language you supplied would be declared as one of the missing translations and the campaign would wait forever on a translation that already exists. That is why it is optional on its own and required whenever translateTo is used — and why it is not stored anywhere: it is a fact about your request, not about the campaign.
Errors
errorCode | Cause |
|---|---|
invalid-message | message was sent without text (or, on RCS, without template); a fallback was sent without text; more than 11 RCS buttons; template sent with text or suggestions, on an SMS campaign, not as an object, or with a value of the wrong shape; translateTo without message.language; an unknown compliance value. |
unknown-sender | The sender id does not exist or belongs to another project. |
fallback-not-supported | A fallback was sent on a channel that reaches every contact. |
unknown-channel | channel is missing, or names a channel this endpoint cannot draft. |
What's next
Last updated