Node SDK
Send transactional email, check what happened to it and take its events. Works on Node 18+, Cloudflare Workers, Bun and Deno, with no dependencies.
npm install @torvath/mail
Types are generated from the same OpenAPI description the API uses.
Node 18+, Cloudflare Workers, Bun and Deno.
Nothing else to install or keep up to date.
An idempotency key on every send. Pass your own to tie it to your records.
Listen for events and acknowledge each one when your handler finishes.
Errors carry a code and the fields that caused them.
Send
Make a key under Admin → API in Torvath, then send from any address on a verified domain.
import { Torvath } from "@torvath/mail";
const torvath = new Torvath({ apiKey: process.env.TORVATH_API_KEY! });
const { id } = await torvath.emails.send({
from: { email: "billing@yourcompany.in", name: "Your Company" },
to: "customer@example.com",
subject: "Invoice 1042",
html: "<p>Your invoice is attached.</p>",
tags: ["invoice"],
});Templates
On Business, make templates with {{name}} where a detail goes. A missing variable is refused, so a half-filled email never goes out.
await torvath.emails.send({
from: "billing@acme.in",
to: "a@b.in",
template: "invoice-ready",
variables: { name: "Asha", amount: "₹500" },
});Events
An event is acknowledged only when your handler finishes without throwing. If it throws, the event comes back after 60 seconds.
const listener = torvath.events.listen(
{ types: ["email.bounced", "email.complained"] },
async (event) => {
await markAddressBad(event.recipient, event.reason);
},
);
// later
await listener.stop();| Item | Supported |
|---|---|
| Node.js | 18 and later |
| Cloudflare Workers | Yes |
| Bun | Yes |
| Deno | Yes |
| Dependencies | None |
Not yet. The API is plain JSON over HTTPS, so any language can call it directly.
Make a test key (it starts tv_test_). Everything is checked, nothing is sent, and events arrive straight away.
Each send carries an idempotency key, so a retry never sends twice. Pass your own key to tie it to your records.
Then get an API key and send your first email.