post https://partner.gupshup.io/partner/app//templates
Request Parameters
Key | Description | Value | Data Type | Required/Optional | Constraints |
---|---|---|---|---|---|
Authorization | Access Token for the application | {{PARTNER_APP_TOKEN}} | String | Required | Should be a valid Partner App Access Token |
elementName | The name of a template. The element name is unique for a WABAs namespace. | {{ELEMENT_NAME}} | String | Required | elementName (not more than 180 char.) Mandatory fields |
languageCode | Language code for the template. Refer to all the language codes here. | {{LANGUAGE_CODE}} | String | Optional | languageCode default value : en_US |
content | The body of the template. | {{CONTENT}} | String | Required | content (not more than 1024 char.) |
category | The category of your template. | {{CATEGORY}} | String | Required | Category Type: MARKETING UTILITY |
vertical | TEXT | {{VERTICAL}} | String | Required | vertical (not more than 180 char.) |
templateType | CAROUSEL | {{TEMPLATE_TYPE}} | String | Required | The type of template: CAROUSEL Cards only to be passed if template type is CAROUSEL |
example | Template Example | {{EXAMPLE}} | String | Required | |
enableSample | Required for creating all types of templates | {{ENABLE_SAMPLE}} | true/false | Optional | if enableSample is true then exampleMedia |
cards | Card list | [{"headerType":"VIDEO","mediaUrl":null,"mediaId":"6462811350485912","exampleMedia":null,"body":"Time for shopping yay {{1}} 😀","sampleText":"Time for shopping yay user 😀","buttons":[{"type":"URL","text":"Buy now","url":"https://www.luckyshrub.com/shop?promo={{1}}","buttonValue":"https://www.luckyshrub.com/shop?promo=","suffix":"exotic_produce_2023","example":["https://www.luckyshrub.com/shop?promo=exotic_produce_2023"]},{"type":"QUICK_REPLY","text":"Send more like this"}]}] | String | Required | Either of mediaUrl, mediaId or exampleMedia is required. If exampleMedia is not provided, the handleId / exampleMedia will be generated in the backend using the mediaUrl / mediaId.[ { "headerType": "<VIDEO>", "mediaUrl": "<video url>", "mediaId": "<video id>", "exampleMedia": "<video handle id>", "body": "<card 1 body>", "sampleText": "<card 1 example>", "buttons": <button_list> } ] |
allowTemplateCategoryChange | Boolean value. If True, Meta will automatically update the template category as per the template content. The default value is False. | {{ALLOW_TEMPLATE_CATEGORY_CHANGE}} | true/false | Optional | |
appId | App ID to fetch the access token | {{APP_ID}} | String | Required | The Id should be a valid app Id of Gupshup The App must be associated with the account that owns the PARTNER_APP_TOKEN being used |
curl --location --request POST 'https://partner.gupshup.io/partner/partner/app/{{APP_ID}}/templates' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'elementName={{ELEMENT_NAME}}' \
--data-urlencode 'languageCode={{LANGUAGE_CODE}}' \
--data-urlencode 'content={{CONTENT}}' \
--data-urlencode 'category={{CATEGORY}}' \
--data-urlencode 'vertical={{VERTICAL}}' \
--data-urlencode 'templateType={{TEMPLATE_TYPE}}' \
--data-urlencode 'example={{EXAMPLE}}' \
--data-urlencode 'allowTemplateCategoryChange={{ALLOW_TEMPLATE_CATEGORY_CHANGE}}' \
--data-urlencode 'enableSample={{ENABLE_SAMPLE}}' \
--data-urlencode 'cards=[{"headerType":"VIDEO","mediaUrl":null,"mediaId":"6462811350485912","exampleMedia":null,"body":"Time for shopping yay {{1}} 😀","sampleText":"Time for shopping yay user 😀","buttons":[{"type":"URL","text":"Buy now","url":"https://www.luckyshrub.com/shop?promo={{1}}","buttonValue":"https://www.luckyshrub.com/shop?promo=","suffix":"exotic_produce_2023","example":["https://www.luckyshrub.com/shop?promo=exotic_produce_2023"]},{"type":"QUICK_REPLY","text":"Send more like this"}]}]'
Sample Response
{
"status": "success",
"template": {
"appId": "a41b30f4-d202-4fdb-911e-3a8fbfbfb797",
"category": "MARKETING",
"containerMeta": "{\"appId\":\"a41b30f4-d202-4fdb-911e-3a8fbfbfb797\",\"data\":\"Hey there new products are here\",\"cards\":[{\"headerType\":\"VIDEO\",\"mediaId\":\"6462811350485912\",\"body\":\"Time for shopping yay {{1}} 😀\",\"sampleText\":\"Time for shopping yay user 😀\",\"buttons\":[{\"type\":\"URL\",\"text\":\"Buy now\",\"url\":\"https://www.luckyshrub.com/shop?promo={{1}}\",\"example\":[\"https://www.luckyshrub.com/shop?promo=exotic_produce_2023\"]},{\"type\":\"QUICK_REPLY\",\"text\":\"Send more like this\"}]}],\"sampleText\":\"Hey there new products are here\",\"enableSample\":true,\"editTemplate\":false,\"allowTemplateCategoryChange\":false,\"addSecurityRecommendation\":false}",
"createdOn": 1715666311400,
"data": "Hey there new products are here",
"elementName": "mediaidvideotemplate",
"id": "485d9a3d-851c-4bb1-b9ac-be9713aa347c",
"languageCode": "en",
"languagePolicy": "deterministic",
"meta": "{\"example\":\"Hey there new products are here\"}",
"modifiedOn": 1715666311400,
"namespace": "9c7fe92f_2a48_40ec_83d0_69c62a772433",
"priority": 1,
"quality": "UNKNOWN",
"retry": 0,
"stage": "NONE",
"status": "PENDING",
"templateType": "CAROUSEL",
"vertical": "internal_vertical",
"wabaId": "104505526065633"
}
}
Status Codes
Status Code | Response | Comment |
---|---|---|
Success | ||
200 | { "status": "success", "template": { "appId": "a41b30f4-d202-4fdb-911e-3a8fbfbfb797", "category": "MARKETING", "containerMeta": "{"appId":"a41b30f4-d202-4fdb-911e-3a8fbfbfb797","data":"Hey there new products are here","cards":[{"headerType":"VIDEO","mediaId":"6462811350485912","body":"Time for shopping yay {{1}} 😀","sampleText":"Time for shopping yay user 😀","buttons":[{"type":"URL","text":"Buy now","url":"https://www.luckyshrub.com/shop?promo={{1}}\",\"example\":[\"https://www.luckyshrub.com/shop?promo=exotic_produce_2023\"]},{\"type\":\"QUICK_REPLY\",\"text\":\"Send more like this"}]}],"sampleText":"Hey there new products are here","enableSample":true,"editTemplate":false,"allowTemplateCategoryChange":false,"addSecurityRecommendation":false}", "createdOn": 1715666311400, "data": "Hey there new products are here", "elementName": "mediaidvideotemplate", "id": "485d9a3d-851c-4bb1-b9ac-be9713aa347c", "languageCode": "en", "languagePolicy": "deterministic", "meta": "{"example":"Hey there new products are here"}", "modifiedOn": 1715666311400, "namespace": "9c7fe92f_2a48_40ec_83d0_69c62a772433", "priority": 1, "quality": "UNKNOWN", "retry": 0, "stage": "NONE", "status": "PENDING", "templateType": "CAROUSEL", "vertical": "internal_vertical", "wabaId": "104505526065633" } } | |
Error | ||
429 | { "status": "error", "message": "Too Many Requests" } | 10 Requests per Minute |
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 |