@messagebird/sdk 0.12.1 → 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,49 +3770,49 @@ 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({
3712
3783
  client: this.client,
3713
3784
  path: { domain_id: domainId },
3785
+ body: params,
3714
3786
  headers,
3715
3787
  signal
3716
3788
  }));
3717
3789
  }
3718
- };
3719
- //#endregion
3720
- //#region src/resources/contactProperties.ts
3721
- var ContactPropertiesResource = class extends Resource {
3722
3790
  /**
3723
- * Define a contact property. The `key` must be unique in the workspace and is
3724
- * how contacts reference the field in their `data`.
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.
3725
3792
  *
3726
- * @example
3727
- * const prop = await bird.contactProperties.create({ key: "plan", type: "string" });
3728
- * console.log(prop.id); // "cp_…"
3793
+ * @example Delete a sending domain by id
3794
+ * await bird.domains.delete("dom_01krdgeqcxet5s7t44vh8rt9mg");
3729
3795
  */
3730
- create(params, options) {
3731
- return this.call("POST", options, ({ signal, headers }) => createContactProperty({
3796
+ delete(domainId, options) {
3797
+ return this.call("DELETE", options, ({ signal, headers }) => deleteDomain({
3732
3798
  client: this.client,
3733
- body: params,
3799
+ path: { domain_id: domainId },
3734
3800
  headers,
3735
3801
  signal
3736
3802
  }));
3737
3803
  }
3804
+ };
3805
+ //#endregion
3806
+ //#region src/resources/contactProperties.gen.ts
3807
+ var ContactPropertiesResource = class extends Resource {
3738
3808
  /**
3739
- * List the workspace's contact properties. `await` resolves the first page;
3740
- * `for await` walks every property across pages.
3809
+ * List the workspace's contact properties as a cursor page, newest first. Archived properties are included, marked by their archived flag.
3741
3810
  *
3742
- * @example
3811
+ * @example Iterate every contact property, or take one page
3743
3812
  * for await (const prop of bird.contactProperties.list()) {
3744
3813
  * console.log(prop.key, prop.type);
3745
3814
  * }
3815
+ * const page = await bird.contactProperties.list({ limit: 50 }); // page.data, page.next_cursor
3746
3816
  */
3747
3817
  list(query, options) {
3748
3818
  return this.paginated("GET", options, ({ signal, headers }, cursor) => listContactProperties({
@@ -3756,10 +3826,11 @@ var ContactPropertiesResource = class extends Resource {
3756
3826
  }));
3757
3827
  }
3758
3828
  /**
3759
- * Fetch a single contact property by id.
3829
+ * Get a single contact property by ID: key, type, fallback value, and archived state.
3760
3830
  *
3761
- * @example
3831
+ * @example Fetch a contact property by id
3762
3832
  * const prop = await bird.contactProperties.get("cp_01krdgeqcxet5s7t44vh8rt9mg");
3833
+ * console.log(prop.key, prop.type);
3763
3834
  */
3764
3835
  get(propertyId, options) {
3765
3836
  return this.call("GET", options, ({ signal, headers }) => getContactProperty({
@@ -3770,12 +3841,27 @@ var ContactPropertiesResource = class extends Resource {
3770
3841
  }));
3771
3842
  }
3772
3843
  /**
3773
- * Update a contact property. Only the fields you send change.
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.
3774
3845
  *
3775
- * @example
3846
+ * @example Define a custom property
3847
+ * const prop = await bird.contactProperties.create({ key: "plan", type: "string" });
3848
+ * console.log(prop.id); // "cp_…"
3849
+ */
3850
+ create(params, options) {
3851
+ return this.call("POST", options, ({ signal, headers }) => createContactProperty({
3852
+ client: this.client,
3853
+ body: params,
3854
+ headers,
3855
+ signal
3856
+ }));
3857
+ }
3858
+ /**
3859
+ * Update a contact property's fallback value. The key and type are immutable; create a new property instead.
3860
+ *
3861
+ * @example Change a property's fallback value
3776
3862
  * await bird.contactProperties.update("cp_01krdgeqcxet5s7t44vh8rt9mg", { fallback_value: "free" });
3777
3863
  */
3778
- update(propertyId, params, options) {
3864
+ update(propertyId, params = {}, options) {
3779
3865
  return this.call("PATCH", options, ({ signal, headers }) => updateContactProperty({
3780
3866
  client: this.client,
3781
3867
  path: { property_id: propertyId },
@@ -3785,10 +3871,11 @@ var ContactPropertiesResource = class extends Resource {
3785
3871
  }));
3786
3872
  }
3787
3873
  /**
3788
- * Archive a contact property, retiring the field without deleting its 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`.
3789
3875
  *
3790
- * @example
3791
- * await bird.contactProperties.archive("cp_01krdgeqcxet5s7t44vh8rt9mg");
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);
3792
3879
  */
3793
3880
  archive(propertyId, options) {
3794
3881
  return this.call("POST", options, ({ signal, headers }) => archiveContactProperty({
@@ -3799,9 +3886,9 @@ var ContactPropertiesResource = class extends Resource {
3799
3886
  }));
3800
3887
  }
3801
3888
  /**
3802
- * Restore an archived contact property.
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.
3803
3890
  *
3804
- * @example
3891
+ * @example Restore an archived property
3805
3892
  * await bird.contactProperties.unarchive("cp_01krdgeqcxet5s7t44vh8rt9mg");
3806
3893
  */
3807
3894
  unarchive(propertyId, options) {
@@ -3815,7 +3902,7 @@ var ContactPropertiesResource = class extends Resource {
3815
3902
  };
3816
3903
  //#endregion
3817
3904
  //#region src/resources/contacts.gen.ts
3818
- var ContactsResourceBase = class extends Resource {
3905
+ var ContactsResource = class extends Resource {
3819
3906
  /**
3820
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.
3821
3908
  *
@@ -3870,48 +3957,47 @@ var ContactsResourceBase = class extends Resource {
3870
3957
  }));
3871
3958
  }
3872
3959
  /**
3873
- * 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.
3874
3961
  *
3875
- * @example Delete a contact by id
3876
- * 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);
3877
3967
  */
3878
- delete(contactId, options) {
3879
- return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
3968
+ update(contactId, params = {}, options) {
3969
+ return this.call("PATCH", options, ({ signal, headers }) => updateContact({
3880
3970
  client: this.client,
3881
3971
  path: { contact_id: contactId },
3972
+ body: params,
3882
3973
  headers,
3883
3974
  signal
3884
3975
  }));
3885
3976
  }
3886
- };
3887
- //#endregion
3888
- //#region src/resources/contacts.ts
3889
- var ContactsResource = class extends ContactsResourceBase {
3890
3977
  /**
3891
- * 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.
3892
3979
  *
3893
- * @example
3894
- * const contact = await bird.contacts.update("con_01krdgeqcxet5s7t44vh8rt9mg", {
3895
- * first_name: "Jane",
3896
- * });
3980
+ * @example Delete a contact by id
3981
+ * await bird.contacts.delete("con_01krdgeqcxet5s7t44vh8rt9mg");
3897
3982
  */
3898
- update(contactId, params, options) {
3899
- return this.call("PATCH", options, ({ signal, headers }) => updateContact({
3983
+ delete(contactId, options) {
3984
+ return this.call("DELETE", options, ({ signal, headers }) => deleteContact({
3900
3985
  client: this.client,
3901
3986
  path: { contact_id: contactId },
3902
- body: params,
3903
3987
  headers,
3904
3988
  signal
3905
3989
  }));
3906
3990
  }
3907
3991
  /**
3908
- * Create or update many contacts in one call, matched by email. Returns a
3909
- * 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.
3910
3993
  *
3911
- * @example
3994
+ * @example Create or update many contacts at once, matched by email
3912
3995
  * const result = await bird.contacts.batch({
3913
3996
  * contacts: [{ email: "jane@acme.com", first_name: "Jane" }],
3914
3997
  * });
3998
+ * for (const item of result.data) {
3999
+ * console.log(item.email, item.status);
4000
+ * }
3915
4001
  */
3916
4002
  batch(params, options) {
3917
4003
  return this.call("POST", options, ({ signal, headers }) => createContactBatch({
@@ -3923,8 +4009,47 @@ var ContactsResource = class extends ContactsResourceBase {
3923
4009
  }
3924
4010
  };
3925
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
3926
4050
  //#region src/resources/sms.ts
3927
- var SmsResource = class extends Resource {
4051
+ /** Filters and cursor params for `bird.sms.list`. */
4052
+ var SmsResource = class extends SmsResourceBase {
3928
4053
  /**
3929
4054
  * Send one SMS to a single recipient. Supply either `text` (with a `category`)
3930
4055
  * or a stored `template` (by `id` or `name`, with its `parameters`). The
@@ -3971,52 +4096,12 @@ var SmsResource = class extends Resource {
3971
4096
  signal
3972
4097
  }));
3973
4098
  }
3974
- /**
3975
- * Fetch a single SMS message: its current delivery status, segment breakdown,
3976
- * cost, and failure detail if it failed.
3977
- *
3978
- * @example
3979
- * const msg = await bird.sms.get("sms_abc123");
3980
- * msg.status; // "accepted" | "delivered" | …
3981
- */
3982
- get(messageId, options) {
3983
- return this.call("GET", options, ({ signal, headers }) => getSmsMessage({
3984
- client: this.client,
3985
- path: { message_id: messageId },
3986
- headers,
3987
- signal
3988
- }));
3989
- }
3990
- /**
3991
- * List SMS messages, newest first. `await` resolves the first page; `for await`
3992
- * walks every message across all pages. Filter by direction, status, category,
3993
- * recipient, sender, or tag.
3994
- *
3995
- * @example
3996
- * for await (const msg of bird.sms.list({ direction: "outbound" })) {
3997
- * console.log(msg.id, msg.status);
3998
- * }
3999
- */
4000
- list(query, options) {
4001
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listSmsMessages({
4002
- client: this.client,
4003
- query: {
4004
- ...query,
4005
- starting_after: cursor ?? query?.starting_after
4006
- },
4007
- headers,
4008
- signal
4009
- }));
4010
- }
4011
4099
  };
4012
4100
  //#endregion
4013
- //#region src/resources/smsTemplates.ts
4101
+ //#region src/resources/smsTemplates.gen.ts
4014
4102
  var SmsTemplatesResource = class extends Resource {
4015
4103
  /**
4016
- * List the SMS templates available to the workspace Bird's built-in
4017
- * templates plus any the workspace authored. The catalogue is small and
4018
- * returned in full (`.data`); this list is not paginated. Filter by `scope`,
4019
- * `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.
4020
4105
  *
4021
4106
  * @example List the built-in templates
4022
4107
  * const { data } = await bird.smsTemplates.list({ scope: "system" });
@@ -4031,10 +4116,9 @@ var SmsTemplatesResource = class extends Resource {
4031
4116
  }));
4032
4117
  }
4033
4118
  /**
4034
- * Fetch a single SMS template by its name or id, including its body and the
4035
- * 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.
4036
4120
  *
4037
- * @example
4121
+ * @example Read one template by name or id
4038
4122
  * const tpl = await bird.smsTemplates.get("bird_otp_verification");
4039
4123
  * console.log(tpl.body, tpl.variables);
4040
4124
  */
@@ -4048,39 +4132,12 @@ var SmsTemplatesResource = class extends Resource {
4048
4132
  }
4049
4133
  };
4050
4134
  //#endregion
4051
- //#region src/resources/whatsapp.ts
4052
- var WhatsappResource = class extends Resource {
4135
+ //#region src/resources/whatsapp.gen.ts
4136
+ var WhatsappResourceBase = class extends Resource {
4053
4137
  /**
4054
- * Send a template message. Bird selects the sender number from the
4055
- * template's category, so there is no sender field on the request. The
4056
- * result is `accepted`, not yet delivered — read it back with `get` to
4057
- * 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.
4058
4139
  *
4059
- * @example
4060
- * const msg = await bird.whatsapp.send({
4061
- * to: "+15551234567",
4062
- * template: {
4063
- * name: "bird_otp",
4064
- * components: [
4065
- * { type: "body", parameters: [{ type: "text", text: "123456" }] },
4066
- * ],
4067
- * },
4068
- * });
4069
- * console.log(msg.id, msg.status);
4070
- */
4071
- send(params, options) {
4072
- return this.call("POST", options, ({ signal, headers }) => sendWhatsAppMessage({
4073
- client: this.client,
4074
- body: params,
4075
- headers,
4076
- signal
4077
- }));
4078
- }
4079
- /**
4080
- * Fetch a single WhatsApp message: its current delivery status and failure
4081
- * detail if it failed.
4082
- *
4083
- * @example
4140
+ * @example Read a message back
4084
4141
  * const msg = await bird.whatsapp.get("wa_abc123");
4085
4142
  * msg.status; // "accepted" | "delivered" | …
4086
4143
  */
@@ -4093,11 +4150,9 @@ var WhatsappResource = class extends Resource {
4093
4150
  }));
4094
4151
  }
4095
4152
  /**
4096
- * List WhatsApp messages, newest first. `await` resolves the first page;
4097
- * `for await` walks every message across all pages. Filter by status,
4098
- * 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.
4099
4154
  *
4100
- * @example
4155
+ * @example Iterate delivered messages
4101
4156
  * for await (const msg of bird.whatsapp.list({ status: ["delivered"] })) {
4102
4157
  * console.log(msg.id, msg.status);
4103
4158
  * }
@@ -4114,11 +4169,9 @@ var WhatsappResource = class extends Resource {
4114
4169
  }));
4115
4170
  }
4116
4171
  /**
4117
- * List a WhatsApp message's lifecycle event timeline, in chronological
4118
- * order. The timeline is bounded and returned in full — this list is not
4119
- * 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.
4120
4173
  *
4121
- * @example
4174
+ * @example Read one message's delivery timeline
4122
4175
  * const { data } = await bird.whatsapp.listEvents("wa_abc123");
4123
4176
  * for (const event of data) console.log(event.type, event.occurred_at);
4124
4177
  */
@@ -4133,36 +4186,42 @@ var WhatsappResource = class extends Resource {
4133
4186
  }
4134
4187
  };
4135
4188
  //#endregion
4136
- //#region src/resources/whatsappTemplates.ts
4137
- var WhatsappTemplatesResource = class extends Resource {
4189
+ //#region src/resources/whatsapp.ts
4190
+ var WhatsappResource = class extends WhatsappResourceBase {
4138
4191
  /**
4139
- * List the WhatsApp message templates available to the workspace Meta's
4140
- * approved templates for this business account. The catalogue is small and
4141
- * 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.
4142
4196
  *
4143
4197
  * @example
4144
- * const { data } = await bird.whatsappTemplates.list();
4145
- * 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);
4146
4208
  */
4147
- list(options) {
4148
- return this.call("GET", options, ({ signal, headers }) => listWhatsAppTemplates({
4209
+ send(params, options) {
4210
+ return this.call("POST", options, ({ signal, headers }) => sendWhatsAppMessage({
4149
4211
  client: this.client,
4212
+ body: params,
4150
4213
  headers,
4151
4214
  signal
4152
4215
  }));
4153
4216
  }
4154
4217
  };
4155
4218
  //#endregion
4156
- //#region src/resources/verify.ts
4157
- var VerificationsResource = class extends Resource {
4219
+ //#region src/resources/verifyVerifications.gen.ts
4220
+ var VerifyVerificationsResource = class extends Resource {
4158
4221
  /**
4159
- * Start a verification and send a one-time passcode to the recipient in `to`
4160
- * (a `phone_number` over SMS, an `email_address` over email, or both). Calling
4161
- * again for the same recipient re-sends the code after the cooldown rather than
4162
- * starting a second verification. The passcode is never returned — submit the
4163
- * 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.
4164
4223
  *
4165
- * @example Start over SMS
4224
+ * @example Start a verification over SMS
4166
4225
  * const verification = await bird.verify.verifications.create({
4167
4226
  * to: { phone_number: "+15551234567" },
4168
4227
  * });
@@ -4177,12 +4236,9 @@ var VerificationsResource = class extends Resource {
4177
4236
  }));
4178
4237
  }
4179
4238
  /**
4180
- * Check a passcode the recipient submitted. Identify the verification by the same
4181
- * `to` recipient used to start it — no id needed. A wrong or expired code resolves
4182
- * with `success: false` and a `reason`, not an error; a verification already
4183
- * 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.
4184
4240
  *
4185
- * @example
4241
+ * @example Check a submitted passcode
4186
4242
  * const result = await bird.verify.verifications.check({
4187
4243
  * to: { phone_number: "+15551234567" },
4188
4244
  * code: "123456",
@@ -4198,11 +4254,13 @@ var VerificationsResource = class extends Resource {
4198
4254
  }));
4199
4255
  }
4200
4256
  };
4257
+ //#endregion
4258
+ //#region src/resources/verify.ts
4201
4259
  /** The Verify product namespace — holds the `verifications` collection. */
4202
4260
  var VerifyResource = class {
4203
4261
  verifications;
4204
4262
  constructor(...args) {
4205
- this.verifications = new VerificationsResource(...args);
4263
+ this.verifications = new VerifyVerificationsResource(...args);
4206
4264
  }
4207
4265
  };
4208
4266
  //#endregion
@@ -4267,26 +4325,43 @@ function toHeaderRecord(headers) {
4267
4325
  return headers instanceof Headers ? Object.fromEntries(headers) : headers;
4268
4326
  }
4269
4327
  //#endregion
4270
- //#region src/resources/mailbox.ts
4271
- var MailboxResource = class extends Resource {
4328
+ //#region src/resources/mailbox.gen.ts
4329
+ var MailboxResourceBase = class extends Resource {
4272
4330
  /**
4273
- * Create a mailbox. Omit `local_part` to auto-generate a handle on inbox.ai.
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
+ }
4349
+ /**
4350
+ * Create a mailbox — a durable agent identity that owns an email address, groups mail into threads, and remembers conversations for its retention tier.
4274
4351
  *
4275
4352
  * @example Create a mailbox
4276
4353
  * const mailbox = await bird.mailbox.create({ display_name: "Support" });
4277
4354
  * console.log(mailbox.address); // "abc123@inbox.ai"
4278
4355
  */
4279
- create(params, options) {
4356
+ create(params = {}, options) {
4280
4357
  return this.call("POST", options, ({ signal, headers }) => createMailbox({
4281
4358
  client: this.client,
4282
- body: params ?? {},
4359
+ body: params,
4283
4360
  headers,
4284
4361
  signal
4285
4362
  }));
4286
4363
  }
4287
4364
  /**
4288
- * Get a mailbox by id.
4289
- *
4290
4365
  * @example Get a mailbox
4291
4366
  * const mailbox = await bird.mailbox.get("mbx_01abc");
4292
4367
  * console.log(mailbox.state); // "active"
@@ -4300,22 +4375,26 @@ var MailboxResource = class extends Resource {
4300
4375
  }));
4301
4376
  }
4302
4377
  /**
4303
- * 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.
4304
4379
  *
4305
- * @example Update receive policy
4306
- * 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);
4307
4385
  */
4308
- update(mailboxId, params, options) {
4386
+ update(mailboxId, params = {}, query, options) {
4309
4387
  return this.call("PATCH", options, ({ signal, headers }) => updateMailbox({
4310
4388
  client: this.client,
4311
4389
  path: { mailbox_id: mailboxId },
4312
4390
  body: params,
4391
+ query,
4313
4392
  headers,
4314
4393
  signal
4315
4394
  }));
4316
4395
  }
4317
4396
  /**
4318
- * 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.
4319
4398
  *
4320
4399
  * @example Delete a mailbox
4321
4400
  * await bird.mailbox.delete("mbx_01abc");
@@ -4329,10 +4408,11 @@ var MailboxResource = class extends Resource {
4329
4408
  }));
4330
4409
  }
4331
4410
  /**
4332
- * 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.
4333
4412
  *
4334
- * @example Restore a mailbox
4413
+ * @example Restore a deleted mailbox
4335
4414
  * const mailbox = await bird.mailbox.restore("mbx_01abc");
4415
+ * console.log(mailbox.deleted_at); // null
4336
4416
  */
4337
4417
  restore(mailboxId, options) {
4338
4418
  return this.call("POST", options, ({ signal, headers }) => restoreMailbox({
@@ -4343,10 +4423,11 @@ var MailboxResource = class extends Resource {
4343
4423
  }));
4344
4424
  }
4345
4425
  /**
4346
- * 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.
4347
4427
  *
4348
- * @example Resume a mailbox
4428
+ * @example Resume a suspended mailbox
4349
4429
  * const mailbox = await bird.mailbox.resume("mbx_01abc");
4430
+ * console.log(mailbox.state); // "active"
4350
4431
  */
4351
4432
  resume(mailboxId, options) {
4352
4433
  return this.call("POST", options, ({ signal, headers }) => resumeMailbox({
@@ -4357,8 +4438,6 @@ var MailboxResource = class extends Resource {
4357
4438
  }));
4358
4439
  }
4359
4440
  /**
4360
- * Get email activity statistics for a mailbox.
4361
- *
4362
4441
  * @example Get mailbox stats
4363
4442
  * const stats = await bird.mailbox.stats("mbx_01abc");
4364
4443
  * console.log(stats.summary?.sends_accepted);
@@ -4367,11 +4446,30 @@ var MailboxResource = class extends Resource {
4367
4446
  return this.call("GET", options, ({ signal, headers }) => getMailboxStats({
4368
4447
  client: this.client,
4369
4448
  path: { mailbox_id: mailboxId },
4370
- 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 },
4371
4465
  headers,
4372
4466
  signal
4373
4467
  }));
4374
4468
  }
4469
+ };
4470
+ //#endregion
4471
+ //#region src/resources/mailbox.ts
4472
+ var MailboxResource = class extends MailboxResourceBase {
4375
4473
  /**
4376
4474
  * Send a new email from this mailbox, starting a new conversation.
4377
4475
  *
@@ -4391,33 +4489,22 @@ var MailboxResource = class extends Resource {
4391
4489
  signal
4392
4490
  }));
4393
4491
  }
4492
+ };
4493
+ //#endregion
4494
+ //#region src/resources/mailboxReceiveRule.gen.ts
4495
+ var MailboxReceiveRuleResource = class extends Resource {
4394
4496
  /**
4395
- * List labels available in a mailbox.
4396
- *
4397
- * @example List labels
4398
- * const labels = await bird.mailbox.labels("mbx_01abc");
4399
- * console.log(labels.data.map(l => l.name));
4400
- */
4401
- labels(mailboxId, options) {
4402
- return this.call("GET", options, ({ signal, headers }) => listMailboxLabels({
4403
- client: this.client,
4404
- path: { mailbox_id: mailboxId },
4405
- headers,
4406
- signal
4407
- }));
4408
- }
4409
- /**
4410
- * List mailboxes in the workspace. `await` resolves the first page;
4411
- * `for await` walks every mailbox.
4497
+ * List a mailbox's allow/block receive rules as a cursor page, oldest first. Filter by action.
4412
4498
  *
4413
- * @example List mailboxes
4414
- * for await (const mailbox of bird.mailbox.list()) {
4415
- * 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);
4416
4502
  * }
4417
4503
  */
4418
- list(query, options) {
4419
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxes({
4504
+ list(mailboxId, query, options) {
4505
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxReceiveRules({
4420
4506
  client: this.client,
4507
+ path: { mailbox_id: mailboxId },
4421
4508
  query: {
4422
4509
  ...query,
4423
4510
  starting_after: cursor ?? query?.starting_after
@@ -4426,16 +4513,15 @@ var MailboxResource = class extends Resource {
4426
4513
  signal
4427
4514
  }));
4428
4515
  }
4429
- };
4430
- var MailboxReceiveRuleResource = class extends Resource {
4431
4516
  /**
4432
- * 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.
4433
4518
  *
4434
4519
  * @example Block a domain
4435
4520
  * const rule = await bird.mailboxReceiveRule.create("mbx_01abc", {
4436
4521
  * action: "block",
4437
4522
  * entry: "spam.example.com",
4438
4523
  * });
4524
+ * console.log(rule.id);
4439
4525
  */
4440
4526
  create(mailboxId, params, options) {
4441
4527
  return this.call("POST", options, ({ signal, headers }) => createMailboxReceiveRule({
@@ -4447,7 +4533,7 @@ var MailboxReceiveRuleResource = class extends Resource {
4447
4533
  }));
4448
4534
  }
4449
4535
  /**
4450
- * Remove a receive rule.
4536
+ * Remove a receive rule from a mailbox. Delete-and-recreate is how an entry's action is flipped.
4451
4537
  *
4452
4538
  * @example Delete a rule
4453
4539
  * await bird.mailboxReceiveRule.delete("mbx_01abc", "erl_01xyz");
@@ -4463,18 +4549,21 @@ var MailboxReceiveRuleResource = class extends Resource {
4463
4549
  signal
4464
4550
  }));
4465
4551
  }
4552
+ };
4553
+ //#endregion
4554
+ //#region src/resources/mailboxThread.gen.ts
4555
+ var MailboxThreadResource = class extends Resource {
4466
4556
  /**
4467
- * 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.
4468
4558
  *
4469
- * @example List rules
4470
- * for await (const rule of bird.mailboxReceiveRule.list("mbx_01abc")) {
4471
- * 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);
4472
4562
  * }
4473
4563
  */
4474
- list(mailboxId, query, options) {
4475
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listMailboxReceiveRules({
4564
+ list(query, options) {
4565
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreads({
4476
4566
  client: this.client,
4477
- path: { mailbox_id: mailboxId },
4478
4567
  query: {
4479
4568
  ...query,
4480
4569
  starting_after: cursor ?? query?.starting_after
@@ -4483,16 +4572,12 @@ var MailboxReceiveRuleResource = class extends Resource {
4483
4572
  signal
4484
4573
  }));
4485
4574
  }
4486
- };
4487
- //#endregion
4488
- //#region src/resources/mailboxThread.ts
4489
- var MailboxThreadResource = class extends Resource {
4490
4575
  /**
4491
- * Get a conversation thread.
4576
+ * Get one conversation: participants, counts, labels, read state. Fetch its messages with the thread messages endpoint.
4492
4577
  *
4493
4578
  * @example Get a thread
4494
4579
  * const thread = await bird.mailboxThread.get("thr_01abc");
4495
- * console.log(thread.message_count);
4580
+ * console.log(thread.subject);
4496
4581
  */
4497
4582
  get(threadId, options) {
4498
4583
  return this.call("GET", options, ({ signal, headers }) => getEmailThread({
@@ -4503,14 +4588,15 @@ var MailboxThreadResource = class extends Resource {
4503
4588
  }));
4504
4589
  }
4505
4590
  /**
4506
- * 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.
4507
4592
  *
4508
- * @example Archive a thread
4593
+ * @example Apply label changes to a thread
4509
4594
  * const thread = await bird.mailboxThread.update("thr_01abc", {
4510
4595
  * labels: { add: ["archive"] },
4511
4596
  * });
4597
+ * console.log(thread.id);
4512
4598
  */
4513
- update(threadId, params, options) {
4599
+ update(threadId, params = {}, options) {
4514
4600
  return this.call("PATCH", options, ({ signal, headers }) => updateEmailThread({
4515
4601
  client: this.client,
4516
4602
  path: { thread_id: threadId },
@@ -4520,10 +4606,10 @@ var MailboxThreadResource = class extends Resource {
4520
4606
  }));
4521
4607
  }
4522
4608
  /**
4523
- * 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.
4524
4610
  *
4525
4611
  * @example Delete a thread
4526
- * await bird.mailboxThread.delete("thr_01abc");
4612
+ * await bird.mailboxThread.delete("thr_01abc", { permanent: true });
4527
4613
  */
4528
4614
  delete(threadId, query, options) {
4529
4615
  return this.call("DELETE", options, ({ signal, headers }) => deleteEmailThread({
@@ -4534,18 +4620,22 @@ var MailboxThreadResource = class extends Resource {
4534
4620
  signal
4535
4621
  }));
4536
4622
  }
4623
+ };
4624
+ //#endregion
4625
+ //#region src/resources/mailboxThreadMessage.gen.ts
4626
+ var MailboxThreadMessageResource = class extends Resource {
4537
4627
  /**
4538
- * List threads across the workspace's mailboxes. `await` resolves the first
4539
- * 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.
4540
4629
  *
4541
- * @example List threads in the inbox
4542
- * for await (const thread of bird.mailboxThread.list()) {
4543
- * 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);
4544
4633
  * }
4545
4634
  */
4546
- list(query, options) {
4547
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreads({
4635
+ list(threadId, query, options) {
4636
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreadMessages({
4548
4637
  client: this.client,
4638
+ path: { thread_id: threadId },
4549
4639
  query: {
4550
4640
  ...query,
4551
4641
  starting_after: cursor ?? query?.starting_after
@@ -4554,10 +4644,8 @@ var MailboxThreadResource = class extends Resource {
4554
4644
  signal
4555
4645
  }));
4556
4646
  }
4557
- };
4558
- var MailboxThreadMessageResource = class extends Resource {
4559
4647
  /**
4560
- * 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.
4561
4649
  *
4562
4650
  * @example Get a message
4563
4651
  * const msg = await bird.mailboxThreadMessage.get("thr_01abc", "rem_01xyz");
@@ -4575,9 +4663,9 @@ var MailboxThreadMessageResource = class extends Resource {
4575
4663
  }));
4576
4664
  }
4577
4665
  /**
4578
- * 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.
4579
4667
  *
4580
- * @example Get message body
4668
+ * @example Get a message body
4581
4669
  * const body = await bird.mailboxThreadMessage.body("thr_01abc", "rem_01xyz");
4582
4670
  * console.log(body.text);
4583
4671
  */
@@ -4593,14 +4681,15 @@ var MailboxThreadMessageResource = class extends Resource {
4593
4681
  }));
4594
4682
  }
4595
4683
  /**
4596
- * 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.
4597
4685
  *
4598
4686
  * @example Reply to a message
4599
4687
  * const reply = await bird.mailboxThreadMessage.reply("thr_01abc", "rem_01xyz", {
4600
4688
  * text: "Thanks for reaching out!",
4601
4689
  * });
4690
+ * console.log(reply.id);
4602
4691
  */
4603
- reply(threadId, messageId, params, options) {
4692
+ reply(threadId, messageId, params = {}, options) {
4604
4693
  return this.call("POST", options, ({ signal, headers }) => replyEmailThreadMessage({
4605
4694
  client: this.client,
4606
4695
  path: {
@@ -4613,11 +4702,11 @@ var MailboxThreadMessageResource = class extends Resource {
4613
4702
  }));
4614
4703
  }
4615
4704
  /**
4616
- * 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.
4617
4706
  *
4618
- * @example List attachments
4707
+ * @example List a message's attachments
4619
4708
  * const atts = await bird.mailboxThreadMessage.attachments("thr_01abc", "rem_01xyz");
4620
- * console.log(atts.data.map(a => a.filename));
4709
+ * console.log(atts.data.map((a) => a.filename));
4621
4710
  */
4622
4711
  attachments(threadId, messageId, options) {
4623
4712
  return this.call("GET", options, ({ signal, headers }) => listEmailThreadMessageAttachments({
@@ -4630,24 +4719,211 @@ var MailboxThreadMessageResource = class extends Resource {
4630
4719
  signal
4631
4720
  }));
4632
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 {
4633
4752
  /**
4634
- * List messages in a thread. `await` resolves the first page; `for await`
4635
- * walks every message.
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.
4636
4756
  *
4637
- * @example List messages
4638
- * for await (const msg of bird.mailboxThreadMessage.list("thr_01abc")) {
4639
- * console.log(msg.id, msg.direction);
4640
- * }
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);
4641
4763
  */
4642
- list(threadId, query, options) {
4643
- return this.paginated("GET", options, ({ signal, headers }, cursor) => listEmailThreadMessages({
4764
+ list(appId, query, options) {
4765
+ const auth = this.auth(options);
4766
+ return this.call("GET", options, ({ signal, headers }) => listRealtimeAppChannels({
4644
4767
  client: this.client,
4645
- path: { thread_id: threadId },
4646
- query: {
4647
- ...query,
4648
- starting_after: cursor ?? query?.starting_after
4768
+ path: { realtime_app_id: appId },
4769
+ query,
4770
+ headers: {
4771
+ ...headers,
4772
+ ...auth
4773
+ },
4774
+ signal
4775
+ }));
4776
+ }
4777
+ /**
4778
+ * Read one channel's state. An unknown or never-used name is not an error —
4779
+ * it resolves with `occupied: false`.
4780
+ *
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);
4788
+ */
4789
+ get(appId, channelName, query, options) {
4790
+ const auth = this.auth(options);
4791
+ return this.call("GET", options, ({ signal, headers }) => getRealtimeAppChannel({
4792
+ client: this.client,
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
4649
4926
  },
4650
- headers,
4651
4927
  signal
4652
4928
  }));
4653
4929
  }
@@ -4714,8 +4990,6 @@ var BirdClient = class {
4714
4990
  smsTemplates;
4715
4991
  /** The WhatsApp channel — `bird.whatsapp.send(...)`, `.get(...)`, `.list(...)`, `.listEvents(...)`. */
4716
4992
  whatsapp;
4717
- /** WhatsApp templates — `bird.whatsappTemplates.list(...)`. */
4718
- whatsappTemplates;
4719
4993
  /** The Verify product — `bird.verify.verifications.create(...)`, `.check(...)`. */
4720
4994
  verify;
4721
4995
  /** Contacts — `bird.contacts.create(...)`, `.list(...)`, `.get(...)`, `.batch(...)`, … */
@@ -4736,6 +5010,8 @@ var BirdClient = class {
4736
5010
  mailboxThread;
4737
5011
  /** Thread messages — `bird.mailboxThreadMessage.list(...)`, `.get(...)`, `.reply(...)`, `.body(...)`, … */
4738
5012
  mailboxThreadMessage;
5013
+ /** Realtime — `bird.realtime.publish(...)`, `.channels.list(...)`, `.members.disconnect(...)`, … */
5014
+ realtime;
4739
5015
  constructor(options) {
4740
5016
  const opts = options;
4741
5017
  this.#baseUrl = resolveBaseUrl(opts);
@@ -4743,9 +5019,9 @@ var BirdClient = class {
4743
5019
  this.#headers = {
4744
5020
  ...opts.defaultHeaders,
4745
5021
  Authorization: `Bearer ${opts.apiKey}`,
4746
- "User-Agent": `bird-sdk-js/0.12.1`,
5022
+ "User-Agent": `bird-sdk-js/0.14.0`,
4747
5023
  "Bird-Surface": "sdk-js",
4748
- "Bird-Version": "0.12.1"
5024
+ "Bird-Version": "0.14.0"
4749
5025
  };
4750
5026
  const caller = detectCaller();
4751
5027
  if (caller) this.#headers["Bird-Caller"] = caller;
@@ -4762,7 +5038,6 @@ var BirdClient = class {
4762
5038
  this.sms = new SmsResource(this.core, this.#client);
4763
5039
  this.smsTemplates = new SmsTemplatesResource(this.core, this.#client);
4764
5040
  this.whatsapp = new WhatsappResource(this.core, this.#client);
4765
- this.whatsappTemplates = new WhatsappTemplatesResource(this.core, this.#client);
4766
5041
  this.verify = new VerifyResource(this.core, this.#client);
4767
5042
  this.contacts = new ContactsResource(this.core, this.#client);
4768
5043
  this.audiences = new AudiencesResource(this.core, this.#client);
@@ -4773,6 +5048,7 @@ var BirdClient = class {
4773
5048
  this.mailboxReceiveRule = new MailboxReceiveRuleResource(this.core, this.#client);
4774
5049
  this.mailboxThread = new MailboxThreadResource(this.core, this.#client);
4775
5050
  this.mailboxThreadMessage = new MailboxThreadMessageResource(this.core, this.#client);
5051
+ this.realtime = new RealtimeResource(this.core, this.#client, opts.realtime);
4776
5052
  }
4777
5053
  /**
4778
5054
  * Escape hatch for endpoints the typed resources don't cover. Runs the full
@@ -4856,11 +5132,6 @@ const WebhookEventType = {
4856
5132
  EmailScheduled: "email.scheduled",
4857
5133
  EmailSuppressionCreated: "email_suppression.created",
4858
5134
  EmailUnsubscribed: "email.unsubscribed",
4859
- RealtimeCacheChannels: "realtime.cache_channels",
4860
- RealtimeChannelExistence: "realtime.channel_existence",
4861
- RealtimeClientEvents: "realtime.client_events",
4862
- RealtimeConnectionCount: "realtime.connection_count",
4863
- RealtimePresence: "realtime.presence",
4864
5135
  SmsAccepted: "sms.accepted",
4865
5136
  SmsDelivered: "sms.delivered",
4866
5137
  SmsExpired: "sms.expired",
@@ -4872,6 +5143,11 @@ const WebhookEventType = {
4872
5143
  SmsTfnVerificationRejected: "sms.tfn_verification.rejected",
4873
5144
  SmsTfnVerificationSubmitted: "sms.tfn_verification.submitted",
4874
5145
  SmsUndelivered: "sms.undelivered",
5146
+ VerifyAttemptDelivered: "verify.attempt.delivered",
5147
+ VerifyAttemptSent: "verify.attempt.sent",
5148
+ VerifyAttemptUndelivered: "verify.attempt.undelivered",
5149
+ VerifyVerificationCreated: "verify.verification.created",
5150
+ VerifyVerificationVerified: "verify.verification.verified",
4875
5151
  VoiceCallAnswered: "voice_call.answered",
4876
5152
  VoiceCallEnded: "voice_call.ended",
4877
5153
  VoiceCallInitiated: "voice_call.initiated",