Quickstart: send your first email
A complete walkthrough to send your first email with Publiq, understand the response and evolve to templates and tracking.
This guide assumes you already did the Installation and set PUBLIQ_API_KEY. In a few minutes you send an email, understand the response and start using templates.
Step 1 — Send an email
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>"
}'The from must be on a verified domain. If you have not verified yet, do it first — see Domains and verification.
Step 2 — Understand the response
Sending is asynchronous: the API accepts and queues the email, returning the id and the initial queued status. The status evolves (sent → delivered → opened…) and you follow it via Webhooks or in the dashboard.
{
"id": "msg_01J9Z...",
"status": "queued",
"external_id": null
}Step 3 — Use a template
Instead of inline HTML, create a template in the AI builder and reference it by templateKey. The variables fill the {{ }} at send time:
await publiq.emails.send({
from: 'you@yourdomain.com',
to: 'user@example.com',
templateKey: 'welcome-email',
variables: { first_name: 'Ana' }, // -> {{ first_name }}
});Next steps
- Integrate with your framework: Next.js, NestJS, Express, Node.js or Python
- Understand How it works — the sending pipeline
- Configure Domains for maximum deliverability
- Automate with Events & Automations