Templates: Editing

Update Template

Changes the name, html, text or subject of an html template. Each change saves a version, so you can go back: the last 10 are kept.

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

Needs the template:update scope on your API key.

i

Up to 60 calls per minute per account. Over that, the command answers RATE_LIMITED.

i

Send only what changes. text or subject as null or "" clears it.

!

Unlayer and Custom templates answer TEMPLATE_READ_ONLY: edit them in the dashboard.

Arguments

  • template_idstringrequired

    An html template.

    e.g. "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"

  • namestringoptional

    Up to 255 characters, no HTML.

    e.g. "Welcome email v2"

  • htmlstringoptional

    The new html, up to 512 KB. Checked like in Create Template.

  • textstring | nulloptional

    The new plain-text version.

  • subjectstring | nulloptional

    The new default subject.

    e.g. "Welcome aboard, {{first_name}}"

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/template',
  {
    commands: [
      {
        command: "update_template",
        args: {
          template_id: "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
          subject: "Welcome aboard, {{first_name}}"
        }
      }
    ]
  },
  { 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": "update_template",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 8,
      "data": {
        "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:31:08.447Z",
        "subject": "Welcome aboard, {{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>",
        "text": "Welcome, {{first_name}}! Your {{plan}} plan is ready. Get started: https://acme.com/start"
      }
    }
  ]
}

Response fields

  • template_id

    The id of the template: html_<uuid>, unlayer_<number> or custom_<uuid>. Use it in every other command.

  • type

    html (yours, sent through the API), unlayer (built in the drag-and-drop editor) or custom (built in the Sendcorex editor).

  • name

    The name you gave it.

  • reference

    A short code that also identifies the template in the dashboard.

  • preview

    A picture of the template, for editor templates. null for html templates and for editor templates not saved yet.

  • has_html

    false for an editor template that was created but never saved. It cannot be rendered or sent yet.

  • html_size

    Size of the html, in bytes.

  • editable

    true for html templates: you can update, restore and delete them here. Editor templates are read-only through the API.

  • created_at / updated_at

    ISO 8601, UTC.

  • subject

    The default subject, or null. Can have variables.

  • html

    The html. null for an editor template that was never saved.

  • text

    The plain-text version, or null. Send one: some clients and filters prefer emails that have it.

Keeping templates in your repo

  • One source of truth

    Keep the html in your code, and call Update Template from your deploy. Your team reviews templates like any other change.

  • Safe rollbacks

    If a deploy breaks a template, Restore Template Version brings back the last good one in one call.

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.

  • CMDUNSAFE_HTML

    The html has something email cannot carry: `<script>`, `<iframe>`, forms, `on*=` handlers, `javascript:` links… The message says exactly what to remove.

  • CMDTEMPLATE_TOO_LARGE

    The html is over 512 KB. Host your images and link them instead of embedding them.

  • 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.