Template: Versioni

Elenca versioni del modello

Le versioni salvate di un template, dalla più recente. Vengono conservate le ultime 10.

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

Richiede lo scope template:read sulla tua API key.

I template html salvano una versione a ogni creazione e aggiornamento. I template dell'editor ne salvano una ogni volta che clicchi Salva nella dashboard (non con il salvataggio automatico).

Argomenti

  • template_idstringobbligatorio

    Il template.

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

Avvio rapido

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/template',
  {
    commands: [
      {
        command: "list_template_versions",
        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);

Risposta

{
  "type": "SUCCESS",
  "results": [
    {
      "command": "list_template_versions",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 4,
      "data": {
        "template_id": "html_5f2c8a10-3d4e-4b6f-9a71-2c8e0d4b7a93",
        "versions": [
          {
            "version_at": "2026-10-21T04:15:40.902Z",
            "html_size": 248,
            "subject": "Welcome to Acme, {{first_name}}"
          },
          {
            "version_at": "2026-10-21T04:09:12.004Z",
            "html_size": 231,
            "subject": "Welcome to Acme"
          },
          {
            "version_at": "2026-10-21T04:02:11.310Z",
            "html_size": 198,
            "subject": null
          }
        ]
      }
    }
  ]
}

Campi della risposta

  • template_id

    Il template.

  • versions

    Dalla più recente. Vuoto quando non è stato ancora salvato nulla.

  • versions[].version_at

    Quando è stata salvata la versione. Passalo così com'è a Restore Template Version.

  • versions[].html_size

    Dimensione dell'html di quella versione, in byte.

  • versions[].subject

    L'oggetto di quella versione, o null.

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.

  • CMDINTERNAL

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