Use this API to send messages with Template ID.
Note:
- In case of Carousel template, the postback texts are added to the Cards of the Carousel template.
- If the template has a quick reply button, then the postback texts can be added to the Callback URL.
Parameters
Key | Description | Required/Optional | Type | Value |
---|---|---|---|---|
Authorization |
Access Token for the application |
Required |
String |
{{PARTNER_APP_TOKEN}} |
appId |
Unique Identifier for Gupshup App |
Required |
String |
{{APP_ID}} |
source |
Phone number to send a message from. Required phone Number With Country Code |
Required |
Integer |
91891056XXXX |
src.name |
App name |
Required |
String |
Appname1 |
sandbox |
Should be a boolean value |
Optional |
Boolean |
false |
destination |
Phone number of the customer to send the message to. Required phone Number With Country Code. |
Required |
Integer |
918286836XXX |
template |
MPM Template Catalog Template LTO Template |
Optional |
String |
{"id": "007b7c0e-fc8d-4698-a9a8-3938151dd5da","params": ["monday","2020-12-20","apps"]} |
src.name |
App name, whose appId used while creating template |
Required |
String |
GupshupDevAssistant01 |
message |
For the carousel, message JSON along with the media id/link will also contain the postbackTexts here index is the button index (starts from 0) and text is the postback text for that button. |
Optional |
String |
|
postbackTexts |
Add Postback Text for quick reply button |
Optional |
String |
|
channel |
Messaging channel to send message on. |
Optional |
String |
|
Token |
Your app token, please refer Get access token api to get the token from partner documentation. |
Required |
String |
sk_61b3021c97xxx4370b341f8baaae0xxxx |
Sample Request
curl --location '{{partner_base_url}}/partner/app/{{APP_ID}}/template/msg' \
--header 'Connection: keep-alive' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'channel=whatsapp' \
--data-urlencode 'source={{SOURCE_NUMBER}}' \
--data-urlencode 'sandbox=false' \
--data-urlencode 'destination={{DESTINATION_NUMBER}}' \
--data-urlencode 'template={"id": "{{TEMPLATE_ID}}","params":[]' \
--data-urlencode 'src.name={{APP_NAME}}' \
--data-urlencode 'message={{MESSAGE}}' \
--data-urlencode 'postbackTexts=[{"index":4,"text":"Hello"}]'
Sample Response
{
"status": "submitted",
"messageId": "b****acb-3***-4***-98**-64*****ea9**"
}
Expected Response on Callback
{
"app": "{{app_name}}",
"timestamp": 1716900845926,
"version": 2,
"type": "message",
"payload": {
"id": "wamid.HBgMOTE4ODg4OTk4NTQ1FQIAEhgUM0EzODA1NkE2OENBNEFGQjFFQjkA",
"source": "{{phone_number}}",
"type": "quick_reply",
"payload": {
"text": "Yes",
"type": "button",
"postbackText": "hello"
},
"sender": {
"phone": "{{phone_number}}",
"name": "{{name}}",
"country_code": "91",
"dial_code": "{{phone_number}}"
},
"context": {
"id": "3847e304-2b9f-4cef-a72d-29aca93f95ce",
"gsId": "3d749fe7-36fb-44b6-8209-f79efed697f9",
"forwarded": false,
"frequently_forwarded": false
}
}
}
Status Codes
Status Code | Response | Comment |
---|---|---|
Success | ||
200 | { "status": "submitted", "messageId": <messageId> } | |
Error | ||
400 | { "message": "Invalid Destination", "status": "error" } | If the destination is missing. |
400 | { "message": "Invalid App Details", "status": "error" } | If the source is missing or app details are not found"If the source is unavailable or the application details cannot be found. |
500 | { "status": "error", "message": "Internal server error. Please try again later and If Issue still persist than contact Gupshup Dev Support" } | For any Internal Error |