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
- 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.
- To set up a WhatsApp account on Kaleyra platform, see Manual Signup
 and Embedded Signup.
- 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.
- A WABA ID onboarded on Kaleyra WhatsApp API V2.
 
API Domain and Value
| api_domain | Value | 
|---|---|
| IN pod | api.in.kaleyra.io | 
| SG Pod | api.ap.kaleyra.io | 
| EU Pod | api.eu.kaleyra.io | 
| NA pod | api.na.kaleyra.ai | 
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.
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 \ 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_templatesURL Parameters and Header Parameters
Following is the list of header parameters:
| Parameter / Headers | Data Type | Description | Example | Mandatory? | 
|---|---|---|---|---|
| sid | String | Account SID (Security Identifier). | HXAP16XXXXXX97IN | Yes | 
| waba-id | String | WhatsApp business account id. | xxxxx48869xxxxx | Yes | 
| Content-Type | String | Indicates the format of the content the API will be processing. | The only allowed value is application/json. | Yes | 
| api-key | String | API key generated from Kaleyra platform account. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes | 
Following is the list of query parameters:
| Parameter | Data Type | Description | Example | Mandatory? | 
|---|---|---|---|---|
| Template_name | String | Template name. | Marketing_template | No | 
| whatsapp_template_id | String | The unique WhatsApp template ID. | ID83258xxxxx42871 | No | 
| status | String | The status of the WhatsApp template for approval. | approved | Yes | 
| category | String | The template category. | Marketing | Yes | 
| limit | Integer | The number of templates shown in the GET response. The default value is 25. | 10 | No | 
| offset | Integer | If 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 | No | 
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:
| Parameter | Data Type | Description | Example | 
|---|---|---|---|
| code | String | The response code for the request sent. | WA200 | 
| message | String | The response message corresponding to the response code. | Request Processed Successfully. | 
| data | Object | This object shows the details of the WhatsApp template details. | See the specific table below for details. | 
| error | Array | The error list associated with the response. | { } | 
| limit | Integer | The number of templates shown in the GET response. The default value is 25. | 10 | 
| offset | Integer | If 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 | 
| count | Integer | The 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.
| Parameter | Data Type | Description | Example | 
|---|---|---|---|
| allow_category_change | Boolean | This indicates, if the template allows the category to be changed after the template creation. | True | 
| category | String | The template category | Marketing | 
| company_id | String | The company id that is associated with the template. | app_company | 
| components | Object | This object lists the components of the template. | See the specific table below for details. | 
| language | String | The language used in the template. | En_US | 
| name | String | The name of the template. | Marketing_template | 
| previous_category | String | The template category that was assigned to the template prior to the category change. | Authentication | 
| status | String | The approval status of the template. | Approved | 
| waba_id | String | The waba_id associated with the template | 15044XXXX142241 | 
| Whatsapp_template_id | String | The unique WhatsApp template ID. | 83258xxxxx42871 | 
Components Object Parameters
The following is the list of parameters for Components object in the API response.
| Parameter | Data Type | Description | Example | 
|---|---|---|---|
| type | String | The type of component within the template. | Header, Body, Footer, and Buttons | 
| format | String | The format of the component. | Text | 
| text | String | The component text displayed in the component. | Our Summer sale is on! | 
| example | Object | This 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.
| Parameter | Data Type | Description | Example | 
|---|---|---|---|
| Header_text | String | The 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"
    }
}Updated about 1 month ago
