@messagebird/sdk 0.12.2 → 0.14.0

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/dist/index.mjs CHANGED
@@ -907,7 +907,7 @@ var BirdNotImplementedError = class extends BirdAPIError {
907
907
  Object.setPrototypeOf(this, new.target.prototype);
908
908
  }
909
909
  };
910
- /** 421 — request reached the wrong region (ADR-0036). */
910
+ /** 421 — request reached the wrong region. */
911
911
  var BirdMisdirectedError = class extends BirdAPIError {
912
912
  constructor(fields) {
913
913
  super(fields);
@@ -1183,6 +1183,116 @@ const client = createClient(createConfig());
1183
1183
  //#endregion
1184
1184
  //#region src/generated/sdk.gen.ts
1185
1185
  /**
1186
+ * Publish a Realtime event
1187
+ *
1188
+ * Publishes an event to one or more channels of a Realtime app. Listing several channels broadcasts the event to all of them in one call. Connected clients subscribed to those channels receive it in real time.
1189
+ */
1190
+ const publishRealtimeAppEvent = (options) => (options.client ?? client).post({
1191
+ security: [{
1192
+ scheme: "bearer",
1193
+ type: "http"
1194
+ }, {
1195
+ in: "cookie",
1196
+ name: "bird_session",
1197
+ type: "apiKey"
1198
+ }],
1199
+ url: "/v1/realtime/apps/{realtime_app_id}/events",
1200
+ ...options,
1201
+ headers: {
1202
+ "Content-Type": "application/json",
1203
+ ...options.headers
1204
+ }
1205
+ });
1206
+ /**
1207
+ * Publish a batch of Realtime events
1208
+ *
1209
+ * Publishes up to 10 events (each to one channel) in a single request.
1210
+ */
1211
+ const publishRealtimeAppBatch = (options) => (options.client ?? client).post({
1212
+ security: [{
1213
+ scheme: "bearer",
1214
+ type: "http"
1215
+ }, {
1216
+ in: "cookie",
1217
+ name: "bird_session",
1218
+ type: "apiKey"
1219
+ }],
1220
+ url: "/v1/realtime/apps/{realtime_app_id}/batch-events",
1221
+ ...options,
1222
+ headers: {
1223
+ "Content-Type": "application/json",
1224
+ ...options.headers
1225
+ }
1226
+ });
1227
+ /**
1228
+ * List Realtime channels
1229
+ *
1230
+ * Lists the app's currently occupied channels, optionally filtered by name prefix.
1231
+ */
1232
+ const listRealtimeAppChannels = (options) => (options.client ?? client).get({
1233
+ security: [{
1234
+ scheme: "bearer",
1235
+ type: "http"
1236
+ }, {
1237
+ in: "cookie",
1238
+ name: "bird_session",
1239
+ type: "apiKey"
1240
+ }],
1241
+ url: "/v1/realtime/apps/{realtime_app_id}/channels",
1242
+ ...options
1243
+ });
1244
+ /**
1245
+ * Get a Realtime channel
1246
+ *
1247
+ * Returns a single channel's occupancy and (on request) counts. Channels exist implicitly — a channel appears when the first connection subscribes and vanishes when the last one leaves — so this endpoint reports state, not existence: an unknown or never-used name returns 200 with `occupied: false`, never 404.
1248
+ */
1249
+ const getRealtimeAppChannel = (options) => (options.client ?? client).get({
1250
+ security: [{
1251
+ scheme: "bearer",
1252
+ type: "http"
1253
+ }, {
1254
+ in: "cookie",
1255
+ name: "bird_session",
1256
+ type: "apiKey"
1257
+ }],
1258
+ url: "/v1/realtime/apps/{realtime_app_id}/channels/{channel_name}",
1259
+ ...options
1260
+ });
1261
+ /**
1262
+ * List members on a presence channel
1263
+ *
1264
+ * Lists the member ids currently subscribed to a presence channel. Ids only: `member_info` (the profile data attached by your authorization endpoint) is delivered to subscribed clients over the realtime connection and is not available over REST.
1265
+ */
1266
+ const listRealtimeAppChannelMembers = (options) => (options.client ?? client).get({
1267
+ security: [{
1268
+ scheme: "bearer",
1269
+ type: "http"
1270
+ }, {
1271
+ in: "cookie",
1272
+ name: "bird_session",
1273
+ type: "apiKey"
1274
+ }],
1275
+ url: "/v1/realtime/apps/{realtime_app_id}/channels/{channel_name}/members",
1276
+ ...options
1277
+ });
1278
+ /**
1279
+ * Disconnect a member
1280
+ *
1281
+ * Disconnects all of a member's active connections (e.g. on sign-out or ban).
1282
+ */
1283
+ const disconnectRealtimeAppMember = (options) => (options.client ?? client).post({
1284
+ security: [{
1285
+ scheme: "bearer",
1286
+ type: "http"
1287
+ }, {
1288
+ in: "cookie",
1289
+ name: "bird_session",
1290
+ type: "apiKey"
1291
+ }],
1292
+ url: "/v1/realtime/apps/{realtime_app_id}/members/{member_id}/disconnect",
1293
+ ...options
1294
+ });
1295
+ /**
1186
1296
  * List messages
1187
1297
  *
1188
1298
  * Returns the workspace's sent and scheduled messages, newest first, as a cursor page. Each item carries the aggregate delivery `status` and per-state recipient counts, not the message body. Combine filters to narrow the page: `status`, `category`, `tag`, exact `to`/`from` address, and a `created_after`/`created_before` time window.
@@ -1937,8 +2047,7 @@ const listWhatsAppMessages = (options) => (options?.client ?? client).get({
1937
2047
  * placeholders in `components`; Bird selects the sender number from the
1938
2048
  * template's category, so the request carries no sender field. Templates are
1939
2049
  * the only supported content type: a request without `template` is rejected
1940
- * with a `422`. Browse what you can send with
1941
- * [List available message templates](/docs/api/reference/list-whats-app-templates).
2050
+ * with a `422`. Browse your workspace's templates in the Bird dashboard.
1942
2051
  *
1943
2052
  * The `202` response is the accepted message, echoing the resolved template
1944
2053
  * and language; it is not a delivery confirmation. Follow delivery with
@@ -2005,24 +2114,6 @@ const listWhatsAppMessageEvents = (options) => (options.client ?? client).get({
2005
2114
  ...options
2006
2115
  });
2007
2116
  /**
2008
- * List available message templates
2009
- *
2010
- * Returns the WhatsApp message templates you can send from. Each entry carries the template's `name` (the reference you pass when sending), its language, category, review status, and its content blocks with example values for every placeholder. The catalogue is returned in full, so this list is not paginated, and it can differ by region: you see the templates stocked for the region you call. Pick a template here, then fill its placeholders in the `components` of [Send a WhatsApp message](/docs/api/reference/send-whats-app-message).
2011
- *
2012
- */
2013
- const listWhatsAppTemplates = (options) => (options?.client ?? client).get({
2014
- security: [{
2015
- scheme: "bearer",
2016
- type: "http"
2017
- }, {
2018
- in: "cookie",
2019
- name: "bird_session",
2020
- type: "apiKey"
2021
- }],
2022
- url: "/v1/whatsapp/templates",
2023
- ...options
2024
- });
2025
- /**
2026
2117
  * Daily sending statistics
2027
2118
  *
2028
2119
  * Returns one row of aggregate sending statistics per calendar day for the workspace: UTC days by default, or your local days when `timezone` is set. Days with no activity are included with zero counts, so the series charts without client-side gap handling. Suited to charts and trend lines; for per-message exact accounting use the message detail endpoints.
@@ -2986,6 +3077,60 @@ function mergeHeaders(idempotencyKey, extra) {
2986
3077
  };
2987
3078
  }
2988
3079
  //#endregion
3080
+ //#region src/resources/email.gen.ts
3081
+ var EmailResourceBase = class extends Resource {
3082
+ /**
3083
+ * Fetch one email message by id — aggregate delivery status and per-state recipient counts. The message body (html, text) is not returned. Per-recipient delivery statuses and the event log are separate sub-resources: GET /v1/email/messages/{message_id}/recipients and GET /v1/email/messages/{message_id}/events.
3084
+ *
3085
+ * @example
3086
+ * const msg = await bird.email.get("em_abc123");
3087
+ * msg.status; // "accepted" | "processed" | "delivered" | "bounced" | …
3088
+ * msg.delivered_count;
3089
+ * msg.bounced_count;
3090
+ */
3091
+ get(messageId, options) {
3092
+ return this.call("GET", options, ({ signal, headers }) => getEmailMessage({
3093
+ client: this.client,
3094
+ path: { message_id: messageId },
3095
+ headers,
3096
+ signal
3097
+ }));
3098
+ }
3099
+ /**
3100
+ * List sent email messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by creation time with the half-open range created_after (inclusive) / created_before (exclusive) — e.g. for a single UTC day set created_after to that day at 00:00:00Z and created_before to the next day at 00:00:00Z.
3101
+ *
3102
+ * @example
3103
+ * for await (const message of bird.email.list({ status: "bounced" })) {
3104
+ * console.log(message.id);
3105
+ * }
3106
+ */
3107
+ list(query, options) {
3108
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailMessages({
3109
+ client: this.client,
3110
+ query: {
3111
+ ...query,
3112
+ starting_after: cursor ?? query?.starting_after
3113
+ },
3114
+ headers,
3115
+ signal
3116
+ }));
3117
+ }
3118
+ /**
3119
+ * Cancel a scheduled email before it sends. Only works while the message is still scheduled (status `scheduled`); once it starts sending — or was already canceled — the call returns a conflict error. Canceling does not return consumed scheduled-send quota.
3120
+ *
3121
+ * @example
3122
+ * await bird.email.cancel("em_abc123");
3123
+ */
3124
+ cancel(messageId, options) {
3125
+ return this.call("POST", options, ({ signal, headers }) => cancelEmailMessage({
3126
+ client: this.client,
3127
+ path: { message_id: messageId },
3128
+ headers,
3129
+ signal
3130
+ }));
3131
+ }
3132
+ };
3133
+ //#endregion
2989
3134
  //#region src/resources/emailStats.gen.ts
