Skip to content
DocumentationAPI reference Build something worth sending.

Developer tools

JavaScript & TypeScript SDK

Install the official Node.js SDK, configure retries and handle structured errors.

Install

bash
npm install @sendpanda/sdk @sendpanda/webhooks

The official packages support Node.js 22+, ESM, CommonJS and TypeScript. Both have no runtime dependencies. Use the SDK only on your server.

Configure the client

ts
import { SendPanda, SendPandaError } from "@sendpanda/sdk";

const panda = new SendPanda(process.env.SENDPANDA_API_KEY!, {
  baseUrl: "https://api.sendpanda.email/v1",
  timeout: 10_000,
  maxRetries: 2,
});

The timeout is in milliseconds, from 1 to 300,000. maxRetries counts additional attempts and is capped at five. Use http://localhost:4000/v1 only for a locally running API.

For CommonJS, use const { SendPanda } = require("@sendpanda/sdk"). In Next.js, call the SDK in a server action or Node.js route handler. For React Email, render your trusted component to HTML first. See the framework guides.

Available resources

The SDK covers emails, domains, webhooks, usage, templates, audiences, contacts, campaigns and incoming mail. Sending/history operations work with a send key. Administration requires a management key and appropriate member permissions.

ts
const email = await panda.emails.get("em_your_email_id");
const usage = await panda.usage.get();
const domains = await panda.domains.list();

Retry safely

GET requests and POST requests with an idempotency key are retried after network failures, HTTP 429 or HTTP 5xx, using bounded exponential jitter. Unkeyed sends and domain/webhook changes are not automatically retried. Redirects are rejected.

A timeout can follow acceptance. Reuse the same key and message for the same business event. Broadcast mutations are not automatically retried after transport failures; inspect the resource first.

Handle errors

ts
try {
  await panda.emails.get("em_your_email_id");
} catch (error) {
  if (error instanceof SendPandaError) {
    console.error(error.code, error.status, error.requestId);
  } else {
    throw error;
  }
}

Network errors use status 0 and code network_error. A malformed successful response raises invalid_response and is not automatically retried. Keep credentials, message bodies and recipient data out of logs. See errors and troubleshooting.

↑↓ to navigate↵ to openesc to close