Templates: Editing

Delete Template

Removes an html template and all its versions.

POSThttps://g.sendcorex.com/v1/templatecommand: delete_template
i

Needs the template:delete scope on your API key.

i

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.

i

Unlayer and Custom templates are deleted in the dashboard.

Arguments

  • template_idstringrequired

    An 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_id

    The template that was removed.

  • deleted

    Always true.

Errors

HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.

  • 401INVALID_API_KEY

    The API key does not exist, was revoked or was disabled in the dashboard.

  • 429RATE_LIMITED

    More than 15 requests/s or 15 in flight for the same IP + API key. Wait the number of seconds in Retry-After.

  • CMDMISSING_SCOPE

    The API key does not have the scope this command needs.

  • CMDINVALID_ARGS

    An 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…

  • CMDTEMPLATE_NOT_FOUND

    The template is not on your account.

  • CMDTEMPLATE_READ_ONLY

    An Unlayer or Custom template: edit it in the dashboard editor. Only html templates change through the API.

  • CMDRATE_LIMITED

    This command was called too many times in the last minute by your account. Wait a minute.

  • CMDINTERNAL

    Server error. The detail is only written to the server log.