Template: Versioni

Ripristina versione del modello

Riporta un template html a una versione precedente: html, text e subject. Il ripristino stesso diventa la versione più recente, quindi puoi annullare anche quello.

POSThttps://g.sendcorex.com/v1/templatecommand: restore_template_version

Richiede lo scope template:update sulla tua API key.

Fino a 20 chiamate al minuto per account. Oltre, il comando risponde RATE_LIMITED.

Argomenti

  • template_idstringobbligatorio

    Un template html.

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

  • version_atstringobbligatorio

    Il version_at di List Template Versions, così com'è arrivato.

    es. "2026-10-21T04:09:12.004Z"

Avvio rapido

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/template',
  {
    commands: [
      {
        command: "restore_template_version",
        args: {
          template_id: "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
          version_at: "2026-10-21T04:09:12.004Z"
        }
      }
    ]
  },
  { 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);

Risposta

{
  "type": "SUCCESS",
  "results": [
    {
      "command": "restore_template_version",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 11,
      "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:40:02.118Z",
        "subject": "Welcome to Acme",
        "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"
      }
    }
  ]
}

Campi della risposta

  • template_id

    L'id del template: html_<uuid>, unlayer_<number> o custom_<uuid>. Usalo in tutti gli altri comandi.

  • type

    html (il tuo, inviato tramite l'API), unlayer (creato nell'editor drag-and-drop) o custom (creato nell'editor di Sendcorex).

  • name

    Il nome che gli hai dato.

  • reference

    Un codice breve che identifica il template anche nella dashboard.

  • preview

    Un'immagine del template, per i template dell'editor. null per i template html e per i template dell'editor non ancora salvati.

  • has_html

    false per un template dell'editor creato ma mai salvato. Non può ancora essere renderizzato né inviato.

  • html_size

    Dimensione dell'html, in byte.

  • editable

    true per i template html: qui puoi aggiornarli, ripristinarli ed eliminarli. I template dell'editor sono di sola lettura tramite l'API.

  • created_at / updated_at

    ISO 8601, UTC.

  • subject

    L'oggetto predefinito, o null. Può contenere variabili.

  • html

    L'html. null per un template dell'editor mai salvato.

  • text

    La versione in testo semplice, o null. Inviane una: alcuni client e filtri preferiscono le email che ce l'hanno.

Errori

Gli errori a livello HTTP restituiscono type, code e message. Gli errori marcati CMD tornano dentro il risultato del comando, con HTTP 200.

  • 401INVALID_API_KEY

    La API key non esiste, è stata revocata o disattivata nella dashboard.

  • 429RATE_LIMITED

    Più di 15 richieste/s o 15 in corso per la stessa IP + API key. Attendi i secondi indicati in Retry-After.

  • CMDMISSING_SCOPE

    La API key non ha lo scope richiesto da questo comando.

  • CMDINVALID_ARGS

    Un argomento non è valido: un `template_id` malformato, `name` o `html` mancante, un nome oltre 255 caratteri, un `version_at` non in RFC 3339…

  • CMDTEMPLATE_NOT_FOUND

    Il template non è nel tuo account.

  • CMDTEMPLATE_READ_ONLY

    Un template Unlayer o Custom: modificalo nell'editor della dashboard. Tramite l'API cambiano solo i template html.

  • CMDVERSION_NOT_FOUND

    Quella versione non esiste. Vengono conservate solo le ultime 10.

  • CMDRATE_LIMITED

    Il tuo account ha chiamato questo comando troppe volte nell'ultimo minuto. Attendi un minuto.

  • CMDINTERNAL

    Errore del server. Il dettaglio viene scritto solo nel log del server.