Use the Lumail SDK resource clients for subscribers, campaigns, transactional emails, tags, and events.
The SDK groups API operations by resource. Each resource client maps to common Lumail workflows.
Create or update a subscriber and optionally trigger matching workflows.
const { subscriber } = await lumail.subscribers.create({
email: "[email protected]",
name: "Jane Doe",
tags: ["newsletter", "customer"],
fields: { plan: "pro" },
triggerWorkflows: true,
});
Update subscriber fields or replace tags later:
await lumail.subscribers.update("[email protected]", {
fields: { plan: "enterprise"
Create campaigns, fetch details, update drafts, and send immediately or on a schedule.
const { campaignId } = await lumail.campaigns.create({
subject: "Welcome to the newsletter",
name: "Welcome Campaign",
preview: "Here is what to expect.",
contentType: "MARKDOWN",
});
await lumail.campaigns.send(campaignId, {
scheduledAt: "2026-06-01T09:00:00Z",
timezone: "Europe/Paris",
});Send transactional email from a verified domain.
await lumail.emails.send({
to: "[email protected]",
from: "[email protected]",
subject: "Your receipt",
content: "Thanks for your purchase.",
contentType: "MARKDOWN",
transactional: true,
});To send a React Email template, render it to HTML and pass contentType: "HTML" - see Send React Email Templates with Lumail.
Validate an address before storing or sending to it.
const result = await lumail.emails.verify({ email: "[email protected]" });
if (!result.success) {
console.log(result.code, result.error, result.suggestion);
}List, create, fetch, and rename tags.
const { tags } = await lumail.tags.list();
const { tag } = await lumail.tags.create({ name: "vip" });
await lumail.tags.update(tag.id, { name: "customer" });Track product activity and business events on a subscriber profile.
await lumail.events.create({
eventType: "SUBSCRIBER_PAYMENT",
subscriber: "[email protected]",
data: {
amount: 99,
currency: "USD",
plan: "pro",
},
});