# A typed client for the bubbl3 API.

The bubbl3 TypeScript SDK is a typed client generated from the same OpenAPI document as the API reference. Every call has a typed method, writes take an idempotency key, safe calls retry after network errors and rate limits, and verifyWebhook checks webhook signatures. It runs on Node 20 or later.

In the API, each number is a `line` object, so the SDK lists your numbers with `lines.list`.

## The client

- The package is `@bubbl3/sdk`. Create a client with your API key: `new Bubbl3({ apiKey })`.
- Every public call has a typed method, grouped by section, such as `messages.create`, `contacts.list`, `lines.list` and `webhooks.create`.
- Writes take `{ idempotencyKey }` as their last argument. Pass your own on every send, named after what you're doing.
- Reads, and writes with an idempotency key, are retried twice after a network error, a `429` or a `5xx`, unless the API asks to wait more than a minute. A `Retry-After` longer than 60 seconds is thrown at once.
- Lists return `{ data, next_cursor }`.

## Errors

A failed call throws a `Bubbl3ApiError` with its status, code, message and request id, with subclasses such as `Bubbl3ValidationError` and `Bubbl3RateLimitError` (with `retryAfterSeconds`). A call that never gets a response throws `Bubbl3ConnectionError`. All of them extend `Bubbl3Error`.

## Webhooks

`verifyWebhook(rawBody, header, secret)` checks a delivery's `bubbl3-signature` header and returns true or false. It never throws, and a missing secret always fails.

## Send a message

Node:

```
import { Bubbl3 } from "@bubbl3/sdk";

const b3 = new Bubbl3({ apiKey: process.env.BUBBL3_API_KEY });

await b3.messages.create(
  { to: "+19175550142", body: "Hi Maya, still good for Thursday at 4:30?" },
  { idempotencyKey: "confirm-4821" },
);
```

Errors:

```
import { Bubbl3, Bubbl3RateLimitError } from "@bubbl3/sdk";

const b3 = new Bubbl3({ apiKey: process.env.BUBBL3_API_KEY });

try {
  const lines = await b3.lines.list();
  console.log(lines.data.length, "lines");
} catch (error) {
  if (error instanceof Bubbl3RateLimitError) {
    console.log("try again in", error.retryAfterSeconds, "seconds");
  } else throw error;
}
```

## In the documentation

- [SDK quick-start](https://docs.bubbl3.com/quickstart/sdk)
- [API reference](https://docs.bubbl3.com/api)

Updated: 2026-10-15
