@billionsend/node 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 (2026-11-26)
4
+
5
+ The OpenAPI snapshot follows the document the API now publishes (186 operations, as before).
6
+
7
+ - Suppressions carry a `note`, why the entry is blocked: `suppressions.create({ note })` and `suppressions.batch.add({ note })` take one (1 to 500 characters, stored on the rows the request creates; an entry that already exists keeps its own), and every entry answers it (`string | null`, `null` on an entry SES wrote).
8
+ - `domains.get(id)` answers `sending_limits`, the broadcast limit the domain's registrable name is under (read-only, only on this call): `mode` (`warming`, `limited`, `unlimited`, `exempt` or `trusted`), `warmup_day`, `warmup_ends_on`, the running window (`window_started_at`, `cap`, `used`), the growth multiplier `g` with the warnings holding it (`g_reasons`), the deliveries it grows from (`t`, `b`), the recipients waiting for the next window (`parked`, `next_window_at`) and `hard_indicators` (`delivery`, `content_review`, `providers_in_backoff`). Only broadcasts are limited; API, SMTP and automation mail never are.
9
+ - Doc comments follow the published descriptions: a recipient's opt-out from a domain is permanent and covers transactional mail too unless the domain turned on `send_transactional_to_unsubscribed`; a broadcast body without the unsubscribe placeholder gets a default unsubscribe link when it is sent.
10
+
3
11
  ## 0.3.0 (2026-11-20)
4
12
 
