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.
https://g.sendcorex.com/v1/templatecommand: restore_template_versionRichiede lo scope template:update sulla tua API key.
Fino a 20 chiamate al minuto per account. Oltre, il comando risponde RATE_LIMITED.
Argomenti
template_idstringobbligatorioUn template html.
es.
"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"version_atstringobbligatorioIl
version_atdi 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_idL'id del template:
html_<uuid>,unlayer_<number>ocustom_<uuid>. Usalo in tutti gli altri comandi.typehtml(il tuo, inviato tramite l'API),unlayer(creato nell'editor drag-and-drop) ocustom(creato nell'editor di Sendcorex).nameIl nome che gli hai dato.
referenceUn codice breve che identifica il template anche nella dashboard.
previewUn'immagine del template, per i template dell'editor.
nullper i template html e per i template dell'editor non ancora salvati.has_htmlfalseper un template dell'editor creato ma mai salvato. Non può ancora essere renderizzato né inviato.html_sizeDimensione dell'html, in byte.
editabletrueper i template html: qui puoi aggiornarli, ripristinarli ed eliminarli. I template dell'editor sono di sola lettura tramite l'API.created_at / updated_atISO 8601, UTC.
subjectL'oggetto predefinito, o
null. Può contenere variabili.htmlL'html.
nullper un template dell'editor mai salvato.textLa 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.
- 401
INVALID_API_KEYLa API key non esiste, è stata revocata o disattivata nella dashboard.
- 429
RATE_LIMITEDPiù di 15 richieste/s o 15 in corso per la stessa IP + API key. Attendi i secondi indicati in Retry-After.
- CMD
MISSING_SCOPELa API key non ha lo scope richiesto da questo comando.
- CMD
INVALID_ARGSUn argomento non è valido: un `template_id` malformato, `name` o `html` mancante, un nome oltre 255 caratteri, un `version_at` non in RFC 3339…
- CMD
TEMPLATE_NOT_FOUNDIl template non è nel tuo account.
- CMD
TEMPLATE_READ_ONLYUn template Unlayer o Custom: modificalo nell'editor della dashboard. Tramite l'API cambiano solo i template html.
- CMD
VERSION_NOT_FOUNDQuella versione non esiste. Vengono conservate solo le ultime 10.
- CMD
RATE_LIMITEDIl tuo account ha chiamato questo comando troppe volte nell'ultimo minuto. Attendi un minuto.
- CMD
INTERNALErrore del server. Il dettaglio viene scritto solo nel log del server.