Skip to content

List the templates ​

GET/v1/templates

The 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 ​

FieldTypeRequiredDescription
channelstringOne 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 ​

FieldTypeDescription
dataTemplate[]
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 ​

FieldTypeDescription
namestringThe name to send with (template of POST /messages), unique in the channel.
versionintegerThe number of the current version: messages answer with it.
channelstringOne of: whatsapp, sms.
categorystringThe category of the current version, which the price of a message depends on.
languagesstring[]The languages of the template, the primary one first.
textsobjectThe text of the current version in each language; variables are written as {{key}}. Keys map to string values.
variablesobject[]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[].keystring
variables[].exampleobjectKeys map to string values.
variables[].fallbackobjectKeys 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:

StatusCodeMeaning
401api_key_invalidNo 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.
403api_key_ip_deniedThe key has an IP allowlist and the request came from another address.
403account_suspendedThe account is suspended. Contact support.
403api_key_scopeThe key lacks the permission of the endpoint (send, status or contacts).
429too_many_requestsOver the rate limit. Wait for the seconds of the Retry-After header.

ACE SEND API v1