Apply For Templates

Using this API, you can Create a template for a particular app

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

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

elementName

The name of a template. 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. Character limit: 1028. For "Authentication" category the first line should be - {{1}} is your verification code.

String

NA

• content (not more than 1024 char.)

category

The category of your template. Possible Values: AUTHENTICATION, MARKETING and UTILITY. If you submit the templates with the any other categories, you will receive an error Invalid category provided, kindly use category from these option AUTHENTICATION, MARKETING, UTILITY.

String

NA

• category (not more than 180 char.)

vertical

TEXT

String

NA

vertical (not more than 180 char.)

templateType

TEXT

Carousel--data-urlencode 'cards'LTO--data-urlencode 'limitedOfferText= {limited offer text}' --data-urlencode 'hasExpiration= {true/false}' --data-urlencode 'isLTO=true

String

NA

The type of template: TEXT, IMAGE, LOCATION, PRODUCT, CATALOG, LTO, CAROUSEL, VIDEO & DOCUMENTCATALOG, LTO, CAROUSEL templates are not available with the On-premises API

CATALOG, LTO, CAROUSEL and PRODUCT templates are available for MARKETING & UTILITY category only.Cards to be cards only to be passed if template type is CAROUSEL

example

Template Example

String

NA

enableSample

Required for creating all types of templates

true/false

NA

if enableSample is true then exampleMedia

header

Header of the template. Applicable for templateType = Text Character limit: 60. Not applicable for "Authentication" category.

String

NA

footer

Footer of the template. Character limit: 60. Not applicable for "Authentication" category, only set based on code_expiration_minutes value

String

NA

buttons

Array of objects

NA

allowTemplateCategoryChange

Boolean value. If True, Meta will automatically update the category of the template as per the template content. Default value is False. If the category gets updated, you can view the oldCategory from the Get Templates API

true/false

NA

exampleHeader

This is the header

String

NA

addSecurityRecommendation

Optionally for "Authentication" category a security disclaimer is added to content - For your security, do not share this code

Boolean

NA

true

codeExpirationMinutes

Optionally for "Authentication" category the following text is added to footer - This code expires in <NUM_MINUTES> minutes. Code expiry time should be between 1 and 90 minutes.

Integer

NA

message_send_ttl_seconds

If we are unable to deliver a message to a WhatsApp user, we will retry the delivery for a period of time known as a time-to-live, TTL, or the message validity period.

Valid message_send_ttl_seconds property values
Authentication templates: 30 to 900 seconds (30 secs to 15 mins). Utility templates: 30 to 43200 seconds (30 secs to 12 hours). Marketing templates: 43200 to 2592000 (12 hours to 30 days)

Integer

NA

📘

NOTE:

  • marketing ttl is only available on MM lite, and not available on CAPI.

Sample Request

curl --location --request POST 'https://partner.gupshup.io/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 'category={{CATEGORY}}' \
--data-urlencode 'templateType={{TEMPLATE_TYPE}}' \
--data-urlencode 'vertical=TEXT' \
--data-urlencode 'content=your ticket has been confirmed for {{1}} persons on date {{2}}.' \
--data-urlencode 'header=This is the header' \
--data-urlencode 'footer=This is the footer' \
--data-urlencode 'buttons=[{"type":"PHONE_NUMBER","text":"Call Us","phone_number":"+919872329959"},{"type":"URL","text":"Book A Demo","url":"https://bookins.gupshup.io/{{1}}","example":["https://bookins.gupshup.io/abc"]}] or for “Authentication” category: [{"type":"OTP","otp_type":"COPY_CODE","text":"Copy OTP"},{"type":"OTP", “otp-type”: “ONE_TAP”, "text":"Book A Demo", "autofill_text": "Autofill", #One-tap buttons only "package_name": "com.example.myapplication" #One-tap buttons only , "signature_hash": "K8a%2FAINcGX7", #One-tap buttons only }]' \
--data-urlencode 'example=your ticket has been confirmed for 4 persons on date 2020-05-04.' \
--data-urlencode 'enableSample=true' \
--data-urlencode 'message_send_ttl_seconds=43200' \
--data-urlencode 'allowTemplateCategoryChange=false' \'

Sample Response

{
    "status": "success",
    "template": {
        "appId": "bf9ee64c-3d4d-4ac4-8668-732e577007c4",
        "category": "MARKETING",
        "containerMeta": "{\"appId\":\"bf9ee64c-3d4d-4ac4-8668-732e577007c4\",\"data\":\"This is category for copy code button template.\",\"footer\":\"This is footer\",\"sampleText\":\"This is category for copy code button template.\",\"enableSample\":true,\"editTemplate\":false,\"allowTemplateCategoryChange\":true,\"addSecurityRecommendation\":false}",
        "createdOn": 1708205191624,
        "data": "This is category for copy code button template.\nThis is footer",
        "elementName": "automation_template_2956534",
        "id": "e8e837c2-a3a8-4845-958f-ec7febb54aec",
        "languageCode": "en",
        "languagePolicy": "deterministic",
        "meta": "{\"example\":\"This is category for copy code button template.\"}",
        "modifiedOn": 1708205191624,
        "namespace": "18cfa544_9c62_4dcd_b8f3_b3785d8c917c",
        "priority": 1,
        "quality": "UNKNOWN",
        "retry": 0,
        "stage": "NONE",
        "status": "PENDING",
        "templateType": "TEXT",
        "vertical": "Internal_vertical",
        "wabaId": "216141188246170"
    }
}

Status Codes

Status Code

Response

Comments

Success

200

{

"status": "success","template":{"appId": "bf9ee64c-3d4d-4ac4-8668-732e577007c4","category": "MARKETING","containerMeta": "{\"appId\":\"bf9ee64c-3d4d-4ac4-8668-732e577007c4\",\"data\":\"This is category for copy code button template.\",\"footer\":\"This is footer\",\"sampleText\":\"This is category for copy code button template.\",\"enableSample\":true,\"editTemplate\":false,\"allowTemplateCategoryChange\":true,\"addSecurityRecommendation\":false}","createdOn": 1708205191624,"data": "This is category for copy code button template.\nThis is footer","elementName": "automation_template_2956534","id": "e8e837c2-a3a8-4845-958f-ec7febb54aec","languageCode": "en","languagePolicy": "deterministic","meta": "{\"example\":\"This is category for copy code button template.\"}","modifiedOn": 1708205191624,"namespace": "18cfa544_9c62_4dcd_b8f3_b3785d8c917c", "priority": 1, "quality": "UNKNOWN", "retry": 0, "stage": "NONE", "status": "PENDING", "templateType": "TEXT", "vertical": "Internal_vertical", "wabaId": "216141188246170" } }

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, then contact Gupshup Dev Support"}

For any Internal Error

Language
Click Try It! to start a request and see the response here!