Get Templates

The GET Template API allows you to fetch all the WhatsApp templates that are created using the Kaleyra APIs/UI associated with a WhatsApp Business Account (WABA) ID.

Prerequisites

  1. Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
    A prerequisite for using Kaleyra WhatsApp APIs is to have an active WhatsApp plan on kaleyra platform.
  2. To set up a WhatsApp account on kaleyra.io, see Manual Signup
    and Embedded Signup.
  3. An active WhatsApp for Business API plan that includes:
    • A WhatsApp business number.
    • An associated profile with the business number.
    • A WhatsApp verified and approved profile.

Base URL

https://<api_domain>/v2/<SID>

API Domain and Value

api_domainValue
IN podapi.in.kaleyra.io
SG Podapi.ap.kaleyra.io
EU Podapi.eu.kaleyra.io

API request to get WhatsApp templates

To get a list of all the WhatsApp templates associated with a waba-id, use the <api_domain>/v2/<sid>/whatsapp/<waba-id>/message_templates endpoint.

Request Format

The following is the request format to get the WhatsApp templates:

curl --location --request GET https://<api_domain>/v2/<sid>/whatsapp/<waba-id>/message_templates \ 

Sample Request Format

The following is the sample request format to get the WhatsApp templates:

curl --location --request GET https://api.in.kaleyra.io/v2/HXAP16XXXXXX97IN/whatsapp/xxxxx48869xxxxx/message_templates

URL Parameters and Header Parameters

Following is the list of header parameters:

Parameter / HeadersData TypeDescriptionExampleMandatory?
sidStringAccount SID (Security Identifier).HXAP16XXXXXX97INYes
waba-idStringWhatsApp business account id.xxxxx48869xxxxxYes
Content-TypeStringIndicates the format of the content the API will be processing.The only allowed value is application/json.Yes
api-keyStringAPI key generated from Kaleyra platform account.Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3Yes

Following is the list of query parameters:

ParameterData TypeDescriptionExampleMandatory?
Template_nameStringTemplate nameMarketing_templateNo
whatsapp_template_idStringThe unique WhatsApp template IDID83258xxxxx42871No
statusStringThe status of the WhatsApp template for approval.approvedYes
categoryStringThe template category.MarketingYes
limitIntegerThe number of templates shown in the GET response. The default value is 25.10No
offsetIntegerIf the GET response cannot be displayed on a single page, you can use the offset value to view the templates after that. The default value is 0.0No

Sample Success Response

The following success message appears with the status 200 Accepted:

{
    "code": "WA200",
    "message": "Request Processed Successfully",
    "data": [
        {
            "allow_category_change": true,
            "category": "Marketing",
            "company_id": "app_company",
            "components": [
                {"type": "app_company",
      					"format": "TEXT",
      					"text": "Our sale is on!"
                }
            ],
            "language": "en_US",
            "name": "Mrkt_template",
            "previous_category": "marketing",
            "status": "approved",
            "waba_id": "xxxxx48869xxxxx",
            "whatsapp_template_id": "83258xxxxx42871"
        }
    ],
    "error": {},
    "limit": 10,
    "offset": 0,
    "count": 50
}

Response Parameters

The following is the list of parameters shown in the API response:

ParameterData TypeDescriptionExample
codeStringThe response code for the request sent.WA200
messageStringThe response message corresponding to the response code.Request Processed Successfully.
dataObjectThis object shows the details of the WhatsApp template details.See the specific table below for details.
errorArrayThe error list associated with the response.{ }
limitIntegerThe number of templates shown in the GET response. The default value is 25.10
offsetIntegerIf the GET response cannot be displayed on a single page, you can use the offset value to view the templates after that. The default value is 0.0
countIntegerThe count of the template int the response output.5

Data object Parameters

The following is the list of parameters for Data object in the API response.

ParameterData TypeDescriptionExample
allow_category_changeBooleanThis indicates, if the template allows the category to be changed after the template creation.True
categoryStringThe template categoryMarketing
company_idStringThe company id that is associated with the template.app_company
componentsObjectThis object lists the components of the template.See the specific table below for details.
languageStringThe language used in the template.En_US
nameStringThe name of the template.Marketing_template
previous_categoryStringThe template category that was assigned to the template prior to the category change.Authentication
statusStringThe approval status of the template.Approved
waba_idStringThe waba_id associated with the template15044XXXX142241
Whatsapp_template_idStringThe unique WhatsApp template ID.83258xxxxx42871

Components Object Parameters

The following is the list of parameters for Components object in the API response.

ParameterData TypeDescriptionExample
typeStringThe type of component within the template.Header, Body, Footer, and Buttons
formatStringThe format of the component.Text
textStringThe component text displayed in the component.Our Summer sale is on!
exampleObjectThis object shows an example of the component.See the specific table below for details.

Example Object Parameters

The following is the list of parameters for Example object in the API response.

ParameterData TypeDescriptionExample
Header_textStringThe header component text shown as an example.Our Summer sale is on!

Sample Failure Response

The following are the failure responses:

401 Unauthorized
{
    "code": "RBC001",
    "message": "Incorrect SID or API key.",
    "data": [],
    "error": {
        "error": "Incorrect SID or API key."
    }
}
401 Wrong account
{
    "code": "WA-401",
    "message": "API is not available for given customer.Please contact support for more info",
    "data": {},
    "error": "API is not available for given customer.Please contact support for more info"
}
 
401 Unauthorized WABA
{
    "code": "WA401",
    "message": "Waba_Id is not present or does not belong to the account.",
    "data": {},
    "error": {
        "waba_id": "Waba_Id is not present or does not belong to the account."
    }
}
401 Unauthorized WABA version
{
    "code": "WA401",
    "message": "The waba_id you're using is associated with different Version of our WA API. Please use the appropriate endpoint.",
    "data": {},
    "error": {
        "waba_id": "The waba_id you're using is associated with different Version of our WA API. Please use the appropriate endpoint."
    }
}
400 Invalid Status
{
    "code": "WA400",
    "message": "invalid status given. valid values are : accepted, pending, rejected, paused, disabled",
    "data": [],
    "error": {
        "status": "invalid status given. valid values are : accepted, pending, rejected, paused, disabled"
    }
}
400 Invalid Category
{
    "code": "WA400",
    "message": "invalid category given. valid values are : marketing, utility, authentication",
    "data": [],
    "error": {
        "category": "invalid category given. valid values are : marketing, utility, authentication"
    }
}
400 Invalid limit
{
    "code": "WA400",
    "message": "please provide a valid positive number",
    "data": [],
    "error": {
        "limit": "please provide a valid positive number"
    }
}

400 Invalid Offset
{
    "code": "WA400",
    "message": "please provide a valid positive number",
    "data": [],
    "error": {
        "offset": "please provide a valid positive number"
    }
}

500 Internal Server Error
{
    "code": "WA-500",
    "message": "Please try again later",
    "data": {},
    "error": {
        "error": "Internal server error"
    }
}