Quickstart: envía tu primer correo
Un paso a paso completo para enviar tu primer correo con Publiq, entender la respuesta y evolucionar a plantillas y seguimiento.
Esta guía asume que ya hiciste la Instalación y configuraste PUBLIQ_API_KEY. En pocos minutos envías un correo, entiendes la respuesta y empiezas a usar plantillas.
Paso 1 — Envía un correo
import { Publiq } from 'publiq';
const publiq = new Publiq(process.env.PUBLIQ_API_KEY);
const email = await publiq.emails.send({
from: 'you@yourdomain.com',
to: 'user@example.com',
subject: 'Hello from Publiq',
html: '<h1>It works!</h1><p>Your first email is on its way.</p>',
});
console.log(email.id); // msg_...from publiq import Publiq
publiq = Publiq() # reads PUBLIQ_API_KEY
email = publiq.emails.send({
"from": "you@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from Publiq",
"html": "<h1>It works!</h1><p>Your first email is on its way.</p>",
})
print(email["id"]) # msg_...curl -X POST https://api.publiq.digital/v1/emails \
-H "Authorization: Bearer $PUBLIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "you@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from Publiq",
"html": "<h1>It works!</h1>"
}'El from debe estar en un dominio verificado. Si aún no verificaste, hazlo primero — ver Dominios y verificación.
Paso 2 — Entiende la respuesta
El envío es asíncrono: la API acepta y encola el correo, devolviendo el id y el estado inicial queued. El estado evoluciona (sent → delivered → opened…) y lo sigues por Webhooks o en el panel.
{
"id": "msg_01J9Z...",
"status": "queued",
"external_id": null
}Paso 3 — Usa una plantilla
En vez de HTML inline, crea una plantilla en el builder con IA y referénciala por templateKey. Las variables rellenan los {{ }} al enviar:
await publiq.emails.send({
from: 'you@yourdomain.com',
to: 'user@example.com',
templateKey: 'welcome-email',
variables: { first_name: 'Ana' }, // -> {{ first_name }}
});Próximos pasos
- Integra con tu framework: Next.js, NestJS, Express, Node.js o Python
- Entiende Cómo funciona el pipeline de envío
- Configura Dominios para máxima entregabilidad
- Automatiza con Eventos y Automatizaciones