API Send Template Carousel
此页面暂无中文版本。显示默认语言(English)。
API Send Template Carousel
POST {BASE_URL}/templates/send
Send an approved WhatsApp carousel template to one contact. A carousel is a message body followed by 2 to 10 swipeable cards, and each card has its own media, body text, and Visit Website URL. This is the same endpoint used to send any other template, with one added parameter, carousel_cards, that carries the content of each card. The contact and conversation are created if they do not exist yet, the same as for any other template send. A successful request returns success: true, and the carousel is delivered to the recipient with the message body followed by every card, in template order.
Send Template Carousel Method
| HTTP Method | Endpoint | Description |
|---|---|---|
| POST | {BASE_URL}/templates/send |
Send a carousel template to one contact |
Send Template Carousel Request
Request Headers
Content-Type: application/json
authorization: api_key {{YOUR_API_KEY}}
Sample Request
This example uses a carousel template with 2 cards. The second card has no file_url, so it is sent with the media approved on the template.
{
"wa_template_id": "1002478156150000",
"inbox_id": "a1b2c3d4-0000-1111-2222-333344445555",
"phone_number": "6285604068646",
"phone_name": "Rafi",
"template_body_variables": ["Rafi"],
"carousel_cards": [
{
"file_url": "https://files.cekat.ai/promo-sepatu.jpg",
"body_variables": ["Sepatu Lari", "299.000"],
"url_button_tails": ["sepatu-lari"]
},
{
"body_variables": ["Tas Ransel", "199.000"],
"url_button_tails": ["tas-ransel"]
}
]
}
| JSON Attribute | Description | Type | Required |
|---|---|---|---|
wa_template_id |
ID of the approved carousel template to send. It can be found on the template detail page. The template must have the APPROVED status. | String | Required |
inbox_id |
ID of the WhatsApp inbox used to send the message. Use GET /api/inboxes to retrieve valid IDs. |
String | Required |
phone_number |
Destination phone number in international format, for example 6285604068646. |
String | Required |
phone_name |
Name associated with the phone number. | String | Optional |
template_body_variables |
Ordered array of values for the variables in the message body of the template ({{1}}, {{2}}, …). Required only if the message body has variables. |
Array of String | Conditional |
carousel_cards |
Ordered array with one entry per card of the template. See Resolving carousel_cards in the Notes section below below. Required only if at least one card has values to fill. |
Array of Object | Conditional |
assign_agent_id |
ID of the agent the conversation is assigned to once the message is sent. | String | Optional |
Resolving carousel_cards
Each entry fills one card of the approved template. Entries map to cards by position: entry 0 is the first card of the template, entry 1 is the second, and so on. The array length must equal the card count of the template.
| Field | Description | Type | Required |
|---|---|---|---|
file_url |
URL of the media for this card, as served by Cekat after the file is uploaded. Replaces the media approved on the template for this card only. The media must match the template header format, image or video. | String | Optional |
body_variables |
Ordered array of values for the placeholders in the body of this card. Values are used as-is. | Array of String | Conditional |
url_button_tails |
Ordered array of values appended to the base URL of this card’s Visit Website buttons, in the template button order. A card with two Visit Website buttons takes two values. | Array of String | Conditional |
No field inside a card is required by the schema. Each one is required only where the approved template has something for it to fill, and is rejected where it does not.
| Field | Required when | Omit when |
|---|---|---|
body_variables |
The body of that card contains placeholders. | The body of that card contains none. |
url_button_tails |
That card has a Visit Website button whose base URL ends with a variable. | That card has no Visit Website button, or its URL is fixed. |
file_url |
Never. | The card is sent with the media approved on the template. |
carousel_cards itself is required only when at least one card needs body_variables or url_button_tails. A carousel template with no card variables and no URL variables can be sent without carousel_cards, and every card is delivered exactly as approved. Because entries map to cards by position, a card that needs nothing is sent as an empty object {} whenever a later card needs values.
What the template locks and what the request can supply
| Fixed on the template | Can be supplied per card |
|---|---|
| Card count and card order | body_variables, where the card body has placeholders |
| Header format, image or video | url_button_tails, where the URL ends with a variable |
| Button label, type, count, and order | file_url, which replaces the approved media of that card |
| Quick Reply label and payload | |
| Call Phone Number | |
| Base URL of Visit Website buttons | |
Card media, when file_url is omitted |
Media requirements
| Media | Requirements |
|---|---|
| Image | JPEG or PNG, 8-bit RGB or RGBA, up to 5 MB. |
| Video | MP4 or 3GPP, up to 16 MB, H.264 video and AAC audio, with a single audio stream or none. |
Text limits
| Field | Limit |
|---|---|
| Card body, after variables are replaced | 160 characters |
| Message body, after variables are replaced | 1,024 characters |
| Resolved URL of a Visit Website button | 2,000 characters |
cURL Example
curl --location '{BASE_URL}/templates/send' \
--header 'Content-Type: application/json' \
--header 'authorization: api_key {{YOUR_API_KEY}}' \
--data '{
"wa_template_id": "1002478156150000",
"inbox_id": "a1b2c3d4-0000-1111-2222-333344445555",
"phone_number": "6285604068646",
"phone_name": "Rafi",
"template_body_variables": ["Rafi"],
"carousel_cards": [
{
"file_url": "https://files.cekat.ai/promo-sepatu.jpg",
"body_variables": ["Sepatu Lari", "299.000"],
"url_button_tails": ["sepatu-lari"]
},
{
"body_variables": ["Tas Ransel", "199.000"],
"url_button_tails": ["tas-ransel"]
}
]
}'
Send Template Carousel Response
Success Response (200)
The fields below are the ones that matter for a carousel send.
{
"success": true,
"data": {
"is_template": true,
"template_id": "1002478156150000"
}
}
| JSON Attribute | Description | Type |
|---|---|---|
success |
true when the message was sent. |
Boolean |
data.is_template |
true for a template send. |
Boolean |
data.template_id |
The wa_template_id that was sent. |
String |
Failed Send (200)
If Meta rejects the send, or a card media file cannot be downloaded or uploaded, the endpoint still returns HTTP 200 with success: false. The reason is in data.error, and no partial message is delivered.
{
"success": false,
"data": {
"error": "<reason from Meta or the media upload>"
}
}
Error Responses
| Status Code | When it happens |
|---|---|
| 400 | carousel_cards fails validation (see below) |
| 401 | Missing or invalid API key |
Carousel validation errors (400)
Validation runs before anything is sent to Meta. If any check fails, nothing is uploaded to Meta and no message is delivered.
| When it happens | Message |
|---|---|
The length of carousel_cards differs from the card count of the template |
Carousel card count does not match. Template has 5 cards, received 3. |
The template has card values to fill and carousel_cards is omitted |
carousel_cards is required because this template has card values to fill. |
carousel_cards is sent for a template that is not a carousel |
carousel_cards is only valid for carousel templates. |
A card has body placeholders and body_variables is omitted |
Names the position of the card. |
A card has no body placeholders and body_variables is sent |
Card has no body variables, so body_variables must be omitted, with the position of the card. |
The number of body_variables differs from the number of placeholders in that card |
Names the position of the card and both counts. |
A card has a Visit Website button ending in a variable and url_button_tails is omitted |
Card requires url_button_tails for its URL button, with the position of the card. |
A card has no URL variable and url_button_tails is sent |
Names the position of the card. |
file_url is a video on an image template, or an image on a video template |
Card media must be image, matching the template header format. or the video equivalent. |
| A card body exceeds 160 characters, the message body exceeds 1,024 characters, or a resolved URL exceeds 2,000 characters | Names the field that overflowed. |
Sample 400: card count mismatch
{
"success": false,
"message": "Carousel card count does not match. Template has 5 cards, received 3."
}
Notes
- Card order is fixed when the template is created and cannot be changed in the request. Entries in
carousel_cardsmap to cards by position, so entry 0 is always the first card of the template. Rearranging the array does not reorder the cards, it only puts each set of values on the wrong card. - Button order within a card is fixed in the same way.
url_button_tailsmaps to the Visit Website buttons of the card in the template button order. - Quick Reply and Call Phone Number buttons accept no values. Their label, payload, and phone number are fixed on the template.
- Card media is uploaded to Meta right before the message is sent. A file used on several cards in the same request is uploaded once and reused.
- All card values are used as-is. There is no lookup against a recipient list in this endpoint.
file_urlandotp_codeat the top level of the request are used by media header and authentication templates. They are not used by a carousel template, which takes its media per card incarousel_cards.- This is an optional addition to the existing endpoint. Every existing request stays valid and behaves as before, so there is no new API version.
- Not supported: creating or editing a carousel template through the API, quick reply values at send time, per-card button labels, base URLs, or phone numbers, changing the number or order of cards, and attributing a quick reply tap back to a specific card.
{BASE_URL}is a placeholder. Confirm the production host with engineering before use.