post
https://api.gupshup.io/wa/api/v1/template/msg
cURL
curl --location '{{api_front_base_url}}/wa/api/v1/template/msg' \
--header 'apikey: {{apiKey}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'channel=whatsapp' \
--data-urlencode 'source={{source phone number}}' \
--data-urlencode 'destination={{destination phone number}}' \
--data-urlencode 'src.name={{app_name}}' \
--data-urlencode 'template={"id":"{{template_id}}","params":{{template_params_list}},"expiration":{{expiration_time_in_UNIX_timestamp_in_milliseconds}} }' \
--data-urlencode 'message={{message}}' \
--data-urlencode 'postbackTexts=[{"index":"<qr_btn_index>","text":"<postback_text>"}]'
- Expiration must be provided for LTO templates created where
has_expirationis true- Include the message object in the curl above only if the template has media. Refer image, video and document template docs to get the corresponding message payloads.
- Omit the
postbackTextsparameter in the curl above if the template doesn’t have quick reply buttons, or if it has but there’s no need for postback text support.
Request Parameters
| Name | In | Description | Required | Type | Example |
|---|---|---|---|---|---|
| apikey | header | Your account API key | true | string | 2xxc4x4xx2c94xxxc2f9xx9d43xxxx8a |
Form Parameters
| Name | Type | Description | Required | Example |
|---|---|---|---|---|
| source | string | Sender Whatsapp Number | true | 919163xxxxx3 |
| src.name | string | App name that the source number belongs to | true | DemoApp |
| destination | string | Receiver Whatsapp Number | true | 917839xxxxx3 |
| template | object | Contains template id, list of template parameters, and expiration for LTO template | true | |
| message | object | Optional; required for media LTO templates | false |
Object Structures
Template Object
| Name | Type | Description | Required | Example |
|---|---|---|---|---|
| id | string | Template ID | true | "template_id" |
| params | array | List of template parameters in LTO template | true | ["param1", "param2"] |
| expiration | integer | Expiration time in UNIX timestamp in milliseconds | true | 1644912000000 |
Message Object
Image Header
| Name | Type | Description | Example |
|---|---|---|---|
| type | string | Type of message (must be "image") | image |
| image | object | Image object containing id / link | |
| link | string | Media URL of the image | <image_media_url> |
| id | string | Media ID of the image | <image_media_id> |
Video Header
| Name | Type | Description | Example |
|---|---|---|---|
| type | string | Type of message (must be "video") | video |
| video | object | Video object containing id / link | |
| link | string | Media URL of the video | <video_media_url> |
| id | string | Media ID of the video | <video_media_id> |
Postback Texts
| Name | Type | Description | Example |
|---|---|---|---|
| index | integer | Button index (0-based) | 0 |
| text | string | Postback text for the button | hello |
Channel
| Name | Type | Description | Example |
|---|---|---|---|
| channel | string | Messaging Platform Name |
Status Codes
| Status Code | Description | Response Schema |
|---|---|---|
| 202 | Success response | { "status": "success", "messageId": "message id" } |
| 400 | Error response; in case of bad request | { "status": "error", "message": "Invalid Destination" } |
| 401 | Error response; in case of authentication failure | { "status": "error", "message": "Authentication Failed" } |