2990
3135
  var EmailStatsResource = class extends Resource {
2991
3136
  /**
@@ -3282,7 +3427,7 @@ var EmailStatsResource = class extends Resource {
3282
3427
  };
3283
3428
  //#endregion
3284
3429
  //#region src/resources/email.ts
3285
- var EmailResource = class extends Resource {
3430
+ var EmailResource = class extends EmailResourceBase {
3286
3431
  #defaults;
3287
3432
  /** Email statistics — `bird.email.stats.summary(...)`, `.daily(...)`, `.byTag(...)`, … */
3288
3433
  stats;
@@ -3400,85 +3545,14 @@ var EmailResource = class extends Resource {
3400
3545
  signal
3401
3546
  }));
3402
3547
  }
3403
- /**
3404
- * Fetch a message with aggregate delivery status.
3405
- *
3406
- * @example
3407
- * const msg = await bird.email.get("em_abc123");
3408
- * msg.status; // "accepted" | "processed" | "delivered" | "bounced" | …
3409
- * msg.delivered_count;
3410
- * msg.bounced_count;
3411
- */
3412
- get(messageId, options) {
3413
- return this.call("GET", options, ({ signal, headers }) => getEmailMessage({
3414
- client: this.client,
3415
- path: { message_id: messageId },
3416
- headers,
3417
- signal
3418
- }));
3419
- }
3420
- /**
3421
- * Cancel a message scheduled with `scheduled_at` before it sends. Only a
3422
- * message that is still scheduled can be canceled; one that already started
3423
- * sending — or was previously canceled — rejects with a conflict error.
3424
- * Canceling does not return consumed scheduled-send quota.
3425
- *
3426
- * @example
3427
- * await bird.email.cancel("em_abc123");
3428
- */
3429
- cancel(messageId, options) {
3430
- return this.call("POST", options, ({ signal, headers }) => cancelEmailMessage({
3431
- client: this.client,
3432
- path: { message_id: messageId },
3433
- headers,
3434
- signal
3435
- }));
3436
- }
3437
- /**
3438
- * List messages, newest first. `await` resolves the first page; `for await`
3439
- * walks every message across all pages.
3440
- *
3441
- * @example Iterate every message, or take one page
3442
- * for await (const message of bird.email.list({ status: "bounced" })) {
3443
- * console.log(message.id);
3444
- * }
3445
- * const page = await bird.email.list({ limit: 50 }); // page.data, page.next_cursor
3446
- */
3447
- list(query, options) {
3448
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailMessages({
3449
- client: this.client,
3450
- query: {
3451
- ...query,
3452
- starting_after: cursor ?? query?.starting_after
3453
- },
3454
- headers,
3455
- signal
3456
- }));
3457
- }
3458
3548
  };
3459
3549
  //#endregion
3460
- //#region src/resources/audiences.ts
3550
+ //#region src/resources/audiences.gen.ts
3461
3551
  var AudiencesResource = class extends Resource {
3462
3552
  /**
3463
- * Create an audience.
3464
- *
3465
- * @example Create an audience
3466
- * const audience = await bird.audiences.create({ name: "Newsletter subscribers" });
3467
- * console.log(audience.id); // "aud_…"
3468
- */
3469
- create(params, options) {
3470
- return this.call("POST", options, ({ signal, headers }) => createAudience({
3471
- client: this.client,
3472
- body: params,
3473
- headers,
3474
- signal
3475
- }));
3476
- }
3477
- /**
3478
- * List the workspace's audiences, newest first. `await` resolves the first
3479
- * page; `for await` walks every audience across pages.
3553
+ * List the workspace's audiences as a cursor page, newest first. Filter by name substring with `q`.
3480
3554
  *
3481
- * @example
3555
+ * @example Iterate every audience, or take one page
3482
3556
  * for await (const audience of bird.audiences.list()) {
3483
3557
  * console.log(audience.id, audience.name);
3484
3558
  * }
@@ -3495,10 +3569,11 @@ var AudiencesResource = class extends Resource {
3495
3569
  }));
3496
3570
  }
3497
3571
  /**
3498
- * Fetch a single audience by id.
3572
+ * Get a single audience by ID: name, description, and type. Members are listed separately with `audiences.list_contacts`.
3499
3573
  *
3500
- * @example
3501
- * const audience = await bird.audiences.get("aud_01krdgeqcxet5s7t44vh8rt9mg");
3574
+ * @example Fetch an audience by id
3575
+ * const audience = await bird.audiences.get("adn_01krdgeqcxet5s7t44vh8rt9mg");
3576
+ * console.log(audience.name);
3502
3577
  */
3503
3578
  get(audienceId, options) {
3504
3579
  return this.call("GET", options, ({ signal, headers }) => getAudience({
@@ -3509,12 +3584,27 @@ var AudiencesResource = class extends Resource {
3509
3584
  }));
3510
3585
  }
3511
3586
  /**
3512
- * Update an audience. Only the fields you send change.
3587
+ * Create an audience in the workspace. New audiences start empty; add contacts with `audiences.add_contacts` or `contacts.batch`. Only static audiences can be created today.
3513
3588
  *
3514
- * @example
3515
- * await bird.audiences.update("aud_01krdgeqcxet5s7t44vh8rt9mg", { name: "Renamed" });
3589
+ * @example Create an audience
3590
+ * const audience = await bird.audiences.create({ name: "Newsletter subscribers" });
3591
+ * console.log(audience.id); // "adn_…"
3592
+ */
3593
+ create(params, options) {
3594
+ return this.call("POST", options, ({ signal, headers }) => createAudience({
3595
+ client: this.client,
3596
+ body: params,
3597
+ headers,
3598
+ signal
3599
+ }));
3600
+ }
3601
+ /**
3602
+ * Update an audience's name or description. Omitted fields are unchanged; a null description clears it.
3603
+ *
3604
+ * @example Rename an audience
3605
+ * await bird.audiences.update("adn_01krdgeqcxet5s7t44vh8rt9mg", { name: "Renamed" });
3516
3606
  */
3517
- update(audienceId, params, options) {
3607
+ update(audienceId, params = {}, options) {
3518
3608
  return this.call("PATCH", options, ({ signal, headers }) => updateAudience({
3519
3609
  client: this.client,
3520
3610
  path: { audience_id: audienceId },
@@ -3524,10 +3614,10 @@ var AudiencesResource = class extends Resource {
3524
3614
  }));
3525
3615
  }
3526
3616
  /**
3527
- * Delete an audience. Its contacts are unaffected.
3617
+ * Delete an audience and its memberships; contacts themselves are not deleted. Fails while a broadcast targeting the audience is scheduled, accepted, sending, or canceling.
3528
3618
  *
3529
- * @example
3530
- * await bird.audiences.delete("aud_01krdgeqcxet5s7t44vh8rt9mg");
3619
+ * @example Delete an audience by id
3620
+ * await bird.audiences.delete("adn_01krdgeqcxet5s7t44vh8rt9mg");
3531
3621
  */
3532
3622
  delete(audienceId, options) {
3533
3623
  return this.call("DELETE", options, ({ signal, headers }) => deleteAudience({
@@ -3538,11 +3628,10 @@ var AudiencesResource = class extends Resource {
3538
3628
  }));
3539
3629
  }
3540
3630
  /**
3541
- * List the contacts in an audience, newest first. `await` resolves the first
3542
- * page; `for await` walks every member across pages.
3631
+ * List the contacts in a static audience by ID, as a cursor page ordered by when each contact joined (most recent first). Each entry pairs the contact with its join time.
3543
3632
  *
3544
- * @example
3545
- * for await (const member of bird.audiences.listContacts("aud_01krdgeqcxet5s7t44vh8rt9mg")) {
3633
+ * @example Iterate an audience's members
3634
+ * for await (const member of bird.audiences.listContacts("adn_01krdgeqcxet5s7t44vh8rt9mg")) {
3546
3635
  * console.log(member.contact.id, member.joined_at);
3547
3636
  * }
3548
3637
  */
@@ -3559,11 +3648,11 @@ var AudiencesResource = class extends Resource {
3559
3648
  }));
3560
3649
  }
3561
3650
  /**
3562
- * Add contacts to an audience by id.
3651
+ * Add up to 1,000 existing contacts to a static audience by ID. Fails entirely if any contact ID does not exist.
3563
3652
  *
3564
- * @example
3565
- * await bird.audiences.addContacts("aud_01krdgeqcxet5s7t44vh8rt9mg", {
3566
- * contact_ids: ["con_1", "con_2"],
3653
+ * @example Add contacts to an audience
3654
+ * await bird.audiences.addContacts("adn_01krdgeqcxet5s7t44vh8rt9mg", {
3655
+ * contact_ids: ["con_01krdgeqcxet5s7t44vh8rt9mg"],
3567
3656
  * });
3568
3657
  */
3569
3658
  addContacts(audienceId, params, options) {
@@ -3576,11 +3665,11 @@ var AudiencesResource = class extends Resource {
3576
3665
  }));
3577
3666
  }
3578
3667
  /**
3579
- * Remove a set of contacts from an audience.
3668
+ * Remove up to 1,000 contacts from a static audience by ID. Fails entirely if any contact ID does not exist; contacts are not deleted.
3580
3669
  *
3581
- * @example
3582
- * await bird.audiences.removeContacts("aud_01krdgeqcxet5s7t44vh8rt9mg", {
3583
- * contact_ids: ["con_1", "con_2"],
3670
+ * @example Remove contacts from an audience
3671
+ * await bird.audiences.removeContacts("adn_01krdgeqcxet5s7t44vh8rt9mg", {
3672
+ * contact_ids: ["con_01krdgeqcxet5s7t44vh8rt9mg"],
3584
3673
  * });
3585
3674
  */
3586
3675
  removeContacts(audienceId, params, options) {
@@ -3593,10 +3682,13 @@ var AudiencesResource = class extends Resource {
3593
3682
  }));
3594
3683
  }
3595
3684
  /**
3596
- * Remove a single contact from an audience.
3685
+ * Remove one contact's membership from an audience. The contact itself is not deleted and stays a member of any other audiences.
3597
3686
  *
3598
- * @example
3599
- * await bird.audiences.removeContact("aud_01krdgeqcxet5s7t44vh8rt9mg", "con_1");
3687
+ * @example Remove one contact's membership
3688
+ * await bird.audiences.removeContact(
3689
+ * "adn_01krdgeqcxet5s7t44vh8rt9mg",
3690
+ * "con_01krdgeqcxet5s7t44vh8rt9mg",
3691
+ * );
3600
3692
  */
