Templates, media and key check
List your message templates, download media files from chats, and check that an API key works.
List templates#
https://app.zapgen.ae/api/templatesReturns the message templates in your organization, paginated. Use it to find a template's exact name and language before you send it.
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | No | Page number, from 1. |
per_page | integer | No | Templates per page, 1–100. Default 10. |
curl "https://app.zapgen.ae/api/templates?per_page=100" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"const res = await fetch('https://app.zapgen.ae/api/templates?per_page=100', {
headers: { Authorization: 'Bearer YOUR_API_KEY', Accept: 'application/json' }
});
const { data } = await res.json();
const templates = data.map(t => ({ uuid: t.uuid, name: t.name, ...JSON.parse(t.metadata) }));$ch = curl_init('https://app.zapgen.ae/api/templates?per_page=100');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Accept: application/json'],
]);
foreach (json_decode(curl_exec($ch), true)['data'] as $template) {
$meta = json_decode($template['metadata'], true);
echo $template['name'] . ' ' . ($meta['language'] ?? '') . PHP_EOL;
}import json
import requests
res = requests.get(
"https://app.zapgen.ae/api/templates",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
params={"per_page": 100},
)
for t in res.json()["data"]:
meta = json.loads(t["metadata"])
print(t["name"], meta.get("language"), meta.get("status")){
"data": [
{
"uuid": "7c2e9f41-0b6d-4a3e-8f15-6d9a2c4b1e07",
"name": "order_ready",
"metadata": "{\"name\":\"order_ready\",\"language\":\"en_US\",\"status\":\"APPROVED\",\"category\":\"UTILITY\",\"components\":[{\"type\":\"BODY\",\"text\":\"Hi, your order {{1}} is ready for pickup.\"}],\"id\":\"1234567890123456\"}",
"updated_at": "03 Oct 2026 6:20 PM"
}
],
"links": { "first": "…", "last": "…", "prev": null, "next": null },
"meta": { "current_page": 1, "last_page": 1, "per_page": 100, "total": 1 }
}Each template has just four fields:
| Field | Description |
|---|---|
uuid | The template's ID in ZAPGEN. |
name | The template name to use when sending. |
metadata | A JSON string with the template as Meta describes it: language, category, components (header, body, footer, buttons) and, once synced with Meta, status. Parse it before use. |
updated_at | When the template last changed, formatted for display. |
The list includes templates in every status. Before sending, check status in metadata is APPROVED. If status is missing, click Sync templates in the app to refresh your templates from Meta. Status, category and language aren't separate fields yet.
For a ready-made request body, use Copy API payload on the Templates page in the app. See Send a template.
Creating templates through the API isn't available yet. Create them in the app: see Create a template.
Download chat media#
https://app.zapgen.ae/api/chat-media/{id}Downloads a photo, video, voice note or document from a chat in your organization. id is ZAPGEN's numeric media ID.
You'll find media IDs in:
- the
media_idof the chat in a send response or amessage.sentwebhook for media you sent; - the file link that a Flow Builder webhook step includes after a "Wait for attachment" step. That link already points to this endpoint.
curl https://app.zapgen.ae/api/chat-media/18342 \
-H "Authorization: Bearer YOUR_API_KEY" \
-L -o attachmentimport { writeFile } from 'node:fs/promises';
const res = await fetch('https://app.zapgen.ae/api/chat-media/18342', {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
if (res.ok) await writeFile('attachment', Buffer.from(await res.arrayBuffer()));$ch = curl_init('https://app.zapgen.ae/api/chat-media/18342');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$file = curl_exec($ch);
$type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
file_put_contents('attachment', $file);import requests
res = requests.get(
"https://app.zapgen.ae/api/chat-media/18342",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
if res.ok:
with open("attachment", "wb") as f:
f.write(res.content)The response is the file itself, with its type in Content-Type and its name in Content-Disposition. Some older files answer with a redirect to the file's address instead, so let your HTTP client follow redirects.
| Status | Body | Meaning |
|---|---|---|
200 | The file | Here's the file. |
302 | The file lives at another address. Follow the redirect. | |
404 | {"error": "Media not found"} | No media with that ID in your organization. |
410 | {"error": "Media expired"} | The file was deleted. Chat media is kept for 30 days. |
ZAPGEN deletes chat media files 30 days after they arrive or are sent. Download anything you need to keep.
Check an API key#
https://app.zapgen.ae/api/verifyConfirms that a key is valid and your subscription is active. It has no parameters, and it's a good first call when you set up an integration.
curl https://app.zapgen.ae/api/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"const res = await fetch('https://app.zapgen.ae/api/verify', {
headers: { Authorization: 'Bearer YOUR_API_KEY', Accept: 'application/json' }
});
const ok = res.status === 200;$ch = curl_init('https://app.zapgen.ae/api/verify');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Accept: application/json'],
]);
curl_exec($ch);
$ok = curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;import requests
res = requests.get(
"https://app.zapgen.ae/api/verify",
headers={"Authorization": "Bearer YOUR_API_KEY", "Accept": "application/json"},
)
ok = res.status_code == 200{
"statusCode": 200,
"message": "API key is valid and active"
}| Status | message |
|---|---|
200 | API key is valid and active |
401 | Unauthorized. Invalid Bearer Token. (or Bearer Token is missing.) |
403 | API key is inactive. Please renew or subscribe to a plan to continue! |