5
13
  The OpenAPI snapshot follows the document the API now publishes (186 operations, up from 180).
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  The official Node.js and TypeScript client for the [BillionSend](https://billionsend.com) email API: send email, run inboxes for people and agents, stream inbox events, verify webhooks, and manage domains, contacts and broadcasts.
4
4
 
5
- - Every API operation, typed from the BillionSend OpenAPI document.
5
+ - A method for each of the 186 operations of the BillionSend API, typed from a snapshot of its OpenAPI document (see [API coverage](#api-coverage)).
6
6
  - Results as `{ data, error, headers }`: methods never throw. Errors are classes you can tell apart with `instanceof`.
7
7
  - Safe sends: every send carries an `Idempotency-Key`, so retries after a timeout never send twice.
8
8
  - Async iterators for every list and for live inbox events, with automatic resume.
9
- - ES modules and CommonJS, with types for both. No runtime dependencies. Node.js 18 or later (any runtime with `fetch` works).
9
+ - ES modules and CommonJS, with types for both. No runtime dependencies. Node.js 18 or later (any runtime with `fetch` works); the CI runs the tests on Node.js 22 and 24 and the built package on 18, 20, 22 and 24.
10
10
 
11
11
  Documentation: [billionsend.com/docs](https://billionsend.com/docs) · SDK guide: [billionsend.com/docs/sdks/node](https://billionsend.com/docs/sdks/node) · Source: [github.com/billionsend/billionsend-node](https://github.com/billionsend/billionsend-node)
12
12
 
@@ -78,10 +78,12 @@ Every method resolves to one of:
78
78
  | `NotFoundError` | `404` |
79
79
  | `ConflictError` | `409`, such as an idempotency key reused with a different payload |
80
80
  | `RateLimitError` | `429`; `retryAfter` holds the server's hint in seconds |
81
- | `APIError` | `5xx` |
81
+ | `APIError` | `5xx`; `retryAfter` holds the server's hint in seconds, `null` without one |
82
82
  | `APIConnectionError` | no answer: DNS, connection or TLS failure (`statusCode` is `null`) |
83
83
  | `APITimeoutError` | the request timed out (a subclass of `APIConnectionError`) |
84
84
 
85
+ Any other status (such as `402` or `413`) comes back as a plain `BillionSendError` with its `statusCode`, and so does a call that could not be sent at all, with no request made and no retry: `name: "invalid_header"` for a header value HTTP cannot carry (only printable ASCII; the message names the header, never its value), and `application_error` for a path parameter that is empty, `.` or `..`, or for a call aborted through its `signal`. `WebhookVerificationError` (below) is a `BillionSendError` too.
86
+
85
87
  Each carries `statusCode`, `name` (the API's error name, such as `validation_error`; `application_error` when the API sent none), `message` and `requestId`, the answer's `x-request-id`: the same id the request has on the dashboard's Logs page, so quote it when you ask about a request.
86
88
 
87
89
  ```ts
@@ -105,7 +107,7 @@ for await (const contact of bs.contacts.listAll({ limit: 100 })) {
105
107
  }
106
108
  ```
107
109
 
108
- Thread search has `searchAll`. Starting with `before` walks backward. `paginate(fetchPage)` builds the same iterator over any page fetcher.
110
+ Thread search has `searchAll`, and the two broadcast lists `broadcasts.recipientsAll` and `broadcasts.clickedLinksAll`. Starting with `before` walks backward. `paginate(fetchPage)` builds the same iterator over any page fetcher.
109
111
 
110
112
  ## An agent's inbox: wait, read, reply
111
113
 
@@ -155,7 +157,7 @@ const { data: code } = await bs.inboxes.codes.latest("support@acme.dev", { from:
155
157
  - `InboxStreamEvent`: `{ id, event, data }`, where `event` is the webhook event name (`inbox.email.received`, `inbox.thread.created`, `inbox.draft.sent`, `email.received`, …) and `data` is `{ type, created_at, inbox_id, data }`, the webhook payload's metadata with the ids to read next (`thread_id`, `email_id`, `draft_id`).
156
158
  - `StreamGapEvent`: `{ id: null, event: "stream.gap", data: { reason } }` when the stream resumed from further back than the server keeps (24 hours): events may be missing, so read the lists again. One stream hands it out once per position.
157
159
 
158
- When the connection drops (the server also closes every stream about every ten minutes), the stream reconnects with `Last-Event-ID` and replays what it missed before the live events. A connection that delivers nothing, not even the server's keep-alive comment (sent every 15 seconds), for `idleTimeoutMs` (default 45 seconds, `0` turns it off) counts as dropped, so a connection that died silently cannot hang the loop. `maxReconnects` (default 5) bounds the reconnects that fail in a row; one that opens the stream resets the count. A reconnect the API refuses with a `Retry-After` waits that long (longer than 60 seconds: that error is thrown at once). When the reconnects run out, the last one's error is thrown: the API's answer as its own class (`RateLimitError`, `APIError`), or an `APIConnectionError` when the API could not be reached; a refusal a retry cannot fix (a revoked key) is thrown at once. One inbox's stream ends after that inbox's `inbox.deleted` or `inbox.expired`.
160
+ When the connection drops (the server also closes every stream about every ten minutes), the stream reconnects with `Last-Event-ID` and replays what it missed before the live events. A connection that delivers nothing, not even the server's keep-alive comment (sent every 15 seconds), for `idleTimeoutMs` (default 45 seconds, `0` turns it off) counts as dropped, so a connection that died silently cannot hang the loop. `maxReconnects` (default 5) bounds the reconnects that fail in a row; one that opens the stream resets the count. A reconnect the API refuses with a `Retry-After` waits that long (longer than 60 seconds: that error is thrown at once). When the reconnects run out, the last one's error is thrown: the API's answer as its own class (`RateLimitError`, `APIError`), or an `APIConnectionError` when the API could not be reached; a refusal a retry cannot fix (a revoked key) is thrown at once. One inbox's stream ends after that inbox's `inbox.deleted` or `inbox.expired`. Streams are capped per key and per team: one opened over the cap resolves to a `RateLimitError` (`too_many_streams`).
159
161
 
160
162
  ```ts
161
163
  const opened = await bs.inboxes.events.stream({ types: "inbox.email.received,inbox.thread.created" }, {
@@ -192,7 +194,7 @@ app.post("/webhooks/billionsend", express.raw({ type: "application/json" }), asy
192
194
  });
193
195
  ```
194
196
 
195
- With the Fetch API (Next.js route handlers, Hono, Bun, Deno, workers) it is `await verifyWebhook(await request.text(), request.headers, secret)`. During a secret rotation a delivery carries a signature for each live secret, and either secret verifies it.
197
+ With the Fetch API (Next.js route handlers, Hono, Bun, Deno, workers) it is `await verifyWebhook(await request.text(), request.headers, secret)`. During a secret rotation a delivery carries a signature for each live secret, and either secret verifies it. The fourth argument takes `{ tolerance }` (seconds, default 300) to change how far the timestamp may be from now.
196
198
 
197
199
  Deliveries come from `51.161.117.92` with the user agent `BillionSend-Webhooks/1.0 (+https://billionsend.com/docs/concepts/webhooks)`; when the receiving end sits behind a WAF or Cloudflare, allow them as the [webhooks guide](https://billionsend.com/docs/concepts/webhooks) describes.
198
200
 
@@ -268,8 +270,8 @@ Every method takes a last `options` argument with `signal`, `headers`, `timeoutM
268
270
  | `domains` | create, list, get, update, delete, verify, `claims` (create, get, verify), `unsubscribePage.logo` (upload, delete) |
269
271
  | `brand` | get, update, `logo` (upload, delete) |
270
272
  | `apiKeys` | create, list, update, delete |
271
- | `contacts` | create, list, get, update, delete, preferences link, `batch`, `imports` (create, list, get), `topics`, `segments` (list, add, remove) |
272
- | `audiences.contacts` | contacts addressed through an audience |
273
+ | `contacts` | create, list, get, update, delete, preferences link, `batch` (create, get, remove), `imports` (create, list, get), `topics` (list, update), `segments` (list, add, remove) |
274
+ | `audiences.contacts` | contacts addressed through an audience: create, get, update, delete |
273
275
  | `contactProperties`, `segments`, `topics` | create, list, get, update, delete (segment contacts under `segments.contacts`) |
274
276
  | `broadcasts` | create, list, get, update, delete, send, duplicate, cancel, recipients, clickedLinks |
275
277
  | `templates` | create, list, get, update, delete, publish, duplicate |
@@ -282,16 +284,25 @@ Every method takes a last `options` argument with `signal`, `headers`, `timeoutM
282
284
  | `automations` | create, list, get, update, remove, validate, duplicate, simulate, stop, metrics, `runs` (list, get, cancel) |
283
285
  | `logs` | list, get |
284
286
  | `oauthGrants` | list, revoke |
285
- | `inboxes` | create, list, get, update, delete, send, `agent` (get, update), `safety`, `labels`, `threads` (search, labels, emails, reply, forward), `quarantine`, `codes`, `drafts`, `events` |
287
+ | `inboxes` | create, list, get, update, delete, send, `agent` (get, update), `safety`, `labels`, `threads` (list, get, update, delete, search, `labels`, `emails`: list, get, reply, forward), `quarantine` (list, release), `codes` (latest), `drafts` (create, list, get, update, delete, send, reject), `events` (stream, streamInbox) |
286
288
  | `agent` | signup, status, claimEmail |
287
289
 
288
290
  Method names are camelCase; request and response fields keep the API's snake_case names. All request and response types are exported, named after the API's schemas (`SendEmailRequest`, `Inbox`, …).
289
291
 
292
+ ## API coverage
293
+
294
+ Every operation of the API's OpenAPI document has its method: the 186 `operationId`s are the methods' dotted paths (`emails.send`, `inboxes.threads.emails.reply`). The types are generated from `openapi/api.openapi.json`, the snapshot taken for version 0.3.0, so they follow that snapshot and not the API's later schema changes. Two additions are missing from the types, though the API takes and returns them:
295
+
296
+ - `suppressions.create` and `suppressions.batch.add` accept `note` (up to 500 characters, why the entry is blocked), and the entries `suppressions.list` and `suppressions.get` return carry `note`.
297
+ - `domains.get` returns `sending_limits` (the domain's broadcast warm-up and sending window: `mode`, `warmup_day`, `warmup_ends_on`, `window_started_at`, `cap`, `used`, `g`, `g_reasons`, `t`, `b`, `parked`, `next_window_at`, `hard_indicators`).
298
+
299
+ The SDK sends a request body as given and returns the answer as the API wrote it, so both work at runtime; only the compiler does not know them. An object literal with `note` fails the type check as an unknown property (build the object in a variable first), and reading `note` or `sending_limits` needs a cast.
300
+
290
301
  ## Development
291
302
 
292
303
  ```bash
293
304
  pnpm install
294
- pnpm typecheck && pnpm lint && pnpm test:coverage # fails below 95% lines and branches of the hand-written code
305
+ pnpm typecheck && pnpm lint && pnpm test:coverage # fails below 95% lines, branches, functions and statements of the hand-written code
295
306
  pnpm build && pnpm test:smoke
296
307
  ```
297
308
 
@@ -310,10 +321,8 @@ pnpm openapi:check # fails when the snapshot differs from the publi
310
321
 
311
322
  Publishing is manual; nothing is published on push.
312
323
 
313
- 1. Set `version` in `package.json`, turn the changelog's `Unreleased` heading into that version, commit, then tag and push: `git tag v0.1.0 && git push origin main v0.1.0`.
314
- 2. The first version only: a member of the `@billionsend` npm organization publishes from a clean checkout of the tag, with two-factor authentication: `pnpm install --frozen-lockfile && pnpm typecheck && pnpm lint && pnpm test && pnpm test:smoke && npm publish` (`prepublishOnly` builds; `publishConfig.access` is `public`).
315
- 3. Once the package exists: on npmjs.com, `@billionsend/node` → Settings → Trusted Publisher → GitHub Actions, repository `billionsend/billionsend-node`, workflow `release.yml`.
316
- 4. Every later version: Actions → `release` → Run workflow, on the version tag. The workflow refuses a branch or a tag that differs from `package.json`, runs every check, and publishes with npm Trusted Publishing (no token stored).
324
+ 1. Set `version` in `package.json` and `src/version.ts`, add the version's section to the changelog, commit, then tag and push: `git tag v<version> && git push origin main v<version>`.
325
+ 2. Actions → `release` → Run workflow, on the version tag. The workflow refuses a branch or a tag that differs from `package.json`, runs every check, and publishes with npm Trusted Publishing (no token stored). That needs `@billionsend/node` on npmjs.com → Settings → Trusted Publisher → GitHub Actions to name repository `billionsend/billionsend-node` and workflow `release.yml`.
317
326
 
318
327
  ## License
319
328
 
package/dist/index.cjs CHANGED
@@ -166,7 +166,7 @@ function sleep(ms, signal) {
166
166
  }
167
167
 
168
168
  // src/version.ts
169
- var VERSION = "0.3.0";
169
+ var VERSION = "0.3.1";
170
170
 
171
171
  // src/core.ts
172
172
  var DEFAULT_BASE_URL = "https://api.billionsend.com";