3601
3693
  removeContact(audienceId, contactId, options) {
3602
3694
  return this.call("DELETE", options, ({ signal, headers }) => unassignAudienceContact({
@@ -3611,29 +3703,12 @@ var AudiencesResource = class extends Resource {
3611
3703
  }
3612
3704
  };
3613
3705
  //#endregion
3614
- //#region src/resources/domains.ts
3706
+ //#region src/resources/domains.gen.ts
3615
3707
  var DomainsResource = class extends Resource {
3616
3708
  /**
3617
- * Register a sending domain. Returns it in `pending` with the `dns_records`
3618
- * to publish at your DNS provider; call `verify` once they are in place.
3619
- *
3620
- * @example Register a sending domain
3621
- * const domain = await bird.domains.create({ domain: "mail.acme.com" });
3622
- * console.log(domain.id, domain.status); // "dom_…", "pending"
3623
- */
3624
- create(params, options) {
3625
- return this.call("POST", options, ({ signal, headers }) => createDomain({
3626
- client: this.client,
3627
- body: params,
3628
- headers,
3629
- signal
3630
- }));
3631
- }
3632
- /**
3633
- * List the workspace's sending domains, newest first. `await` resolves the
3634
- * first page; `for await` walks every domain across pages.
3709
+ * List the workspace's sending domains with their verification status, as a cursor page.
3635
3710
  *
3636
- * @example
3711
+ * @example Iterate every sending domain
3637
3712
  * for await (const domain of bird.domains.list()) {
3638
3713
  * console.log(domain.id, domain.status);
3639
3714
  * }
@@ -3650,11 +3725,11 @@ var DomainsResource = class extends Resource {
3650
3725
  }));
3651
3726
  }
3652
3727
  /**
3653
- * Fetch a single sending domain by id, with its DNS records and their
3654
- * per-record verification state.
3728
+ * Fetch one sending domain: verification status and the DNS records with their individual verification states.
3655
3729
  *
3656
- * @example
3730
+ * @example Fetch a sending domain by id
3657
3731
  * const domain = await bird.domains.get("dom_01krdgeqcxet5s7t44vh8rt9mg");
3732
+ * console.log(domain.domain);
3658
3733
  */
3659
3734
  get(domainId, options) {
3660
3735
  return this.call("GET", options, ({ signal, headers }) => getDomain({
@@ -3665,34 +3740,29 @@ var DomainsResource = class extends Resource {
3665
3740
  }));
3666
3741
  }
3667
3742
  /**
3668
- * Update a sending domain. Only the fields you send change; `settings` apply
3669
- * immediately, while `return_path`/`tracking`/`dkim` changes are staged until
3670
- * their new DNS records verify.
3743
+ * Register a new sending domain and get the DNS records to publish. Flow: call this, publish the returned DNS records at your DNS provider, then call email_domains_verify (repeat until status is verified — DNS propagation can take minutes to hours).
3671
3744
  *
3672
- * @example
3673
- * await bird.domains.update("dom_01krdgeqcxet5s7t44vh8rt9mg", {
3674
- * settings: { click_tracking: true, open_tracking: true },
3675
- * tracking: { name: "links" },
3676
- * });
3745
+ * @example Register a sending domain
3746
+ * const domain = await bird.domains.create({ domain: "mail.acme.com" });
3747
+ * console.log(domain.id, domain.status); // "dom_…", "pending"
3677
3748
  */
3678
- update(domainId, params, options) {
3679
- return this.call("PATCH", options, ({ signal, headers }) => updateDomain({
3680
- client: this.client,
3681
- path: { domain_id: domainId },
3749
+ create(params, options) {
3750
+ return this.call("POST", options, ({ signal, headers }) => createDomain({
3751
+ client: this.client,
3682
3752
  body: params,
3683
3753
  headers,
3684
3754
  signal
3685
3755
  }));
3686
3756
  }
3687
3757
  /**
3688
- * Delete a sending domain. Mail already accepted still sends; you can no
3689
- * longer send new mail from it.
3758
+ * Trigger a DNS verification check for a sending domain and return the refreshed domain with per-record results. Safe to repeat while waiting for DNS propagation.
3690
3759
  *
3691
- * @example
3692
- * await bird.domains.delete("dom_01krdgeqcxet5s7t44vh8rt9mg");
3760
+ * @example Re-run the DNS verification check
3761
+ * const domain = await bird.domains.verify("dom_01krdgeqcxet5s7t44vh8rt9mg");
3762
+ * console.log(domain.status); // "verified" once DNS is in place
3693
3763
  */
3694
- delete(domainId, options) {
3695
- return this.call("DELETE", options, ({ signal, headers }) => deleteDomain({
3764
+ verify(domainId, options) {
3765
+ return this.call("POST", options, ({ signal, headers }) => verifyDomain({
3696
3766
  client: this.client,
3697
3767
  path: { domain_id: domainId },
3698
3768
  headers,
@@ -3700,15 +3770,31 @@ var DomainsResource = class extends Resource {
3700
3770
  }));
3701
3771
  }
3702
3772
  /**
3703
- * Trigger a fresh DNS check and return the refreshed domain with per-record
3704
- * results. Safe to repeat while waiting for DNS to propagate.
3773
+ * Update a sending domain's tracking and inbound configuration. Tracking: toggle click_tracking and open_tracking (applied immediately to new sends), and set, change, or remove the tracking domain (the name part only — Bird appends the sending domain). Enabling either toggle with no tracking domain configured returns 409; removing the tracking domain while either toggle is still on also returns 409. Tracking-domain changes on a verified domain are staged behind DNS verification, so the current config keeps serving until the new records verify. Inbound receiving: set inbound.enabled to start or stop receiving mail for the domain. Enabling requires the domain's DKIM to be verified first (a fresh enable on an unverified domain returns 422), and a domain already receiving inbound for another organization returns 422. The MX records to publish are always listed in dns_records regardless, so enabling — not merely publishing them — is what turns receiving on.
3705
3774
  *
3706
- * @example
3707
- * const domain = await bird.domains.verify("dom_01krdgeqcxet5s7t44vh8rt9mg");
3708
- * console.log(domain.status); // "verified" once DNS is in place
3775
+ * @example Enable tracking on a domain
3776
+ * await bird.domains.update("dom_01krdgeqcxet5s7t44vh8rt9mg", {
3777
+ * settings: { click_tracking: true, open_tracking: true },
3778
+ * tracking: { name: "links" },
3779
+ * });
3709
3780
  */
3710
- verify(domainId, options) {
3711
- return this.call("POST", options, ({ signal, headers }) => verifyDomain({
3781
+ update(domainId, params = {}, options) {
3782
+ return this.call("PATCH", options, ({ signal, headers }) => updateDomain({
3783
+ client: this.client,
3784
+ path: { domain_id: domainId },
3785
+ body: params,
3786
+ headers,
3787
+ signal
3788
+ }));
3789
+ }
3790
+ /**
3791
+ * Delete a sending domain by id. Revokes its sender authorization: new sends from the domain are rejected afterward, while historical statistics and events for past sends are preserved. Destructive.
3792
+ *
3793
+ * @example Delete a sending domain by id
3794
+ * await bird.domains.delete("dom_01krdgeqcxet5s7t44vh8rt9mg");
3795
+ */
3796
+ delete(domainId, options) {
3797
+ return this.call("DELETE", options, ({ signal, headers }) => deleteDomain({
3712
3798
  client: this.client,
3713
3799
  path: { domain_id: domainId },
3714
3800
  headers,
@@ -3718,7 +3804,7 @@ var DomainsResource = class extends Resource {
3718
3804
  };
3719
3805
  //#endregion
3720
3806
  //#region src/resources/contactProperties.gen.ts
3721
- var ContactPropertiesResourceBase = class extends Resource {
3807
+ var ContactPropertiesResource = class extends Resource {
3722
3808
  /**
3723
3809
  * List the workspace's contact properties as a cursor page, newest first. Archived properties are included, marked by their archived flag.
3724
3810
  *
@@ -3755,65 +3841,60 @@ var ContactPropertiesResourceBase = class extends Resource {
3755
3841
  }));
3756
3842
  }
3757
3843
  /**
3758
- * Archive a contact property: the key is rejected in new contact writes and stops rendering in templates, while stored values remain readable. The key stays reserved and counts toward the 200-property limit; reverse with `contact_properties.unarchive`.
3844
+ * Define a custom contact property (key + value type) that becomes available in contact data and as a broadcast template variable. The key and type cannot change after creation; a workspace holds at most 200 properties, archived included.
3759
3845
  *
3760
- * @example Archive a property, retiring the field without deleting its data
3761
- * const prop = await bird.contactProperties.archive("cp_01krdgeqcxet5s7t44vh8rt9mg");
3762
- * console.log(prop.key, prop.archived);
3846
+ * @example Define a custom property
3847
+ * const prop = await bird.contactProperties.create({ key: "plan", type: "string" });
3848
+ * console.log(prop.id); // "cp_…"
3763
3849
  */
3764
- archive(propertyId, options) {
3765
- return this.call("POST", options, ({ signal, headers }) => archiveContactProperty({
3850
+ create(params, options) {
3851
+ return this.call("POST", options, ({ signal, headers }) => createContactProperty({
3766
3852
  client: this.client,
3767
- path: { property_id: propertyId },
3853
+ body: params,
3768
3854
  headers,
3769
3855
  signal
3770
3856
  }));
3771
3857
  }
3772
3858
  /**
3773
- * Reactivate an archived contact property so its key is accepted in contact writes and renders in templates again. Fails with a conflict if the property is not archived.
3859
+ * Update a contact property's fallback value. The key and type are immutable; create a new property instead.
3774
3860
  *
3775
- * @example Restore an archived property
3776
- * await bird.contactProperties.unarchive("cp_01krdgeqcxet5s7t44vh8rt9mg");
3861
+ * @example Change a property's fallback value
3862
+ * await bird.contactProperties.update("cp_01krdgeqcxet5s7t44vh8rt9mg", { fallback_value: "free" });
3777
3863
  */
3778
- unarchive(propertyId, options) {
3779
- return this.call("POST", options, ({ signal, headers }) => unarchiveContactProperty({
3864
+ update(propertyId, params = {}, options) {
3865
+ return this.call("PATCH", options, ({ signal, headers }) => updateContactProperty({
3780
3866
  client: this.client,
3781
3867
  path: { property_id: propertyId },
3868
+ body: params,
3782
3869
  headers,
3783
3870
  signal
3784
3871
  }));
3785
3872
  }
3786
- };
3787
- //#endregion
3788
- //#region src/resources/contactProperties.ts
3789
- var ContactPropertiesResource = class extends ContactPropertiesResourceBase {
3790
3873
  /**
3791
- * Define a contact property. The `key` must be unique in the workspace and is
3792
- * how contacts reference the field in their `data`.
3874
+ * Archive a contact property: the key is rejected in new contact writes and stops rendering in templates, while stored values remain readable. The key stays reserved and counts toward the 200-property limit; reverse with `contact_properties.unarchive`.
3793
3875
  *
3794
- * @example
3795
- * const prop = await bird.contactProperties.create({ key: "plan", type: "string" });
3796
- * console.log(prop.id); // "cp_…"
3876
+ * @example Archive a property, retiring the field without deleting its data
3877
+ * const prop = await bird.contactProperties.archive("cp_01krdgeqcxet5s7t44vh8rt9mg");
3878
+ * console.log(prop.key, prop.archived);
3797
3879
  */
3798
- create(params, options) {
3799
- return this.call("POST", options, ({ signal, headers }) => createContactProperty({
3880
+ archive(propertyId, options) {
3881
+ return this.call("POST", options, ({ signal, headers }) => archiveContactProperty({
3800
3882
  client: this.client,
3801
- body: params,
3883
+ path: { property_id: propertyId },
3802
3884
  headers,
3803
3885
  signal
3804
3886
  }));
3805
3887
  }
3806
3888
  /**
3807
- * Update a contact property. Only the fields you send change.
3889
+ * Reactivate an archived contact property so its key is accepted in contact writes and renders in templates again. Fails with a conflict if the property is not archived.
3808
3890
  *
3809
- * @example
3810
- * await bird.contactProperties.update("cp_01krdgeqcxet5s7t44vh8rt9mg", { fallback_value: "free" });
3891
+ * @example Restore an archived property
3892
+ * await bird.contactProperties.unarchive("cp_01krdgeqcxet5s7t44vh8rt9mg");
3811
3893
  */
3812
- update(propertyId, params, options) {
3813
- return this.call("PATCH", options, ({ signal, headers }) => updateContactProperty({
3894
+ unarchive(propertyId, options) {
3895
+ return this.call("POST", options, ({ signal, headers }) => unarchiveContactProperty({
3814
3896
  client: this.client,
3815
3897
  path: { property_id: propertyId },
3816
- body: params,
3817
3898
  headers,
3818
3899
  signal
3819
3900
  }));
@@ -3821,7 +3902,7 @@ var ContactPropertiesResource = class extends ContactPropertiesResourceBase {
3821
3902
  };
3822
3903
  //#endregion
3823
3904
  //#region src/resources/contacts.gen.ts
3824
- var ContactsResourceBase = class extends Resource {
3905
+ var ContactsResource = class extends Resource {
3825
3906
  /**
3826
3907
  * List the workspace's contacts as a cursor page, newest first. Look one up by exact email or external_id, or search by email substring.
3827
3908
  *
@@ -3876,48 +3957,47 @@ var ContactsResourceBase = class extends Resource {
3876
3957
  }));
3877
3958
  }
3878
3959
  /**
3879
- * Delete a contact and remove it from every audience it belongs to. Suppression records for the address are unaffected.
3960
+ * Update a contact's name, external_id, email, or custom data. Only supplied fields change; custom data keys are merged, with null removing a key.
3880
3961
  *
3881
- * @example Delete a contact by id
3882
- * await bird.contacts.delete("con_01krdgeqcxet5s7t44vh8rt9mg");
3962
+ * @example Change a contact's fields
3963
+ * const contact = await bird.contacts.update("con_01krdgeqcxet5s7t44vh8rt9mg", {
3964
+ * first_name: "Jane",
3965
+ * });
3966
+ * console.log(contact.first_name);
3883
3967
  */
3884
- delete(contactId, options) {
3885
- return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
3968
+ update(contactId, params = {}, options) {
3969
+ return this.call("PATCH", options, ({ signal, headers }) => updateContact({
3886
3970
  client: this.client,
3887
3971
  path: { contact_id: contactId },
3972
+ body: params,
3888
3973
  headers,
3889
3974
  signal
3890
3975
  }));
3891
3976
  }
3892
- };
3893
- //#endregion
3894
- //#region src/resources/contacts.ts
3895
- var ContactsResource = class extends ContactsResourceBase {
3896
3977
  /**
3897
- * Update a contact. Only the fields you send change.
3978
+ * Delete a contact and remove it from every audience it belongs to. Suppression records for the address are unaffected.
3898
3979
  *
3899
- * @example
3900
- * const contact = await bird.contacts.update("con_01krdgeqcxet5s7t44vh8rt9mg", {
3901
- * first_name: "Jane",
3902
- * });
3980
+ * @example Delete a contact by id
3981
+ * await bird.contacts.delete("con_01krdgeqcxet5s7t44vh8rt9mg");
3903
3982
  */
3904
- update(contactId, params, options) {
3905
- return this.call("PATCH", options, ({ signal, headers }) => updateContact({
3983
+ delete(contactId, options) {
3984
+ return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
3906
3985
  client: this.client,
3907
3986
  path: { contact_id: contactId },
3908
- body: params,
3909
3987
  headers,
3910
3988
  signal
3911
3989
  }));
3912
3990
  }
3913
3991
  /**
3914
- * Create or update many contacts in one call, matched by email. Returns a
3915
- * per-contact result.
3992
+ * Create or update up to 1,000 contacts in one request, matched by email address, and optionally add them all to one or more audiences. Per-contact results are returned in submission order.
3916
3993
  *
3917
- * @example
3994
+ * @example Create or update many contacts at once, matched by email
3918
3995
  * const result = await bird.contacts.batch({
3919
3996
  * contacts: [{ email: "jane@acme.com", first_name: "Jane" }],
3920
3997
  * });
3998
+ * for (const item of result.data) {
3999
+ * console.log(item.email, item.status);
4000
+ * }
3921
4001
  */
3922
4002
  batch(params, options) {
3923
4003
  return this.call("POST", options, ({ signal, headers }) => createContactBatch({
@@ -3929,8 +4009,47 @@ var ContactsResource = class extends ContactsResourceBase {
3929
4009
  }
3930
4010
  };
3931
4011
  //#endregion
4012
+ //#region src/resources/sms.gen.ts
4013
+ var SmsResourceBase = class extends Resource {
4014
+ /**
4015
+ * Get one SMS message by id: its current delivery status, segment breakdown, cost, and failure detail if it failed.
4016
+ *
4017
+ * @example Read a message back
4018
+ * const msg = await bird.sms.get("sms_abc123");
4019
+ * msg.status; // "accepted" | "delivered" | …
4020
+ */
4021
+ get(messageId, options) {
4022
+ return this.call("GET", options, ({ signal, headers }) => getSmsMessage({
4023
+ client: this.client,
4024
+ path: { message_id: messageId },
4025
+ headers,
4026
+ signal
4027
+ }));
4028
+ }
4029
+ /**
4030
+ * List SMS messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by direction, status, category, recipient, sender, or tag.
4031
+ *
4032
+ * @example Iterate outbound messages
4033
+ * for await (const msg of bird.sms.list({ direction: "outbound" })) {
4034
+ * console.log(msg.id, msg.status);
4035
+ * }
4036
+ */
4037
+ list(query, options) {
4038
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listSmsMessages({
4039
+ client: this.client,
4040
+ query: {
4041
+ ...query,
4042
+ starting_after: cursor ?? query?.starting_after
4043
+ },
4044
+ headers,
4045
+ signal
4046
+ }));
4047
+ }
4048
+ };
4049
+ //#endregion
3932
4050
  //#region src/resources/sms.ts
3933
- var SmsResource = class extends Resource {
4051
+ /** Filters and cursor params for `bird.sms.list`. */
4052
+ var SmsResource = class extends SmsResourceBase {
3934
4053
  /**
3935
4054
  * Send one SMS to a single recipient. Supply either `text` (with a `category`)
3936
4055
  * or a stored `template` (by `id` or `name`, with its `parameters`). The
@@ -3977,52 +4096,12 @@ var SmsResource = class extends Resource {
3977
4096
  signal
3978
4097
  }));
3979
4098
  }
3980
- /**
3981
- * Fetch a single SMS message: its current delivery status, segment breakdown,
3982
- * cost, and failure detail if it failed.
3983
- *
3984
- * @example
3985
- * const msg = await bird.sms.get("sms_abc123");
3986
- * msg.status; // "accepted" | "delivered" | …
3987
- */
3988
- get(messageId, options) {
3989
- return this.call("GET", options, ({ signal, headers }) => getSmsMessage({
3990
- client: this.client,
3991
- path: { message_id: messageId },
3992
- headers,
3993
- signal
3994
- }));
3995
- }
3996
- /**
3997
- * List SMS messages, newest first. `await` resolves the first page; `for await`
3998
- * walks every message across all pages. Filter by direction, status, category,
3999
- * recipient, sender, or tag.
4000
- *
4001
- * @example
4002
- * for await (const msg of bird.sms.list({ direction: "outbound" })) {
4003
- * console.log(msg.id, msg.status);
4004
- * }
4005
- */
4006
- list(query, options) {
4007
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listSmsMessages({
4008
- client: this.client,
4009
- query: {
4010
- ...query,
4011
- starting_after: cursor ?? query?.starting_after
4012
- },
4013
- headers,
4014
- signal
4015
- }));
4016
- }
4017
4099
  };
4018
4100
  //#endregion
4019
- //#region src/resources/smsTemplates.ts
4101
+ //#region src/resources/smsTemplates.gen.ts
4020
4102
  var SmsTemplatesResource = class extends Resource {
4021
4103
  /**
4022
- * List the SMS templates available to the workspace Bird's built-in
4023
- * templates plus any the workspace authored. The catalogue is small and
4024
- * returned in full (`.data`); this list is not paginated. Filter by `scope`,
4025
- * `category`, or `language` (a BCP-47 language tag).
4104
+ * List the SMS templates available to your workspace, including Bird's built-in templates. Filter by scope, category, or language. The catalogue is small and returned in full; this list is not paginated. Use sms_templates_get to read one template's variables before sending with it.
4026
4105
  *
4027
4106
  * @example List the built-in templates
4028
4107
  * const { data } = await bird.smsTemplates.list({ scope: "system" });
@@ -4037,10 +4116,9 @@ var SmsTemplatesResource = class extends Resource {
4037
4116
  }));
4038
4117
  }
4039
4118
  /**
4040
- * Fetch a single SMS template by its name or id, including its body and the
4041
- * variables it expects.
4119
+ * Get one SMS template by its name or id, including its body and the variables it expects. Fetch it before sms_send to see which parameter keys a template send requires.
4042
4120
  *
4043
- * @example
4121
+ * @example Read one template by name or id
4044
4122
  * const tpl = await bird.smsTemplates.get("bird_otp_verification");
4045
4123
  * console.log(tpl.body, tpl.variables);
4046
4124
  */
@@ -4054,39 +4132,12 @@ var SmsTemplatesResource = class extends Resource {
4054
4132
  }
4055
4133
  };
4056
4134
  //#endregion
4057
- //#region src/resources/whatsapp.ts
4058
- var WhatsappResource = class extends Resource {
4135
+ //#region src/resources/whatsapp.gen.ts
4136
+ var WhatsappResourceBase = class extends Resource {
4059
4137
  /**
4060
- * Send a template message. Bird selects the sender number from the
4061
- * template's category, so there is no sender field on the request. The
4062
- * result is `accepted`, not yet delivered — read it back with `get` to
4063
- * confirm.
4138
+ * Get one WhatsApp message by id: current delivery status, sent/delivered/read timestamps, the template it was sent from, and failure detail if it failed. For the per-event timeline use whatsapp_list_events.
4064
4139
  *
4065
- * @example
4066
- * const msg = await bird.whatsapp.send({
4067
- * to: "+15551234567",
4068
- * template: {
4069
- * name: "bird_otp",
4070
- * components: [
4071
- * { type: "body", parameters: [{ type: "text", text: "123456" }] },
4072
- * ],
4073
- * },
4074
- * });
4075
- * console.log(msg.id, msg.status);
4076
- */
4077
- send(params, options) {
4078
- return this.call("POST", options, ({ signal, headers }) => sendWhatsAppMessage({
4079
- client: this.client,
4080
- body: params,
4081
- headers,
4082
- signal
4083
- }));
4084
- }
4085
- /**
4086
- * Fetch a single WhatsApp message: its current delivery status and failure
4087
- * detail if it failed.
4088
- *
4089
- * @example
4140
+ * @example Read a message back
4090
4141
  * const msg = await bird.whatsapp.get("wa_abc123");
4091
4142
  * msg.status; // "accepted" | "delivered" | …
4092
4143
  */
@@ -4099,11 +4150,9 @@ var WhatsappResource = class extends Resource {
4099
4150
  }));
4100
4151
  }
4101
4152
  /**
4102
- * List WhatsApp messages, newest first. `await` resolves the first page;
4103
- * `for await` walks every message across all pages. Filter by status,
4104
- * recipient phone number, or business-scoped user ID.
4153
+ * List WhatsApp messages, newest first, as a cursor page ({data, next_cursor, …}). Pass next_cursor back as starting_after to fetch the next page. Filter by status, contact phone number, bsuid, or tag. Use whatsapp_get for one message's current state.
4105
4154
  *
4106
- * @example
4155
+ * @example Iterate delivered messages
4107
4156
  * for await (const msg of bird.whatsapp.list({ status: ["delivered"] })) {
4108
4157
  * console.log(msg.id, msg.status);
4109
4158
  * }
@@ -4120,11 +4169,9 @@ var WhatsappResource = class extends Resource {
4120
4169
  }));
4121
4170
  }
4122
4171
  /**
4123
- * List a WhatsApp message's lifecycle event timeline, in chronological
4124
- * order. The timeline is bounded and returned in full — this list is not
4125
- * paginated.
4172
+ * Get one WhatsApp message's delivery timeline, oldest first: whatsapp.accepted, whatsapp.sent, whatsapp.delivered, whatsapp.read, and whatsapp.failed events, with failure detail on failed events. Not paginated; an unknown message id is a 404. Use whatsapp_get for the condensed current status.
4126
4173
  *
4127
- * @example
4174
+ * @example Read one message's delivery timeline
4128
4175
  * const { data } = await bird.whatsapp.listEvents("wa_abc123");
4129
4176
  * for (const event of data) console.log(event.type, event.occurred_at);
4130
4177
  */
@@ -4139,36 +4186,42 @@ var WhatsappResource = class extends Resource {
4139
4186
  }
4140
4187
  };
4141
4188
  //#endregion
4142
- //#region src/resources/whatsappTemplates.ts
4143
- var WhatsappTemplatesResource = class extends Resource {
4189
+ //#region src/resources/whatsapp.ts
4190
+ var WhatsappResource = class extends WhatsappResourceBase {
4144
4191
  /**
4145
- * List the WhatsApp message templates available to the workspace Meta's
4146
- * approved templates for this business account. The catalogue is small and
4147
- * returned in full (`.data`); this list is not paginated.
4192
+ * Send a template message. Bird selects the sender number from the
4193
+ * template's category, so there is no sender field on the request. The
4194
+ * result is `accepted`, not yet delivered read it back with `get` to
4195
+ * confirm.
4148
4196
  *
4149
4197
  * @example
4150
- * const { data } = await bird.whatsappTemplates.list();
4151
- * for (const tpl of data) console.log(tpl.name, tpl.status);
4198
+ * const msg = await bird.whatsapp.send({
4199
+ * to: "+15551234567",
4200
+ * template: {
4201
+ * name: "bird_otp",
4202
+ * components: [
4203
+ * { type: "body", parameters: [{ type: "text", text: "123456" }] },
4204
+ * ],
4205
+ * },
4206
+ * });
4207
+ * console.log(msg.id, msg.status);
4152
4208
  */
4153
- list(options) {
4154
- return this.call("GET", options, ({ signal, headers }) => listWhatsAppTemplates({
4209
+ send(params, options) {
4210
+ return this.call("POST", options, ({ signal, headers }) => sendWhatsAppMessage({
4155
4211
  client: this.client,
4212
+ body: params,
4156
4213
  headers,
4157
4214
  signal
4158
4215
  }));
4159
4216
  }
4160
4217
  };
4161
4218
  //#endregion
4162
- //#region src/resources/verify.ts
4163
- var VerificationsResource = class extends Resource {
4219
+ //#region src/resources/verifyVerifications.gen.ts
4220
+ var VerifyVerificationsResource = class extends Resource {
4164
4221
  /**
4165
- * Start a verification and send a one-time passcode to the recipient in `to`
4166
- * (a `phone_number` over SMS, an `email_address` over email, or both). Calling
4167
- * again for the same recipient re-sends the code after the cooldown rather than
4168
- * starting a second verification. The passcode is never returned — submit the
4169
- * recipient's entry with `check`.
4222
+ * Start a verification: generate a one-time passcode and send it to the recipient in `to` (a phone number over SMS, an email address over email, or both; with both, it is sent over one channel and fails over to the other, not to both at once). Calling again for the same recipient reuses the in-progress verification and sends a fresh code after the resend cooldown; it does not start a second one, so use this both to send and to resend. The passcode is never returned; submit what the recipient enters with verify_verifications_check. SMS delivery draws on the workspace's SMS balance.
4170
4223
  *
4171
- * @example Start over SMS
4224
+ * @example Start a verification over SMS
4172
4225
  * const verification = await bird.verify.verifications.create({
4173
4226
  * to: { phone_number: "+15551234567" },
4174
4227
  * });
@@ -4183,12 +4236,9 @@ var VerificationsResource = class extends Resource {
4183
4236
  }));
4184
4237
  }
4185
4238
  /**
4186
- * Check a passcode the recipient submitted. Identify the verification by the same
4187
- * `to` recipient used to start it — no id needed. A wrong or expired code resolves
4188
- * with `success: false` and a `reason`, not an error; a verification already
4189
- * resolved is no longer checkable and returns a 404 error.
4239
+ * Check a passcode a recipient submitted. Identify the verification by the same `to` recipient used to start it; no verification id needed. A wrong or expired code returns HTTP 200 with `success: false` and a `reason` (for example `incorrect_code` or `expired`), not an error. A verification that has already reached a final state is no longer checkable and returns 404, as does a missing verification; malformed input or rate limiting is also an error status.
4190
4240
  *
4191
- * @example
4241
+ * @example Check a submitted passcode
4192
4242
  * const result = await bird.verify.verifications.check({
4193
4243
  * to: { phone_number: "+15551234567" },
4194
4244
  * code: "123456",
@@ -4204,11 +4254,13 @@ var VerificationsResource = class extends Resource {
4204
4254
  }));
4205
4255
  }
4206
4256
  };
4257
+ //#endregion
4258
+ //#region src/resources/verify.ts
4207
4259
  /** The Verify product namespace — holds the `verifications` collection. */
4208
4260
  var VerifyResource = class {
4209
4261
  verifications;
4210
4262
  constructor(...args) {
4211
- this.verifications = new VerificationsResource(...args);
4263
+ this.verifications = new VerifyVerificationsResource(...args);
4212
4264
  }
4213
4265
  };
4214
4266
  //#endregion
@@ -4273,26 +4325,43 @@ function toHeaderRecord(headers) {
4273
4325
  return headers instanceof Headers ? Object.fromEntries(headers) : headers;
4274
4326
  }
4275
4327
  //#endregion
4276
- //#region src/resources/mailbox.ts
4277
- var MailboxResource = class extends Resource {
4328
+ //#region src/resources/mailbox.gen.ts
4329
+ var MailboxResourceBase = class extends Resource {
4330
+ /**
4331
+ * List the workspace's mailboxes as a cursor page, newest first. Search addresses and display names with q, or filter by exact address, state, or domain.
4332
+ *
4333
+ * @example List mailboxes
4334
+ * for await (const mailbox of bird.mailbox.list()) {
4335
+ * console.log(mailbox.address);
4336
+ * }
4337
+ */
4338
+ list(query, options) {
4339
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxes({
4340
+ client: this.client,
4341
+ query: {
4342
+ ...query,
4343
+ starting_after: cursor ?? query?.starting_after
4344
+ },
4345
+ headers,
4346
+ signal
4347
+ }));
4348
+ }
4278
4349
  /**
4279
- * Create a mailbox. Omit `local_part` to auto-generate a handle on inbox.ai.
4350
+ * Create a mailbox a durable agent identity that owns an email address, groups mail into threads, and remembers conversations for its retention tier.
4280
4351
  *
4281
4352
  * @example Create a mailbox
4282
4353
  * const mailbox = await bird.mailbox.create({ display_name: "Support" });
4283
4354
  * console.log(mailbox.address); // "abc123@inbox.ai"
4284
4355
  */
4285
- create(params, options) {
4356
+ create(params = {}, options) {
4286
4357
  return this.call("POST", options, ({ signal, headers }) => createMailbox({
4287
4358
  client: this.client,
4288
- body: params ?? {},
4359
+ body: params,
4289
4360
  headers,
4290
4361
  signal
4291
4362
  }));
4292
4363
  }
4293
4364
  /**
4294
- * Get a mailbox by id.
4295
- *
4296
4365
  * @example Get a mailbox
4297
4366
  * const mailbox = await bird.mailbox.get("mbx_01abc");
4298
4367
  * console.log(mailbox.state); // "active"
@@ -4306,22 +4375,26 @@ var MailboxResource = class extends Resource {
4306
4375
  }));
4307
4376
  }
4308
4377
  /**
4309
- * Update a mailbox. Only the fields you provide change.
4378
+ * Update a mailbox's display name, reply-to, receive policy, retention tier, contact, or metadata. Lowering the retention tier onto remembered messages older than the new horizon requires confirm=true.
4310
4379
  *
4311
- * @example Update receive policy
4312
- * const mailbox = await bird.mailbox.update("mbx_01abc", { receive_policy: "open" });
4380
+ * @example Change a mailbox's receive policy
4381
+ * const mailbox = await bird.mailbox.update("mbx_01abc", {
4382
+ * receive_policy: "open",
4383
+ * });
4384
+ * console.log(mailbox.id, mailbox.receive_policy);
4313
4385
  */
4314
- update(mailboxId, params, options) {
4386
+ update(mailboxId, params = {}, query, options) {
4315
4387
  return this.call("PATCH", options, ({ signal, headers }) => updateMailbox({
4316
4388
  client: this.client,
4317
4389
  path: { mailbox_id: mailboxId },
4318
4390
  body: params,
4391
+ query,
4319
4392
  headers,
4320
4393
  signal
4321
4394
  }));
4322
4395
  }
4323
4396
  /**
4324
- * Soft-delete a mailbox. It can be restored within 30 days.
4397
+ * Delete a mailbox. The address stops receiving immediately and is quarantined; the mailbox and its remembered messages stay restorable for 30 days via the restore endpoint, then are permanently deleted.
4325
4398
  *
4326
4399
  * @example Delete a mailbox
4327
4400
  * await bird.mailbox.delete("mbx_01abc");
@@ -4335,10 +4408,11 @@ var MailboxResource = class extends Resource {
4335
4408
  }));
4336
4409
  }
4337
4410
  /**
4338
- * Restore a deleted mailbox within its 30-day window.
4411
+ * Restore a mailbox deleted less than 30 days ago: the address starts receiving again and the remembered messages are back. Past the window the mailbox is permanently deleted and returns 404; a mailbox that is not deleted returns 409.
4339
4412
  *
4340
- * @example Restore a mailbox
4413
+ * @example Restore a deleted mailbox
4341
4414
  * const mailbox = await bird.mailbox.restore("mbx_01abc");
4415
+ * console.log(mailbox.deleted_at); // null
4342
4416
  */
4343
4417
  restore(mailboxId, options) {
4344
4418
  return this.call("POST", options, ({ signal, headers }) => restoreMailbox({
@@ -4349,10 +4423,11 @@ var MailboxResource = class extends Resource {
4349
4423
  }));
4350
4424
  }
4351
4425
  /**
4352
- * Reactivate a suspended mailbox.
4426
+ * Reactivate a suspended mailbox so it can send and receive again and its threads become visible. Fails if your plan does not have room for another active mailbox (or another custom inbox.ai handle); delete an active mailbox or upgrade first. A mailbox that is not suspended returns 409.
4353
4427
  *
4354
- * @example Resume a mailbox
4428
+ * @example Resume a suspended mailbox
4355
4429
  * const mailbox = await bird.mailbox.resume("mbx_01abc");
4430
+ * console.log(mailbox.state); // "active"
4356
4431
  */
4357
4432
  resume(mailboxId, options) {
4358
4433
  return this.call("POST", options, ({ signal, headers }) => resumeMailbox({
@@ -4363,8 +4438,6 @@ var MailboxResource = class extends Resource {
4363
4438
  }));
4364
4439
  }
4365
4440
  /**
4366
- * Get email activity statistics for a mailbox.
4367
- *
4368
4441
  * @example Get mailbox stats
4369
4442
  * const stats = await bird.mailbox.stats("mbx_01abc");
4370
4443
  * console.log(stats.summary?.sends_accepted);
@@ -4373,11 +4446,30 @@ var MailboxResource = class extends Resource {
4373
4446
  return this.call("GET", options, ({ signal, headers }) => getMailboxStats({
4374
4447
  client: this.client,
4375
4448
  path: { mailbox_id: mailboxId },
4376
- query: query ?? {},
4449
+ query,
4450
+ headers,
4451
+ signal
4452
+ }));
4453
+ }
4454
+ /**
4455
+ * List the labels available in a mailbox: the built-in system labels (inbox, archive, spam, blocked, sent, trash, unread) plus every custom label in use.
4456
+ *
4457
+ * @example List a mailbox's labels
4458
+ * const labels = await bird.mailbox.labels("mbx_01abc");
4459
+ * console.log(labels.data.map((label) => label.name));
4460
+ */
4461
+ labels(mailboxId, options) {
4462
+ return this.call("GET", options, ({ signal, headers }) => listMailboxLabels({
4463
+ client: this.client,
4464
+ path: { mailbox_id: mailboxId },
4377
4465
  headers,
4378
4466
  signal
4379
4467
  }));
4380
4468
  }
4469
+ };
4470
+ //#endregion
4471
+ //#region src/resources/mailbox.ts
4472
+ var MailboxResource = class extends MailboxResourceBase {
4381
4473
  /**
4382
4474
  * Send a new email from this mailbox, starting a new conversation.
4383
4475
  *
@@ -4397,33 +4489,22 @@ var MailboxResource = class extends Resource {
4397
4489
  signal
4398
4490
  }));
4399
4491
  }
4492
+ };
4493
+ //#endregion
4494
+ //#region src/resources/mailboxReceiveRule.gen.ts
4495
+ var MailboxReceiveRuleResource = class extends Resource {
4400
4496
  /**
4401
- * List labels available in a mailbox.
4402
- *
4403
- * @example List labels
4404
- * const labels = await bird.mailbox.labels("mbx_01abc");
4405
- * console.log(labels.data.map(l => l.name));
4406
- */
4407
- labels(mailboxId, options) {
4408
- return this.call("GET", options, ({ signal, headers }) => listMailboxLabels({
4409
- client: this.client,
4410
- path: { mailbox_id: mailboxId },
4411
- headers,
4412
- signal
4413
- }));
4414
- }
4415
- /**
4416
- * List mailboxes in the workspace. `await` resolves the first page;
4417
- * `for await` walks every mailbox.
4497
+ * List a mailbox's allow/block receive rules as a cursor page, oldest first. Filter by action.
4418
4498
  *
4419
- * @example List mailboxes
4420
- * for await (const mailbox of bird.mailbox.list()) {
4421
- * console.log(mailbox.address);
4499
+ * @example List a mailbox's receive rules
4500
+ * for await (const rule of bird.mailboxReceiveRule.list("mbx_01abc")) {
4501
+ * console.log(rule.action, rule.entry);
4422
4502
  * }
4423
4503
  */
4424
- list(query, options) {
4425
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxes({
4504
+ list(mailboxId, query, options) {
4505
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxReceiveRules({
4426
4506
  client: this.client,
4507
+ path: { mailbox_id: mailboxId },
4427
4508
  query: {
4428
4509
  ...query,
4429
4510
  starting_after: cursor ?? query?.starting_after
@@ -4432,16 +4513,15 @@ var MailboxResource = class extends Resource {
4432
4513
  signal
4433
4514
  }));
4434
4515
  }
4435
- };
4436
- var MailboxReceiveRuleResource = class extends Resource {
4437
4516
  /**
4438
- * Add an allow or block rule to a mailbox. Block rules always win.
4517
+ * Add an allow or block rule for a sender address or domain to a mailbox. Block always wins; up to 200 rules per mailbox.
4439
4518
  *
4440
4519
  * @example Block a domain
4441
4520
  * const rule = await bird.mailboxReceiveRule.create("mbx_01abc", {
4442
4521
  * action: "block",
4443
4522
  * entry: "spam.example.com",
4444
4523
  * });
4524
+ * console.log(rule.id);
4445
4525
  */
4446
4526
  create(mailboxId, params, options) {
4447
4527
  return this.call("POST", options, ({ signal, headers }) => createMailboxReceiveRule({
@@ -4453,7 +4533,7 @@ var MailboxReceiveRuleResource = class extends Resource {
4453
4533
  }));
4454
4534
  }
4455
4535
  /**
4456
- * Remove a receive rule.
4536
+ * Remove a receive rule from a mailbox. Delete-and-recreate is how an entry's action is flipped.
4457
4537
  *
4458
4538
  * @example Delete a rule
4459
4539
  * await bird.mailboxReceiveRule.delete("mbx_01abc", "erl_01xyz");
@@ -4469,18 +4549,21 @@ var MailboxReceiveRuleResource = class extends Resource {
4469
4549
  signal
4470
4550
  }));
4471
4551
  }
4552
+ };
4553
+ //#endregion
4554
+ //#region src/resources/mailboxThread.gen.ts
4555
+ var MailboxThreadResource = class extends Resource {
4472
4556
  /**
4473
- * List receive rules for a mailbox.
4557
+ * List mailbox conversations as a cursor page, most recently active first. `label` selects the view — inbox (default), archive, spam, blocked, or a custom label. Filter by mailbox, contact, participant address, or subject substring.
4474
4558
  *
4475
- * @example List rules
4476
- * for await (const rule of bird.mailboxReceiveRule.list("mbx_01abc")) {
4477
- * console.log(rule.action, rule.entry);
4559
+ * @example List conversation threads
4560
+ * for await (const thread of bird.mailboxThread.list({ mailbox_id: "mbx_01abc" })) {
4561
+ * console.log(thread.id, thread.subject);
4478
4562
  * }
4479
4563
  */
4480
- list(mailboxId, query, options) {
4481
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxReceiveRules({
4564
+ list(query, options) {
4565
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreads({
4482
4566
  client: this.client,
4483
- path: { mailbox_id: mailboxId },
4484
4567
  query: {
4485
4568
  ...query,
4486
4569
  starting_after: cursor ?? query?.starting_after
@@ -4489,16 +4572,12 @@ var MailboxReceiveRuleResource = class extends Resource {
4489
4572
  signal
4490
4573
  }));
4491
4574
  }
4492
- };
4493
- //#endregion
4494
- //#region src/resources/mailboxThread.ts
4495
- var MailboxThreadResource = class extends Resource {
4496
4575
  /**
4497
- * Get a conversation thread.
4576
+ * Get one conversation: participants, counts, labels, read state. Fetch its messages with the thread messages endpoint.
4498
4577
  *
4499
4578
  * @example Get a thread
4500
4579
  * const thread = await bird.mailboxThread.get("thr_01abc");
4501
- * console.log(thread.message_count);
4580
+ * console.log(thread.subject);
4502
4581
  */
4503
4582
  get(threadId, options) {
4504
4583
  return this.call("GET", options, ({ signal, headers }) => getEmailThread({
@@ -4509,14 +4588,15 @@ var MailboxThreadResource = class extends Resource {
4509
4588
  }));
4510
4589
  }
4511
4590
  /**
4512
- * Apply label changes or contact link changes to a thread.
4591
+ * Add or remove labels on a conversation adding `spam` files it as spam, adding `archive` clears it out of the inbox, adding `inbox` brings it back — or link/unlink a contact.
4513
4592
  *
4514
- * @example Archive a thread
4593
+ * @example Apply label changes to a thread
4515
4594
  * const thread = await bird.mailboxThread.update("thr_01abc", {
4516
4595
  * labels: { add: ["archive"] },
4517
4596
  * });
4597
+ * console.log(thread.id);
4518
4598
  */
4519
- update(threadId, params, options) {
4599
+ update(threadId, params = {}, options) {
4520
4600
  return this.call("PATCH", options, ({ signal, headers }) => updateEmailThread({
4521
4601
  client: this.client,
4522
4602
  path: { thread_id: threadId },
@@ -4526,10 +4606,10 @@ var MailboxThreadResource = class extends Resource {
4526
4606
  }));
4527
4607
  }
4528
4608
  /**
4529
- * Move a thread to trash. Pass `query.permanent = true` to delete immediately.
4609
+ * Move a conversation and all its messages to trash (purged after 30 days), or delete permanently with ?permanent=true.
4530
4610
  *
4531
4611
  * @example Delete a thread
4532
- * await bird.mailboxThread.delete("thr_01abc");
4612
+ * await bird.mailboxThread.delete("thr_01abc", { permanent: true });
4533
4613
  */
4534
4614
  delete(threadId, query, options) {
4535
4615
  return this.call("DELETE", options, ({ signal, headers }) => deleteEmailThread({
@@ -4540,18 +4620,22 @@ var MailboxThreadResource = class extends Resource {
4540
4620
  signal
4541
4621
  }));
4542
4622
  }
4623
+ };
4624
+ //#endregion
4625
+ //#region src/resources/mailboxThreadMessage.gen.ts
4626
+ var MailboxThreadMessageResource = class extends Resource {
4543
4627
  /**
4544
- * List threads across the workspace's mailboxes. `await` resolves the first
4545
- * page; `for await` walks every thread.
4628
+ * List the messages in a conversation newest first, both directions. Page older messages with starting_after, and pass include=extracted_text to inline each message's durable plain text.
4546
4629
  *
4547
- * @example List threads in the inbox
4548
- * for await (const thread of bird.mailboxThread.list()) {
4549
- * console.log(thread.id, thread.message_count);
4630
+ * @example List a thread's messages
4631
+ * for await (const msg of bird.mailboxThreadMessage.list("thr_01abc")) {
4632
+ * console.log(msg.id, msg.direction);
4550
4633
  * }
4551
4634
  */
4552
- list(query, options) {
4553
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreads({
4635
+ list(threadId, query, options) {
4636
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreadMessages({
4554
4637
  client: this.client,
4638
+ path: { thread_id: threadId },
4555
4639
  query: {
4556
4640
  ...query,
4557
4641
  starting_after: cursor ?? query?.starting_after
@@ -4560,10 +4644,8 @@ var MailboxThreadResource = class extends Resource {
4560
4644
  signal
4561
4645
  }));
4562
4646
  }
4563
- };
4564
- var MailboxThreadMessageResource = class extends Resource {
4565
4647
  /**
4566
- * Get metadata for a message (not the body; use `body` for that).
4648
+ * Get one conversation message with its extracted plain text — readable for the mailbox's full retention period, no MIME parsing needed.
4567
4649
  *
4568
4650
  * @example Get a message
4569
4651
  * const msg = await bird.mailboxThreadMessage.get("thr_01abc", "rem_01xyz");
@@ -4581,9 +4663,9 @@ var MailboxThreadMessageResource = class extends Resource {
4581
4663
  }));
4582
4664
  }
4583
4665
  /**
4584
- * Get the parsed HTML and plain-text body of a message.
4666
+ * Get the original rendered HTML and plain-text body of a conversation message. Available 30 days; after that use the message's extracted_text.
4585
4667
  *
4586
- * @example Get message body
4668
+ * @example Get a message body
4587
4669
  * const body = await bird.mailboxThreadMessage.body("thr_01abc", "rem_01xyz");
4588
4670
  * console.log(body.text);
4589
4671
  */
@@ -4599,14 +4681,15 @@ var MailboxThreadMessageResource = class extends Resource {
4599
4681
  }));
4600
4682
  }
4601
4683
  /**
4602
- * Reply to a message from the mailbox's own address.
4684
+ * Reply to a specific conversation message from the mailbox's own address. To reply to a conversation, target its newest received message. Recipients, subject, and threading headers are derived automatically.
4603
4685
  *
4604
4686
  * @example Reply to a message
4605
4687
  * const reply = await bird.mailboxThreadMessage.reply("thr_01abc", "rem_01xyz", {
4606
4688
  * text: "Thanks for reaching out!",
4607
4689
  * });
4690
+ * console.log(reply.id);
4608
4691
  */
4609
- reply(threadId, messageId, params, options) {
4692
+ reply(threadId, messageId, params = {}, options) {
4610
4693
  return this.call("POST", options, ({ signal, headers }) => replyEmailThreadMessage({
4611
4694
  client: this.client,
4612
4695
  path: {
@@ -4619,11 +4702,11 @@ var MailboxThreadMessageResource = class extends Resource {
4619
4702
  }));
4620
4703
  }
4621
4704
  /**
4622
- * List the attachment manifest for a message.
4705
+ * List the attachments on a conversation message. Bytes are downloadable for 30 days; the metadata also rides the message's attachment_manifest durably.
4623
4706
  *
4624
- * @example List attachments
4707
+ * @example List a message's attachments
4625
4708
  * const atts = await bird.mailboxThreadMessage.attachments("thr_01abc", "rem_01xyz");
4626
- * console.log(atts.data.map(a => a.filename));
4709
+ * console.log(atts.data.map((a) => a.filename));
4627
4710
  */
4628
4711
  attachments(threadId, messageId, options) {
4629
4712
  return this.call("GET", options, ({ signal, headers }) => listEmailThreadMessageAttachments({
@@ -4636,24 +4719,211 @@ var MailboxThreadMessageResource = class extends Resource {
4636
4719
  signal
4637
4720
  }));
4638
4721
  }
4722
+ };
4723
+ //#endregion
4724
+ //#region src/resources/realtime.ts
4725
+ var RealtimeBase = class extends Resource {
4726
+ #config;
4727
+ constructor(core, client, config) {
4728
+ super(core, client);
4729
+ this.#config = config;
4730
+ }
4731
+ /**
4732
+ * Resolve the app credentials for one call. Called eagerly at the top of each
4733
+ * method so a missing credential throws before the lifecycle starts — never
4734
+ * as a rejected promise after a request is already in flight.
4735
+ */
4736
+ auth(options) {
4737
+ const key = options?.key ?? this.#config?.key;
4738
+ const secret = options?.secret ?? this.#config?.secret;
4739
+ if (!key || !secret) throw new Error("No Realtime app credentials. Set `realtime: { key, secret }` on the client, or pass `{ key, secret }` in the call options.");
4740
+ return {
4741
+ "X-Realtime-Key": key,
4742
+ "X-Realtime-Secret": secret
4743
+ };
4744
+ }
4745
+ };
4746
+ /**
4747
+ * `bird.realtime.channels` — reads the app's live channel state. Channels exist
4748
+ * implicitly: one appears when the first connection subscribes and vanishes when
4749
+ * the last one leaves, so these report occupancy, never existence.
4750
+ */
4751
+ var RealtimeChannelsResource = class extends RealtimeBase {
4752
+ /**
4753
+ * List the app's currently occupied channels, optionally filtered by name
4754
+ * prefix. The Realtime service returns them all in one response — this is a
4755
+ * point read, not a cursor list, so there is nothing to iterate.
4756
+ *
4757
+ * @example List the occupied presence channels with their member counts
4758
+ * const { data } = await bird.realtime.channels.list("rap_01krdgeqcxet5s7t44vh8rt9mg", {
4759
+ * prefix: "presence-",
4760
+ * include: ["member_count"],
4761
+ * });
4762
+ * for (const channel of data) console.log(channel.name, channel.member_count);
4763
+ */
4764
+ list(appId, query, options) {
4765
+ const auth = this.auth(options);
4766
+ return this.call("GET", options, ({ signal, headers }) => listRealtimeAppChannels({
4767
+ client: this.client,
4768
+ path: { realtime_app_id: appId },
4769
+ query,
4770
+ headers: {
4771
+ ...headers,
4772
+ ...auth
4773
+ },
4774
+ signal
4775
+ }));
4776
+ }
4639
4777
  /**
4640
- * List messages in a thread. `await` resolves the first page; `for await`
4641
- * walks every message.
4778
+ * Read one channel's state. An unknown or never-used name is not an error —
4779
+ * it resolves with `occupied: false`.
4642
4780
  *
4643
- * @example List messages
4644
- * for await (const msg of bird.mailboxThreadMessage.list("thr_01abc")) {
4645
- * console.log(msg.id, msg.direction);
4646
- * }
4781
+ * @example Check whether anyone is in a channel
4782
+ * const channel = await bird.realtime.channels.get(
4783
+ * "rap_01krdgeqcxet5s7t44vh8rt9mg",
4784
+ * "presence-lobby",
4785
+ * { include: ["member_count"] },
4786
+ * );
4787
+ * console.log(channel.occupied, channel.member_count);
4647
4788
  */
4648
- list(threadId, query, options) {
4649
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreadMessages({
4789
+ get(appId, channelName, query, options) {
4790
+ const auth = this.auth(options);
4791
+ return this.call("GET", options, ({ signal, headers }) => getRealtimeAppChannel({
4650
4792
  client: this.client,
4651
- path: { thread_id: threadId },
4652
- query: {
4653
- ...query,
4654
- starting_after: cursor ?? query?.starting_after
4793
+ path: {
4794
+ realtime_app_id: appId,
4795
+ channel_name: channelName
4796
+ },
4797
+ query,
4798
+ headers: {
4799
+ ...headers,
4800
+ ...auth
4801
+ },
4802
+ signal
4803
+ }));
4804
+ }
4805
+ /**
4806
+ * List the member ids subscribed to a presence channel. Ids only — the
4807
+ * `member_info` your authorization endpoint attaches is delivered to subscribed
4808
+ * clients over the realtime connection and is not available over REST.
4809
+ *
4810
+ * @example Who is in the lobby
4811
+ * const { members } = await bird.realtime.channels.members(
4812
+ * "rap_01krdgeqcxet5s7t44vh8rt9mg",
4813
+ * "presence-lobby",
4814
+ * );
4815
+ * for (const member of members) console.log(member.member_id);
4816
+ */
4817
+ members(appId, channelName, options) {
4818
+ const auth = this.auth(options);
4819
+ return this.call("GET", options, ({ signal, headers }) => listRealtimeAppChannelMembers({
4820
+ client: this.client,
4821
+ path: {
4822
+ realtime_app_id: appId,
4823
+ channel_name: channelName
4824
+ },
4825
+ headers: {
4826
+ ...headers,
4827
+ ...auth
4828
+ },
4829
+ signal
4830
+ }));
4831
+ }
4832
+ };
4833
+ /** `bird.realtime.members` — acts on a member across all of its connections. */
4834
+ var RealtimeMembersResource = class extends RealtimeBase {
4835
+ /**
4836
+ * Disconnect every active connection a member holds — sign-out, ban, or a
4837
+ * revoked session. Resolves once the disconnect is applied; the member may
4838
+ * reconnect immediately unless your authorization endpoint refuses them.
4839
+ *
4840
+ * @example Kick a member off every connection
4841
+ * await bird.realtime.members.disconnect("rap_01krdgeqcxet5s7t44vh8rt9mg", "user_42");
4842
+ */
4843
+ disconnect(appId, memberId, options) {
4844
+ const auth = this.auth(options);
4845
+ return this.call("POST", options, ({ signal, headers }) => disconnectRealtimeAppMember({
4846
+ client: this.client,
4847
+ path: {
4848
+ realtime_app_id: appId,
4849
+ member_id: memberId
4850
+ },
4851
+ headers: {
4852
+ ...headers,
4853
+ ...auth
4854
+ },
4855
+ signal
4856
+ }));
4857
+ }
4858
+ };
4859
+ /**
4860
+ * `bird.realtime` — publish events to a Realtime app's channels and inspect its
4861
+ * live state. Every method needs the app's key/secret pair: set it once as
4862
+ * `realtime: { key, secret }` on the client, or pass `{ key, secret }` in a
4863
+ * call's options to reach a different app. Reached as `bird.realtime.*`.
4864
+ */
4865
+ var RealtimeResource = class extends RealtimeBase {
4866
+ /** Channel state — `bird.realtime.channels.list(...)`, `.get(...)`, `.members(...)`. */
4867
+ channels;
4868
+ /** Members — `bird.realtime.members.disconnect(...)`. */
4869
+ members;
4870
+ constructor(core, client, config) {
4871
+ super(core, client, config);
4872
+ this.channels = new RealtimeChannelsResource(core, client, config);
4873
+ this.members = new RealtimeMembersResource(core, client, config);
4874
+ }
4875
+ /**
4876
+ * Publish one event to one or more of the app's channels. Listing several
4877
+ * channels broadcasts the same event to all of them in a single call. Resolves
4878
+ * once the event is accepted — delivery to connected clients is asynchronous.
4879
+ *
4880
+ * Pass `exclude_connection_id` to skip the connection that triggered the
4881
+ * change, so the originating client doesn't echo its own update.
4882
+ *
4883
+ * @example Broadcast an event to a channel
4884
+ * const result = await bird.realtime.publish("rap_01krdgeqcxet5s7t44vh8rt9mg", {
4885
+ * event: "order.updated",
4886
+ * channels: ["orders", "presence-lobby"],
4887
+ * data: { order_id: "ord_123", status: "shipped" },
4888
+ * });
4889
+ * console.log(result.data?.length); // one entry per channel
4890
+ */
4891
+ publish(appId, params, options) {
4892
+ const auth = this.auth(options);
4893
+ return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppEvent({
4894
+ client: this.client,
4895
+ path: { realtime_app_id: appId },
4896
+ body: params,
4897
+ headers: {
4898
+ ...headers,
4899
+ ...auth
4900
+ },
4901
+ signal
4902
+ }));
4903
+ }
4904
+ /**
4905
+ * Publish up to 10 events in one request, each to a single channel. Use it to
4906
+ * fan different events out at once; to send the *same* event to many channels,
4907
+ * use `publish` with several `channels` instead.
4908
+ *
4909
+ * @example Publish two events in one call
4910
+ * await bird.realtime.publishBatch("rap_01krdgeqcxet5s7t44vh8rt9mg", {
4911
+ * events: [
4912
+ * { event: "order.created", channel: "orders", data: { id: 1 } },
4913
+ * { event: "order.updated", channel: "orders", data: { id: 2 } },
4914
+ * ],
4915
+ * });
4916
+ */
4917
+ publishBatch(appId, params, options) {
4918
+ const auth = this.auth(options);
4919
+ return this.call("POST", options, ({ signal, headers }) => publishRealtimeAppBatch({
4920
+ client: this.client,
4921
+ path: { realtime_app_id: appId },
4922
+ body: params,
4923
+ headers: {
4924
+ ...headers,
4925
+ ...auth
4655
4926
  },
4656
- headers,
4657
4927
  signal
4658
4928
  }));
4659
4929
  }
@@ -4720,8 +4990,6 @@ var BirdClient = class {
4720
4990
  smsTemplates;
4721
4991
  /** The WhatsApp channel — `bird.whatsapp.send(...)`, `.get(...)`, `.list(...)`, `.listEvents(...)`. */
4722
4992
  whatsapp;
4723
- /** WhatsApp templates — `bird.whatsappTemplates.list(...)`. */
4724
- whatsappTemplates;
4725
4993
  /** The Verify product — `bird.verify.verifications.create(...)`, `.check(...)`. */
4726
4994
  verify;
4727
4995
  /** Contacts — `bird.contacts.create(...)`, `.list(...)`, `.get(...)`, `.batch(...)`, … */
@@ -4742,6 +5010,8 @@ var BirdClient = class {
4742
5010
  mailboxThread;
4743
5011
  /** Thread messages — `bird.mailboxThreadMessage.list(...)`, `.get(...)`, `.reply(...)`, `.body(...)`, … */
4744
5012
  mailboxThreadMessage;
5013
+ /** Realtime — `bird.realtime.publish(...)`, `.channels.list(...)`, `.members.disconnect(...)`, … */
5014
+ realtime;
4745
5015
  constructor(options) {
4746
5016
  const opts = options;
4747
5017
  this.#baseUrl = resolveBaseUrl(opts);
@@ -4749,9 +5019,9 @@ var BirdClient = class {
4749
5019
  this.#headers = {
4750
5020
  ...opts.defaultHeaders,
4751
5021
  Authorization: `Bearer ${opts.apiKey}`,
4752
- "User-Agent": `bird-sdk-js/0.12.2`,
5022
+ "User-Agent": `bird-sdk-js/0.14.0`,
4753
5023
  "Bird-Surface": "sdk-js",
4754
- "Bird-Version": "0.12.2"
5024
+ "Bird-Version": "0.14.0"
4755
5025
  };
4756
5026
  const caller = detectCaller();
4757
5027
  if (caller) this.#headers["Bird-Caller"] = caller;
@@ -4768,7 +5038,6 @@ var BirdClient = class {
4768
5038
  this.sms = new SmsResource(this.core, this.#client);
4769
5039
  this.smsTemplates = new SmsTemplatesResource(this.core, this.#client);
4770
5040
  this.whatsapp = new WhatsappResource(this.core, this.#client);
4771
- this.whatsappTemplates = new WhatsappTemplatesResource(this.core, this.#client);
4772
5041
  this.verify = new VerifyResource(this.core, this.#client);
4773
5042
  this.contacts = new ContactsResource(this.core, this.#client);
4774
5043
  this.audiences = new AudiencesResource(this.core, this.#client);
@@ -4779,6 +5048,7 @@ var BirdClient = class {
4779
5048
  this.mailboxReceiveRule = new MailboxReceiveRuleResource(this.core, this.#client);
4780
5049
  this.mailboxThread = new MailboxThreadResource(this.core, this.#client);
4781
5050
  this.mailboxThreadMessage = new MailboxThreadMessageResource(this.core, this.#client);
5051
+ this.realtime = new RealtimeResource(this.core, this.#client, opts.realtime);
4782
5052
  }
4783
5053
  /**
4784
5054
  * Escape hatch for endpoints the typed resources don't cover. Runs the full
@@ -4862,11 +5132,6 @@ const WebhookEventType = {
4862
5132
  EmailScheduled: "email.scheduled",
4863
5133
  EmailSuppressionCreated: "email_suppression.created",
4864
5134
  EmailUnsubscribed: "email.unsubscribed",
4865
- RealtimeCacheChannels: "realtime.cache_channels",
4866
- RealtimeChannelExistence: "realtime.channel_existence",
4867
- RealtimeClientEvents: "realtime.client_events",
4868
- RealtimeConnectionCount: "realtime.connection_count",
4869
- RealtimePresence: "realtime.presence",
4870
5135
  SmsAccepted: "sms.accepted",
4871
5136
  SmsDelivered: "sms.delivered",
4872
5137
  SmsExpired: "sms.expired",