Listar Plantillas

Obtén una lista de todas las plantillas publicadas en tu cuenta de Emailit. Solo se devuelven las plantillas que tienen published_at configurado. El contenido (html/texto) se excluye de la vista de lista.

GET/templates

Parámetros de Consulta

per_pageinteger

Elementos por página (1-100). Por defecto: 25.

pageinteger

Número de página (mínimo: 1). Por defecto: 1.

filter[name]string

Filtrar por nombre (coincidencia parcial).

filter[alias]string

Filtrar por alias (coincidencia exacta).

filter[editor]string

Filtrar por tipo de editor: html, tiptap, o dragit.

sortstring

Campo de ordenación: name, alias, created_at, updated_at, o published_at. Por defecto: created_at.

orderstring

Orden de clasificación: asc o desc. Por defecto: 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 "Error de 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 de Bienvenida",
  "alias": "email-bienvenida",
  "from": "Soporte <soporte@empresa.com>",
  "subject": "¡Bienvenido a nuestro servicio!",
  "reply_to": ["soporte@empresa.com"],
  "editor": "html",
  "published_at": "2025-12-24T10:30:00.000000Z",
  "preview_url": "https://cdn.empresa.com/previews/bienvenida.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": "No autorizado"
}

Obtener Plantilla

Recupera una plantilla por ID con todo el contenido y todas las demás versiones (plantillas con el mismo alias).

GET/templates/:id

Parámetros de Ruta

idstringRequired

ID de la plantilla (ej., 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 "Error 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 ObtenerPlantilla {
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 ObtenerPlantilla
{
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 de Bienvenida v1",
"alias": "welcome-email",
"from": "Soporte <support@company.com>",
"subject": "¡Bienvenido!",
"reply_to": ["support@company.com"],
"html": "<h1>¡Bienvenido!</h1>",
"text": "¡Bienvenido!",
"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 de Bienvenida v2",
    "published_at": null,
    "created_at": "2025-12-24T11:00:00.000000Z",
    "updated_at": "2025-12-24T11:00:00.000000Z"
  }
]
}
}
{
"message": "Plantilla no encontrada"
}

Conceptos Clave

Agrupación por Alias

Las plantillas con el mismo alias son versiones de la misma plantilla. Cuando consultas una plantilla por ID, el array versions incluye todas las demás plantillas que comparten el mismo alias.

Publicación

Solo una plantilla por alias puede estar publicada al mismo tiempo. La plantilla publicada tiene una marca de tiempo published_at no nula. Los borradores tienen published_at establecido en null.

Crear Plantilla

Crea una nueva plantilla a través de la API de Emailit. Las plantillas se publican automáticamente si el alias no existe aún; de lo contrario, permanecen como borradores.

POST/templates

Cuerpo de la Solicitud

namestringRequired

Nombre de la plantilla. Máximo 191 caracteres.

aliasstringRequired

Alias de la plantilla para agrupar versiones. Debe contener únicamente letras minúsculas (a-z), números (0-9), guiones bajos (_) y guiones (-). Patrón: ^[a-z0-9_-]+$. Máximo 191 caracteres.

fromstring

Dirección de correo del remitente en formato RFC (ej., Nombre <email@dominio.com>). Máximo 191 caracteres.

subjectstring

Asunto del correo electrónico. Máximo 191 caracteres.

reply_tostring | string[]

Un solo correo o arreglo de direcciones de correo para responder.

htmlstring

Contenido HTML para la plantilla de correo.

textstring

Contenido de texto plano para la plantilla de correo.

editorstring

Tipo de editor: html (predeterminado), 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: 'Correo de Bienvenida',
alias: 'correo-bienvenida',
from: 'Soporte <soporte@empresa.com>',
subject: '¡Bienvenido a nuestro servicio!',
reply_to: ['soporte@empresa.com'],
html: '<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>',
text: '¡Bienvenido! Gracias por unirte a nosotros.',
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' => 'Correo de Bienvenida',
'alias' => 'correo-bienvenida',
'from' => 'Soporte <soporte@empresa.com>',
'subject' => '¡Bienvenido a nuestro servicio!',
'reply_to' => ['soporte@empresa.com'],
'html' => '<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>',
'text' => '¡Bienvenido! Gracias por unirte a nosotros.',
'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 "Error 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': 'Correo de Bienvenida',
    'alias': 'correo-bienvenida',
    'from': 'Soporte <soporte@empresa.com>',
    'subject': '¡Bienvenido a nuestro servicio!',
    'reply_to': ['soporte@empresa.com'],
    'html': '<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>',
    'text': '¡Bienvenido! Gracias por unirte a nosotros.',
    '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: 'Correo de Bienvenida',
