Elenco Template
Recupera un elenco di tutti i template pubblicati nel tuo account Emailit. Vengono restituiti solo i template con published_at impostato. Il contenuto (html/text) è escluso dalla vista elenco.
/templatesParametri di Query
per_pageintegerElementi per pagina (1-100). Predefinito: 25.
pageintegerNumero di pagina (minimo: 1). Predefinito: 1.
filter[name]stringFiltra per nome (corrispondenza parziale).
filter[alias]stringFiltra per alias (corrispondenza esatta).
filter[editor]stringFiltra per tipo di editor: html, tiptap, o dragit.
sortstringCampo di ordinamento: name, alias, created_at, updated_at, o published_at. Predefinito: created_at.
orderstringOrdine di ordinamento: asc o desc. Predefinito: desc.
const response = await fetch('https://api.emailit.com/v2/templates?page=1&per_page=25', {
method: 'GET',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates?page=1&per_page=25',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.get(
'https://api.emailit.com/v2/templates',
params={
'page': 1,
'per_page': 25
},
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates?page=1&per_page=25')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
func main() {
baseURL := "https://api.emailit.com/v2/templates"
params := url.Values{}
params.Add("page", "1")
params.Add("per_page", "25")
fullURL := baseURL + "?" + params.Encode()
req, _ := http.NewRequest("GET", fullURL, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.get("https://api.emailit.com/v2/templates")
.query(&[("page", "1"), ("per_page", "25")])
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class ListTemplates {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates?page=1&per_page=25"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Threading.Tasks;
public class ListTemplates
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var response = await client.GetAsync(
"https://api.emailit.com/v2/templates?page=1&per_page=25");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X GET "https://api.emailit.com/v2/templates?page=1&per_page=25" \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" {
"data": [
{
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": ["supporto@azienda.com"],
"editor": "html",
"published_at": "2025-12-24T10:30:00.000000Z",
"preview_url": "https://cdn.azienda.com/anteprime/benvenuto.png",
"total_versions": 3,
"created_at": "2025-12-24T09:00:00.000000Z",
"updated_at": "2025-12-24T10:30:00.000000Z"
}
],
"total_records": 10,
"per_page": 25,
"current_page": 1,
"total_pages": 1
} {
"message": "Non autorizzato"
} Ottieni Template
Recupera un template tramite ID con contenuto completo e tutte le altre versioni (template con lo stesso alias).
/templates/:idParametri del Percorso
idstringRequiredID del template (es. tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).
const response = await fetch('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT', {
method: 'GET',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.get(
'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.get("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class GetTemplate {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Threading.Tasks;
public class GetTemplate
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var response = await client.GetAsync(
"https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X GET "https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT" \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" {
"data": {
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Email di Benvenuto v1",
"alias": "welcome-email",
"from": "Supporto <support@company.com>",
"subject": "Benvenuto!",
"reply_to": ["support@company.com"],
"html": "<h1>Benvenuto!</h1>",
"text": "Benvenuto!",
"editor": "html",
"published_at": "2025-12-24T10:30:00.000000Z",
"preview_url": "https://cdn.company.com/previews/welcome.png",
"created_at": "2025-12-24T09:00:00.000000Z",
"updated_at": "2025-12-24T10:30:00.000000Z",
"versions": [
{
"id": "tem_anotherOidHere123456789",
"name": "Email di Benvenuto v2",
"published_at": null,
"created_at": "2025-12-24T11:00:00.000000Z",
"updated_at": "2025-12-24T11:00:00.000000Z"
}
]
}
} {
"message": "Template non trovato"
} Concetti Chiave
Raggruppamento per Alias
I template con lo stesso alias sono versioni dello stesso template. Quando recuperi un template tramite ID, l’array versions include tutti gli altri template che condividono lo stesso alias.
Pubblicazione
Solo un template per alias può essere pubblicato alla volta. Il template pubblicato ha un timestamp published_at non nullo. I template in bozza hanno published_at impostato su null.
Crea Template
Crea un nuovo template tramite l’API di Emailit. I template vengono pubblicati automaticamente se l’alias non esiste ancora; altrimenti, rimangono come bozze.
/templatesCorpo della Richiesta
namestringRequiredNome del template. Massimo 191 caratteri.
aliasstringRequiredAlias del template per raggruppare le versioni. Deve contenere solo lettere minuscole (a-z), numeri (0-9), underscore (_) e trattini (-). Pattern: ^[a-z0-9_-]+$. Massimo 191 caratteri.
fromstringIndirizzo email mittente in formato RFC (es. Nome <email@dominio.com>). Massimo 191 caratteri.
subjectstringOggetto dell’email. Massimo 191 caratteri.
reply_tostring | string[]Singolo indirizzo email o array di indirizzi email per la risposta.
htmlstringContenuto HTML per il template email.
textstringContenuto in testo semplice per il template email.
editorstringTipo di editor: html (predefinito), tiptap, o dragit.
const response = await fetch('https://api.emailit.com/v2/templates', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Email di Benvenuto',
alias: 'email-benvenuto',
from: 'Supporto <supporto@azienda.com>',
subject: 'Benvenuto nel nostro servizio!',
reply_to: ['supporto@azienda.com'],
html: '<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>',
text: 'Benvenuto! Grazie per esserti unito a noi.',
editor: 'html'
})
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Email di Benvenuto',
'alias' => 'email-benvenuto',
'from' => 'Supporto <supporto@azienda.com>',
'subject' => 'Benvenuto nel nostro servizio!',
'reply_to' => ['supporto@azienda.com'],
'html' => '<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>',
'text' => 'Benvenuto! Grazie per esserti unito a noi.',
'editor' => 'html'
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.post(
'https://api.emailit.com/v2/templates',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
json={
'name': 'Email di Benvenuto',
'alias': 'email-benvenuto',
'from': 'Supporto <supporto@azienda.com>',
'subject': 'Benvenuto nel nostro servizio!',
'reply_to': ['supporto@azienda.com'],
'html': '<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>',
'text': 'Benvenuto! Grazie per esserti unito a noi.',
'editor': 'html'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Email di Benvenuto',
alias: 'email-benvenuto',
from: 'Supporto <supporto@azienda.com>',
subject: 'Benvenuto nel nostro servizio!',
reply_to: ['supporto@azienda.com'],
html: '<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>',
text: 'Benvenuto! Grazie per esserti unito a noi.',
editor: 'html'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/templates"
data := map[string]interface{}{
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": []string{"supporto@azienda.com"},
"html": "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
"text": "Benvenuto! Grazie per esserti unito a noi.",
"editor": "html",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://api.emailit.com/v2/templates")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.json(&json!({
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": ["supporto@azienda.com"],
"html": "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
"text": "Benvenuto! Grazie per esserti unito a noi.",
"editor": "html"
}))
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
public class CreateTemplate {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": ["supporto@azienda.com"],
"html": "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
"text": "Benvenuto! Grazie per esserti unito a noi.",
"editor": "html"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class CreateTemplate
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var data = new {
name = "Email di Benvenuto",
alias = "email-benvenuto",
from = "Supporto <supporto@azienda.com>",
subject = "Benvenuto nel nostro servizio!",
reply_to = new[] { "supporto@azienda.com" },
html = "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
text = "Benvenuto! Grazie per esserti unito a noi.",
editor = "html"
};
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.emailit.com/v2/templates", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X POST https://api.emailit.com/v2/templates \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": ["supporto@azienda.com"],
"html": "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
"text": "Benvenuto! Grazie per esserti unito a noi.",
"editor": "html"
}' {
"data": {
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Email di Benvenuto",
"alias": "email-benvenuto",
"from": "Supporto <supporto@azienda.com>",
"subject": "Benvenuto nel nostro servizio!",
"reply_to": ["supporto@azienda.com"],
"html": "<h1>Benvenuto!</h1><p>Grazie per esserti unito a noi.</p>",
"text": "Benvenuto! Grazie per esserti unito a noi.",
"editor": "html",
"published_at": "2025-12-24T10:30:00.000000Z",
"preview_url": null,
"created_at": "2025-12-24T10:30:00.000000Z",
"updated_at": "2025-12-24T10:30:00.000000Z"
},
"message": "Template creato con successo."
} {
"message": "Validazione fallita",
"errors": {
"name": ["Il nome è obbligatorio"],
"alias": ["L'alias deve contenere solo lettere minuscole (a-z), numeri (0-9), underscore (_) e trattini (-)"]
}
} Comportamento di Auto-Pubblicazione
- Nuovo alias: Quando crei un template con un alias che non esiste ancora, il template viene pubblicato automaticamente (
published_atviene impostato). - Alias esistente: Quando crei un template con un alias che ha già dei template, il nuovo template viene salvato come bozza (
published_atènull). Puoi pubblicarlo successivamente utilizzando l’endpoint Pubblica Template.
Regole di Validazione
| Campo | Regole |
|---|---|
name | Obbligatorio, massimo 191 caratteri |
alias | Obbligatorio, massimo 191 caratteri, pattern: ^[a-z0-9_-]+$ |
from | Opzionale, massimo 191 caratteri |
subject | Opzionale, massimo 191 caratteri |
reply_to | Opzionale, deve essere email valida/e |
editor | Opzionale, deve essere html, tiptap, o dragit |
Aggiorna Template
Aggiorna un template esistente tramite l’API di Emailit. Tutti i campi sono opzionali. Questo endpoint non modifica lo stato published_at.
/templates/:idParametri del Percorso
idstringRequiredID del template (es. tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).
Corpo della Richiesta (tutti opzionali)
namestringNome del template. Massimo 191 caratteri.
aliasstringAlias del template. Deve essere univoco se modificato. Deve contenere solo lettere minuscole (a-z), numeri (0-9), underscore (_) e trattini (-). Massimo 191 caratteri.
fromstringIndirizzo email del mittente in formato RFC. Massimo 191 caratteri.
subjectstringOggetto dell’email. Massimo 191 caratteri.
reply_tostring | string[]Indirizzo/i email per la risposta.
htmlstringContenuto HTML per il template email.
textstringContenuto in testo semplice per il template email.
editorstringTipo di editor: html, tiptap, o dragit.
const response = await fetch('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Email di Benvenuto - Aggiornata',
subject: 'Benvenuto! Siamo felici che tu sia qui'
})
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Email di Benvenuto - Aggiornata',
'subject' => 'Benvenuto! Siamo felici che tu sia qui'
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.post(
'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
json={
'name': 'Email di Benvenuto - Aggiornata',
'subject': 'Benvenuto! Siamo felici che tu sia qui'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
request.body = {
name: 'Email di Benvenuto - Aggiornata',
subject: 'Benvenuto! Siamo felici che tu sia qui'
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"
data := map[string]interface{}{
"name": "Email di Benvenuto - Aggiornata",
"subject": "Benvenuto! Siamo felici che tu sia qui",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.json(&json!({
"name": "Email di Benvenuto - Aggiornata",
"subject": "Benvenuto! Siamo felici che tu sia qui"
}))
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
public class UpdateTemplate {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"name": "Email di Benvenuto - Aggiornata",
"subject": "Benvenuto! Siamo felici che tu sia qui"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class UpdateTemplate
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var data = new {
name = "Email di Benvenuto - Aggiornata",
subject = "Benvenuto! Siamo felici che tu sia qui"
};
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X POST https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"name": "Email di Benvenuto - Aggiornata",
"subject": "Benvenuto! Siamo felici che tu sia qui"
}' {
"data": {
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Email di Benvenuto - Aggiornata",
"alias": "welcome-email",
"from": "Supporto <support@company.com>",
"subject": "Benvenuto! Siamo felici che tu sia qui",
"reply_to": ["support@company.com"],
"html": "<h1>Benvenuto!</h1>",
"text": "Benvenuto!",
"editor": "html",
"published_at": "2025-12-24T10:30:00.000000Z",
"preview_url": null,
"created_at": "2025-12-24T10:30:00.000000Z",
"updated_at": "2025-12-24T12:00:00.000000Z"
},
"message": "Il template è stato aggiornato con successo."
} {
"message": "Validazione fallita",
"errors": {
"alias": ["L'alias esiste già"]
}
} {
"message": "Template non trovato"
} Note Importanti
- L’aggiornamento di un template non modifica il suo stato
published_at. Un template pubblicato rimane pubblicato, e una bozza rimane una bozza. - Se modifichi l’
aliascon uno che esiste già, riceverai un errore di validazione. - Per pubblicare un template in bozza, utilizza l’endpoint Pubblica Template.
Elimina Template
Elimina un template dal tuo account Emailit.
/templates/:idParametri del Percorso
idstringRequiredID del template (es. tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).
const response = await fetch('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.delete(
'https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.delete("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class DeleteTemplate {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.DELETE()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Threading.Tasks;
public class DeleteTemplate
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var response = await client.DeleteAsync(
"https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X DELETE "https://api.emailit.com/v2/templates/tem_47TaFwzJx6mD7NeJYvLjFxVwbgT" \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" {
"data": null,
"message": "Template eliminato con successo."
} {
"message": "Template non trovato"
} Note Importanti
- Eliminazione di un template pubblicato: Se elimini il template pubblicato per un alias, nessun template sarà pubblicato per quell’alias finché non pubblicherai un’altra versione utilizzando l’endpoint Pubblica Template.
- Eliminazione di una bozza: L’eliminazione di un template in bozza non ha alcun effetto sul template attualmente pubblicato per quell’alias.
- Questa azione è irreversibile. Il template e il suo contenuto verranno eliminati definitivamente.
Pubblicazione Template
Pubblica un template e annulla automaticamente la pubblicazione di tutti gli altri template con lo stesso alias. Solo un template per alias può essere pubblicato alla volta.
/templates/:id/publishParametri del Percorso
idstringRequiredID del Template (es. tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).
Corpo della Richiesta
Corpo vuoto (nessun parametro richiesto).
const response = await fetch('https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
});
const result = await response.json(); <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Errore cURL #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
} import requests
response = requests.post(
'https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
}
)
result = response.json()
print(result) require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
response = http.request(request)
result = JSON.parse(response.body)
puts result package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
} use reqwest;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
} import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
public class PublishTemplate {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.POST(BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
} using System;
using System.Net.Http;
using System.Threading.Tasks;
public class PublishTemplate
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var response = await client.PostAsync(
"https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish",
null);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
} curl -X POST "https://api.emailit.com/v2/templates/tem_anotherOidHere123456789/publish" \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" {
"data": {
"id": "tem_anotherOidHere123456789",
"name": "Email di Benvenuto v2",
"alias": "welcome-email",
"from": "Supporto <support@company.com>",
"subject": "Benvenuto! Versione aggiornata",
"reply_to": ["support@company.com"],
"html": "<h1>Benvenuto v2!</h1>",
"text": "Benvenuto v2!",
"editor": "html",
"published_at": "2025-12-24T13:00:00.000000Z",
"preview_url": null,
"created_at": "2025-12-24T11:00:00.000000Z",
"updated_at": "2025-12-24T13:00:00.000000Z"
},
"message": "Il template è stato pubblicato con successo."
} {
"message": "Template non trovato"
} Come Funziona la Pubblicazione
Quando pubblichi un template:
- Il template di destinazione riceve il timestamp
published_atimpostato all’ora corrente. - Tutti gli altri template con lo stesso alias hanno il loro
published_atimpostato anull(non pubblicati).
Questo garantisce che solo un template per alias sia mai pubblicato, rendendo semplice la gestione delle versioni dei template e il passaggio tra di esse.
Casi d’Uso
- Test A/B: Crea più versioni di un template e pubblica versioni diverse per testare le prestazioni.
- Rollback: Torna rapidamente a una versione precedente pubblicando un template più vecchio.
- Ambiente di Test: Crea nuove versioni come bozze, testale e pubblicale quando sono pronte.