Template: Modifica
Update Template
Cambia nome, html, testo o oggetto di un template html. Ogni modifica salva una versione, così puoi tornare indietro: vengono conservate le ultime 10.
https://g.sendcorex.com/v1/templatecommand: update_templateRichiede lo scope template:update sulla tua API key.
Fino a 60 chiamate al minuto per account. Oltre, il comando risponde RATE_LIMITED.
Invia solo ciò che cambia. text o subject come null o "" lo svuota.
I template Unlayer e Custom rispondono TEMPLATE_READ_ONLY: modificali nella dashboard.
Argomenti
template_idstringobbligatorioUn template html.
es.
"html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93"namestringfacoltativoFino a 255 caratteri, senza HTML.
es.
"Welcome email v2"htmlstringfacoltativoIl nuovo html, fino a 512 KB. Controllato come in Create Template.
textstring | nullfacoltativoLa nuova versione in testo semplice.
subjectstring | nullfacoltativoIl nuovo oggetto predefinito.
es.
"Welcome aboard, {{first_name}}"
Avvio rapido
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);Risposta
{
"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"
}
}
]
}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.
Tenere i template nel tuo repo
Un'unica fonte di veritàTieni l'html nel tuo codice e chiama Update Template dal tuo deploy. Il team rivede i template come qualsiasi altra modifica.
Rollback sicuriSe un deploy rompe un template, Restore Template Version riporta l'ultimo buono con una sola chiamata.
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
UNSAFE_HTMLL'html contiene qualcosa che un'email non può contenere: `<script>`, `<iframe>`, form, handler `on*=`, link `javascript:`… Il messaggio dice esattamente cosa rimuovere.
- CMD
TEMPLATE_TOO_LARGEL'html supera 512 KB. Ospita le immagini e collegale invece di incorporarle.
- 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.