Use this file to discover all available pages before exploring further.
The official lettr package is a type-safe API client for Node.js and TypeScript. It covers sending, templates, domains, webhooks, audience, and campaigns — with no thrown exceptions: every method returns a Result you destructure into data and error.
Every SDK method returns a Result<T> — a discriminated union of { data, error }. The SDK never throws for API or network failures; you check error instead:
const { data, error } = await client.emails.send({ from: "you@yourdomain.com", to: ["recipient@example.com"], subject: "Hello", html: "<p>Hi there</p>",});if (error) { // error.type is "validation" | "api" | "network" console.error(error.type, error.message); return;}console.log(data.request_id); // narrowed to non-null here
Because data and error are discriminated, TypeScript narrows data to non-null only after you’ve handled error. See Sending Emails → Error Handling for the full error model.