Templates: Routes
Run Commands
The single entry point for templates. Send 1 to 10 commands in one request and get one result per command.
https://g.sendcorex.com/v1/templateSame envelope as Domains, Senders and Contacts. The pages below this one document each command.
Errors are reported per command. A command that fails does not stop the others, and the HTTP status stays 200.
Body parameters
commandsobject[]required1 to 10 commands, executed in order. The whole body can have up to 1 MB.
commands[].commandstringrequiredlist_templates,get_template,render_template,create_template,update_template,delete_template,list_template_versionsorrestore_template_version.commands[].argsobjectoptionalThe command arguments. Any value can be a
$refto the result of an earlier command.commands[].idstringoptionalYour own identifier for the result. Defaults to the index (
"0","1"…). Required if you want to use$ref.
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1/template',
{
commands: [
{
command: "list_templates",
id: "all"
},
{
command: "render_template",
id: "preview",
args: {
template_id: "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
variables: {
first_name: "Ana",
plan: "Pro"
}
}
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);
for (const result of response.data.results) {
if (result.type !== 'SUCCESS') console.error(result.id, result.code, result.message);
else console.log(result.id, result.data);
}Response
{
"type": "SUCCESS",
"results": [
{
"command": "list_templates",
"id": "all",
"type": "SUCCESS",
"took_ms": 6,
"data": {
"templates": [
{
"template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
"type": "html",
"name": "Welcome email",
"reference": "K7Q2M9XR4T",
"preview": null,
"has_html": true,
"html_size": 248,
"editable": true,
"created_at": "2026-10-21T04:02:11.310Z",
"updated_at": "2026-10-21T04:15:40.902Z"
},
{
"template_id": "unlayer_1284",
"type": "unlayer",
"name": "October newsletter",
"reference": "B3VN8QK1ZT",
"preview": "https://res.cloudinary.com/dmg04ffuy/image/upload/v1760000000/previews/oct_newsletter.png",
"has_html": true,
"html_size": 48211,
"editable": false,
"created_at": "2026-10-01T09:12:00.000Z",
"updated_at": "2026-10-18T16:40:22.118Z"
}
]
}
},
{
"command": "render_template",
"id": "preview",
"type": "SUCCESS",
"took_ms": 3,
"data": {
"template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
"subject": "Welcome to Acme, Ana",
"html": "<!doctype html><html><body style=\"font-family:Arial,sans-serif\"><h1>Welcome, Ana!</h1><p>Your Pro plan is ready.</p><p><a href=\"https://acme.com/start\">Get started</a></p></body></html>",
"text": "Welcome, Ana! Your Pro plan is ready. Get started: https://acme.com/start",
"missing_variables": []
}
}
]
}Response fields
typeAlways
SUCCESSwhen the request itself was accepted.results[].commandThe command that produced this result.
results[].idThe
idyou sent, or the index of the command.results[].typeSUCCESSorERROR.results[].took_msTime the command took inside the server.
results[].dataThe command output. Only present when
typeisSUCCESS.results[].code / messageThe error. Only present when
typeisERROR.
Authentication
Use the API key you create in the dashboard, under Developers → API Keys, with the scopes the commands need.
AuthorizationSend
Authorization: <api key>orAuthorization: Bearer <api key>.template:readlist_templates,get_template,render_templateandlist_template_versions.template:createcreate_template.template:updateupdate_templateandrestore_template_version.template:deletedelete_template.Mailbox tokensThe webmail token does not work here. It is rejected with
WRONG_CREDENTIAL_TYPE.Allowed IPsIf the key has an IP allowlist, requests from other IPs get
403 IP_NOT_ALLOWED.
Chaining with $ref
Create a template and render it in the same request to check the result.
create_template → render_template
{
"commands": [
{
"command": "create_template",
"id": "new",
"args": {
"name": "Welcome email",
"subject": "Welcome to Acme, {{first_name}}",
"html": "<!doctype html><html><body style=\"font-family:Arial,sans-serif\"><h1>Welcome, {{first_name}}!</h1><p>Your {{plan}} plan is ready.</p><p><a href=\"https://acme.com/start\">Get started</a></p></body></html>"
}
},
{
"command": "render_template",
"args": {
"template_id": {
"$ref": "new",
"path": "template_id"
},
"variables": {
"first_name": "Ana",
"plan": "Pro"
}
}
}
]
}Rate limits and cache
15 requests / secondPer IP + API key. Over it, HTTP 429 with a
Retry-Afterheader.15 in flightAt most 15 requests being processed at the same time, per IP + API key.
Per command, per accountcreate_template30/min ·update_template60/min ·restore_template_version20/min ·delete_template30/min. Over it, that command answersRATE_LIMITED.Read cache: 1.5 sThe same read within 1.5 seconds returns the same result. Any write on the route clears it.
Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 400
INVALID_JSONThe body is not {"commands":[...]} or is larger than 1 MB.
- 400
INVALID_ARGSThe request has no commands or more than 10.
- 401
MISSING_AUTH_HEADERNo Authorization header was sent.
- 401
INVALID_API_KEYThe API key does not exist, was revoked or was disabled in the dashboard.
- 401
API_KEY_EXPIREDThe API key passed the expiration date set in the dashboard.
- 401
WRONG_CREDENTIAL_TYPEA mailbox token was sent. The Templates API needs a dashboard API key.
- 403
IP_NOT_ALLOWEDThe request came from an IP that is not in the allowed IPs of the key.
- 403
ACCOUNT_BLOCKEDThe account is blocked.
- 403
MISSING_SCOPEThe key has no `template:*` scope, so no command can run.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + API key. Wait the number of seconds in Retry-After.
- 503
AUTH_UNAVAILABLEAuthentication is temporarily unavailable. Try again.
- CMD
UNKNOWN_COMMANDThe command name does not exist.
- CMD
INTERNALServer error. The detail is only written to the server log.