Templates: Editing
Delete Template
Removes an html template and all its versions.
https://g.sendcorex.com/v1/templatecommand: delete_templateNeeds the template:delete scope on your API key.
Up to 30 calls per minute per account. Over that, the command answers RATE_LIMITED.
This cannot be undone. Campaigns and emails already sent keep their own copy of the content and are not affected.
Unlayer and Custom templates are deleted in the dashboard.
Arguments
template_idstringrequiredAn html template.
e.g.
"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1/template',
{
commands: [
{
command: "delete_template",
args: {
template_id: "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"
}
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);
const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);Response
{
"type": "SUCCESS",
"results": [
{
"command": "delete_template",
"id": "0",
"type": "SUCCESS",
"took_ms": 6,
"data": {
"template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
"deleted": true
}
}
]
}Response fields
template_idThe template that was removed.
deletedAlways
true.
Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
INVALID_API_KEYThe API key does not exist, was revoked or was disabled in the dashboard.
- 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.
- CMD
MISSING_SCOPEThe API key does not have the scope this command needs.
- CMD
INVALID_ARGSAn argument is invalid: a malformed `template_id`, a missing `name` or `html`, a name over 255 characters, a `version_at` that is not RFC 3339…
- CMD
TEMPLATE_NOT_FOUNDThe template is not on your account.
- CMD
TEMPLATE_READ_ONLYAn Unlayer or Custom template: edit it in the dashboard editor. Only html templates change through the API.
- CMD
RATE_LIMITEDThis command was called too many times in the last minute by your account. Wait a minute.
- CMD
INTERNALServer error. The detail is only written to the server log.