Skip to content

Email

Send direct email when your server already owns the rendered subject and body. Use a message definition when non-developers should change the content without a deploy.

const response = await fabric.email.send(
{
to: "ama@example.com",
from: "receipts@your-domain.example",
replyTo: "support@your-domain.example",
subject: "Receipt for order GH-4821",
text: "Thanks Ama. Your payment was received.",
html: "<p>Thanks Ama. Your payment was received.</p>",
},
{ idempotencyKey: "receipt:GH-4821" },
);
console.log(response.data.id, response.data.status);

At least one of text or html is required. Supplying both gives clients a safe plain-text fallback and improves deliverability. An idempotency key is optional but recommended so a retry does not send twice.

const message = await fabric.email.retrieve(response.data.id);
console.log(message.data.status, message.data.errorCode);
const page = await fabric.email.list({ limit: 50 });
console.log(page.data.items.length, page.data.nextCursor);
for await (const recent of fabric.email.iterate()) {
console.log(recent.id, recent.status);
}

retrieve returns the EmailMessage — status, from, subject, provider, and a nullable errorCode. list is cursor-paginated (limit 1–100, default 50): each page carries items and an opaque nextCursor (null on the last page). iterate follows the cursor for you.