alias: 'correo-bienvenida',
from: 'Soporte <soporte@empresa.com>',
subject: '¡Bienvenido a nuestro servicio!',
reply_to: ['soporte@empresa.com'],
html: '<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>',
text: '¡Bienvenido! Gracias por unirte a nosotros.',
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": "Correo de Bienvenida",
    "alias": "correo-bienvenida",
    "from": "Soporte <soporte@empresa.com>",
    "subject": "¡Bienvenido a nuestro servicio!",
    "reply_to": []string{"soporte@empresa.com"},
    "html": "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
    "text": "¡Bienvenido! Gracias por unirte a nosotros.",
    "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": "Correo de Bienvenida",
        "alias": "correo-bienvenida",
        "from": "Soporte <soporte@empresa.com>",
        "subject": "¡Bienvenido a nuestro servicio!",
        "reply_to": ["soporte@empresa.com"],
        "html": "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
        "text": "¡Bienvenido! Gracias por unirte a nosotros.",
        "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": "Correo de Bienvenida",
            "alias": "correo-bienvenida",
            "from": "Soporte <soporte@empresa.com>",
            "subject": "¡Bienvenido a nuestro servicio!",
            "reply_to": ["soporte@empresa.com"],
            "html": "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
            "text": "¡Bienvenido! Gracias por unirte a nosotros.",
            "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 = "Correo de Bienvenida",
            alias = "correo-bienvenida",
            from = "Soporte <soporte@empresa.com>",
            subject = "¡Bienvenido a nuestro servicio!",
            reply_to = new[] { "soporte@empresa.com" },
            html = "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
            text = "¡Bienvenido! Gracias por unirte a nosotros.",
            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": "Correo de Bienvenida",
