List the templates
GET
/v1/templatesThe templates of the account you can send — WhatsApp ones first, then SMS, by name; channel lists one channel. A message is sent with the template name of its channel in one of its languages, with a value for every variable that has no fallback in that language. Use it to check names, languages and variables before sending, or to build a picker in your system.
API key permission: send · Limit: 20 requests a second per key
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
channel | string | One of: whatsapp, sms. |
Request
bash
curl "https://api.ace-send.com/v1/templates" \
-H "Authorization: Bearer ak_live_YOUR_API_KEY"js
const response = await fetch('https://api.ace-send.com/v1/templates', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.ACE_SEND_API_KEY}`,
},
})
const result = await response.json()
if (!response.ok) {
// application/problem+json: result.code is stable, result.title is for people
throw new Error(`${result.code}: ${result.title}`)
}
console.log(result)python
import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['ACE_SEND_API_KEY']}",
}
response = requests.get(
"https://api.ace-send.com/v1/templates",
headers=headers,
timeout=10,
)
result = response.json()
if not response.ok:
# application/problem+json: result["code"] is stable, result["title"] is for people
raise RuntimeError(f"{result['code']}: {result['title']}")
print(result)php
<?php
// composer require guzzlehttp/guzzle
$client = new GuzzleHttp\Client(['base_uri' => 'https://api.ace-send.com/v1/']);
$response = $client->request('GET', 'templates', [
'headers' => [
'Authorization' => 'Bearer '.getenv('ACE_SEND_API_KEY'),
],
'http_errors' => false,
]);
$result = json_decode((string) $response->getBody(), true);
if ($response->getStatusCode() >= 400) {
// application/problem+json: $result['code'] is stable, $result['title'] is for people
throw new RuntimeException($result['code'].': '.$result['title']);
}
print_r($result);Response
200 OK
| Field | Type | Description |
|---|---|---|
data | Template[] |
json
{
"data": [
{
"name": "welcome_bonus",
"version": 3,
"channel": "whatsapp",
"category": "marketing",
"languages": [
"pt",
"en"
],
"texts": {
"pt": "Olá {{name}}! Seu bônus {{promo_code}} já está ativo.",
"en": "Hi {{name}}! Your bonus {{promo_code}} is active."
},
"variables": [
{
"key": "name",
"example": {
"pt": "Ana",
"en": "Ann"
},
"fallback": {
"pt": "cliente",
"en": "there"
}
},
{
"key": "promo_code",
"example": {
"pt": "BONUS10",
"en": "BONUS10"
},
"fallback": {}
}
]
},
{
"name": "deposit_reminder",
"version": 1,
"channel": "sms",
"category": "standard",
"languages": [
"en"
],
"texts": {
"en": "Hi {{name}}, your deposit of {{amount}} is waiting. Reply STOP to opt out."
},
"variables": [
{
"key": "name",
"example": {
"en": "Ann"
},
"fallback": {
"en": "there"
}
},
{
"key": "amount",
"example": {
"en": "$50.00"
},
"fallback": {
"en": "your bonus"
}
}
]
}
]
}Objects
Template object
| Field | Type | Description |
|---|---|---|
name | string | The name to send with (template of POST /messages), unique in the channel. |
version | integer | The number of the current version: messages answer with it. |
channel | string | One of: whatsapp, sms. |
category | string | The category of the current version, which the price of a message depends on. |
languages | string[] | The languages of the template, the primary one first. |
texts | object | The text of the current version in each language; variables are written as {{key}}. Keys map to string values. |
variables | object[] | The variables of the texts: example and fallback by language. A variable with a fallback in the language of the message may be left out of variables. |
variables[].key | string | |
variables[].example | object | Keys map to string values. |
variables[].fallback | object | Keys map to string values. |
Errors
Errors are application/problem+json with a stable code (all codes). Besides the errors of every request (an invalid key, a missing permission, too many requests), this endpoint answers:
| Status | Code | Meaning |
|---|---|---|
| 401 | api_key_invalid | No Authorization: Bearer header, or the key is unknown or revoked. After 20 failed key checks in a minute the address gets too_many_requests for the rest of the minute. |
| 403 | api_key_ip_denied | The key has an IP allowlist and the request came from another address. |
| 403 | account_suspended | The account is suspended. Contact support. |
| 403 | api_key_scope | The key lacks the permission of the endpoint (send, status or contacts). |
| 429 | too_many_requests | Over the rate limit. Wait for the seconds of the Retry-After header. |