> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendbaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> The official TypeScript SDK for Node.js and edge runtimes, and how to call the API from everything else.

The API is plain JSON over HTTPS, so any language works; the [sending examples](https://docs.sendbaze.com/get-started/send-with/curl.md) show Python, Ruby, PHP and Go. The official SDK adds types, typed errors and idempotency helpers.

## TypeScript / Node.js

`@sendbaze/sdk` is a zero-dependency client built on `fetch`. It runs on Node.js 20+, Bun, Deno, Cloudflare Workers and Vercel Edge, and ships ESM and CommonJS builds with type definitions.

```bash npm theme={"dark"}
npm install @sendbaze/sdk
```

```bash pnpm theme={"dark"}
pnpm add @sendbaze/sdk
```

```ts theme={"dark"}
import { Sendbaze } from "@sendbaze/sdk";

const sendbaze = new Sendbaze({ apiKey: process.env.SENDBAZE_API_KEY! });
```

### Options

| Option | Default | Purpose |
| - | - | - |
| `apiKey` | required | A live or test key |
| `baseUrl` | `https://api.sendbaze.com` | Point at a mock server in tests |
| `timeoutMs` | `30000` | Request timeout |
| `fetch` | global `fetch` | Custom implementation for older runtimes or tests |

### Resources

| Resource | Methods |
| - | - |
| `emails` | `send`, `batch`, `get`, `list` |
| `templates` | `create`, `list`, `get`, `update`, `delete`, `render`, `versions` |
| `domains` | `create`, `list`, `get`, `verify`, `delete` |
| `suppressions` | `list`, `add`, `remove` |
| `webhooks` | `create`, `list`, `get`, `update`, `delete`, `test`, `deliveries`, `replay` |
| `sms` | `send`, `batch`, `get` |
| `usage` | `get` |

Every method takes an optional last argument `{ idempotencyKey, signal }`.

### Errors

```ts theme={"dark"}
import { SendbazeError, SendbazeConnectionError } from "@sendbaze/sdk";

try {
  await sendbaze.emails.send(email, { idempotencyKey: "order-1042" });
} catch (error) {
  if (error instanceof SendbazeError) {
    error.status;    // 422
    error.code;      // "validation_error" — stable, see the errors reference
    error.fields;    // { "to.1": ["must be a valid email address"] }
    error.requestId; // quote it to support
  } else if (error instanceof SendbazeConnectionError) {
    // timeout or network failure: safe to retry with the same idempotency key
  }
}
```

### Webhooks

```ts theme={"dark"}
import { verifyWebhookSignature, SENDBAZE_SIGNATURE_HEADER, SENDBAZE_EVENT_ID_HEADER } from "@sendbaze/sdk";
```

See [verify the signature](https://docs.sendbaze.com/learn/webhooks/verify-signature.md).

### React Email

Pass a React element as `react` and the SDK renders it to `html` and `text` before sending. The renderer is an optional peer dependency: `npm install @react-email/render react react-dom`. `renderReactEmail` exposes the same rendering for previews and tests. See [React Email](https://docs.sendbaze.com/learn/sending/react-email.md).

```tsx theme={"dark"}
await sendbaze.emails.send({
  from: "orders@yourshop.co.za",
  to: "thandi@example.com",
  subject: "Your order has shipped",
  react: <OrderShipped name="Thandi" tracking="CG123456789ZA" />,
});
```

## Python

`sendbaze` on PyPI needs Python 3.9+ and nothing but the standard library. The same resources and method names as the TypeScript SDK, in snake\_case; `from_` and `class_` stand in for the reserved words.

```bash theme={"dark"}
pip install sendbaze
```

```python theme={"dark"}
from sendbaze import Sendbaze, SendbazeError, verify_webhook_signature

sendbaze = Sendbaze()  # reads SENDBAZE_API_KEY, or pass api_key="sk_live_..."

try:
    email = sendbaze.emails.send(
        from_="orders@yourshop.co.za",
        to="thandi@example.com",
        subject="Hi",
        text="Hello",
        idempotency_key="order-1042-shipped",
    )
    print(email.id)
except SendbazeError as error:
    print(error.status, error.code, error.fields, error.request_id)
```

Every method returns a dict with attribute access (`email.id` or `email["id"]`). Options: `api_key`, `base_url`, `timeout` (seconds, default 30). See the [Python guide](https://docs.sendbaze.com/get-started/send-with/python.md).

## Other languages

Ruby, PHP and Go packages are on the roadmap. Until then the API reference shows a request sample in each language on every endpoint, and the sending guides include a small client you can copy:

> [card] [Ruby](https://docs.sendbaze.com/get-started/send-with/ruby.md)

> [card] [PHP](https://docs.sendbaze.com/get-started/send-with/php.md)

> [card] [Go](https://docs.sendbaze.com/get-started/send-with/go.md)

## OpenAPI

The full specification is at [`/api-reference/openapi.yaml`](https://docs.sendbaze.com/api-reference/openapi.yaml). Generate a client with your usual tooling, or import it into Postman or Insomnia.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.