"alias": "correo-bienvenida",
"from": "Soporte <soporte@empresa.com>",
"subject": "¡Bienvenido a nuestro servicio!",
"reply_to": ["soporte@empresa.com"],
"html": "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
"text": "¡Bienvenido! Gracias por unirte a nosotros.",
"editor": "html"
}'
{
"data": {
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Correo de Bienvenida",
"alias": "correo-bienvenida",
"from": "Soporte <soporte@empresa.com>",
"subject": "¡Bienvenido a nuestro servicio!",
"reply_to": ["soporte@empresa.com"],
"html": "<h1>¡Bienvenido!</h1><p>Gracias por unirte a nosotros.</p>",
"text": "¡Bienvenido! Gracias por unirte a nosotros.",
"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": "La plantilla se creó exitosamente."
}
{
"message": "Error de validación",
"errors": {
"name": ["El nombre es obligatorio"],
"alias": ["El alias debe contener únicamente letras minúsculas (a-z), números (0-9), guiones bajos (_) y guiones (-)"]
}
}

Comportamiento de Publicación Automática

  • Alias nuevo: Cuando creas una plantilla con un alias que no existe aún, la plantilla se publica automáticamente (published_at se establece).
  • Alias existente: Cuando creas una plantilla con un alias que ya tiene plantillas, la nueva plantilla se guarda como borrador (published_at es null). Puedes publicarla más tarde usando el endpoint Publicar Plantilla.

Reglas de Validación

CampoReglas
nameObligatorio, máx. 191 caracteres
aliasObligatorio, máx. 191 caracteres, patrón: ^[a-z0-9_-]+$
fromOpcional, máx. 191 caracteres
subjectOpcional, máx. 191 caracteres
reply_toOpcional, debe ser correo(s) válido(s)
editorOpcional, debe ser html, tiptap, o dragit

Actualizar Plantilla

Actualiza una plantilla existente a través de la API de Emailit. Todos los campos son opcionales. Este endpoint no modifica el estado de published_at.

POST/templates/:id

Parámetros de Ruta

idstringRequired

ID de la plantilla (ej., tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).

Cuerpo de la Solicitud (todos opcionales)

namestring

Nombre de la plantilla. Máximo 191 caracteres.

aliasstring

Alias de la plantilla. Debe ser único si se modifica. Solo puede contener letras minúsculas (a-z), números (0-9), guiones bajos (_) y guiones (-). Máximo 191 caracteres.

fromstring

Dirección de correo del remitente en formato RFC. Máximo 191 caracteres.

subjectstring

Asunto del correo electrónico. Máximo 191 caracteres.

reply_tostring | string[]

Dirección(es) de correo para responder.

htmlstring

Contenido HTML para la plantilla de correo.

textstring

Contenido de texto plano para la plantilla de correo.

editorstring

Tipo de 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 de Bienvenida - Actualizado',
subject: '¡Bienvenido! Nos alegra tenerte aquí'
})
});

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 de Bienvenida - Actualizado',
'subject' => '¡Bienvenido! Nos alegra tenerte aquí'
]),
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 "Error 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 de Bienvenida - Actualizado',
    'subject': '¡Bienvenido! Nos alegra tenerte aquí'
}
)

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 de Bienvenida - Actualizado',
subject: '¡Bienvenido! Nos alegra tenerte aquí'
}.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 de Bienvenida - Actualizado",
    "subject": "¡Bienvenido! Nos alegra tenerte aquí",
}

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 de Bienvenida - Actualizado",
        "subject": "¡Bienvenido! Nos alegra tenerte aquí"
    }))
    .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 de Bienvenida - Actualizado",
            "subject": "¡Bienvenido! Nos alegra tenerte aquí"
        }
        """;
    
    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 de Bienvenida - Actualizado",
            subject = "¡Bienvenido! Nos alegra tenerte aquí"
        };
        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 de Bienvenida - Actualizado",
"subject": "¡Bienvenido! Nos alegra tenerte aquí"
}'
{
"data": {
"id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT",
"name": "Email de Bienvenida - Actualizado",
"alias": "welcome-email",
"from": "Soporte <support@company.com>",
"subject": "¡Bienvenido! Nos alegra tenerte aquí",
"reply_to": ["support@company.com"],
"html": "<h1>¡Bienvenido!</h1>",
"text": "¡Bienvenido!",
"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": "La plantilla se actualizó correctamente."
}
{
"message": "Error de validación",
"errors": {
"alias": ["El alias ya existe"]
}
}
{
"message": "Plantilla no encontrada"
}

Notas Importantes

  • Actualizar una plantilla no modifica su estado de published_at. Una plantilla publicada permanece publicada, y un borrador permanece como borrador.
  • Si cambias el alias por uno que ya existe, recibirás un error de validación.
  • Para publicar una plantilla en borrador, utiliza el endpoint Publicar Plantilla.

Eliminar Plantilla

Elimina una plantilla de tu cuenta de Emailit.

DELETE/templates/:id

Parámetros de Ruta

idstringRequired

ID de la plantilla (ej., 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 "Error 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": "La plantilla se eliminó correctamente."
}
{
"message": "Plantilla no encontrada"
}

Consideraciones Importantes

  • Eliminar una plantilla publicada: Si eliminas la plantilla publicada para un alias, no habrá ninguna plantilla publicada para ese alias hasta que publiques otra versión usando el endpoint Publicar Plantilla.
  • Eliminar un borrador: Eliminar una plantilla en borrador no afecta la plantilla actualmente publicada para ese alias.
  • Esta acción es irreversible. La plantilla y su contenido se eliminarán permanentemente.

Publicar Plantilla

Publica una plantilla y despublica automáticamente todas las demás plantillas con el mismo alias. Solo una plantilla por alias puede estar publicada a la vez.

POST/templates/:id/publish

Parámetros de Ruta

idstringRequired

ID de la plantilla (ej., tem_47TaFwzJx6mD7NeJYvLjFxVwbgT).

Cuerpo de la Solicitud

Cuerpo vacío (no se requieren parámetros).

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 "Error 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 de Bienvenida v2",
"alias": "welcome-email",
"from": "Soporte <support@company.com>",
"subject": "¡Bienvenido! Versión actualizada",
"reply_to": ["support@company.com"],
"html": "<h1>¡Bienvenido v2!</h1>",
"text": "¡Bienvenido 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": "La plantilla se publicó correctamente."
}
{
"message": "Plantilla no encontrada"
}

Cómo Funciona la Publicación

Cuando publicas una plantilla:

  1. La plantilla objetivo recibe su marca de tiempo published_at establecida al momento actual.
  2. Todas las demás plantillas con el mismo alias tienen su published_at establecido en null (despublicadas).

Esto garantiza que solo una plantilla por alias esté publicada en cualquier momento, facilitando la gestión de versiones de plantillas y el cambio entre ellas.

Casos de Uso

  • Pruebas A/B: Crea múltiples versiones de una plantilla y publica diferentes versiones para probar el rendimiento.
  • Reversión: Revierte rápidamente a una versión anterior publicando una plantilla más antigua.
  • Entorno de Pruebas: Crea nuevas versiones como borradores, pruébalas y publícalas cuando estén listas.
Localizado por IA