@messagebird/sdk 0.30.0 → 0.32.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
@@ -2315,7 +2315,7 @@ const updateSmsKeywordRule = (options) => (options.client ?? client).patch({
2315
2315
  }
2316
2316
  });
2317
2317
  /**
2318
- * Get aggregate SMS statistics
2318
+ * Get aggregate outbound SMS statistics
2319
2319
  *
2320
2320
  * Returns one aggregate row for the requested period. It includes SMS lifecycle counts, delivery and failure rates, and processing, delivery, and total latency percentiles (`p50`, `p95`, and `p99`). Rows use send-time attribution, so recent periods can under-report `delivered` while delivery reports arrive.
2321
2321
  *
@@ -2337,7 +2337,7 @@ const getSmsStatsSummary = (options) => (options?.client ?? client).get({
2337
2337
  ...options
2338
2338
  });
2339
2339
  /**
2340
- * Get daily SMS statistics
2340
+ * Get daily outbound SMS statistics
2341
2341
  *
2342
2342
  * Returns one row of SMS lifecycle counts per calendar day. Rows use send-time attribution, so a delivery confirmation is counted on the day when its message was accepted. Recent rows can under-report `delivered` while delivery reports arrive. Days without activity contain zero counts.
2343
2343
  *
@@ -2359,7 +2359,7 @@ const getSmsStatsDaily = (options) => (options?.client ?? client).get({
2359
2359
  ...options
2360
2360
  });
2361
2361
  /**
2362
- * Get hourly SMS statistics
2362
+ * Get hourly outbound SMS statistics
2363
2363
  *
2364
2364
  * Returns one row of SMS lifecycle counts per hour. Rows use send-time attribution, so a delivery confirmation is counted in the hour when its message was accepted. Recent rows can under-report `delivered` while delivery reports arrive.
2365
2365
  *
@@ -2381,7 +2381,7 @@ const getSmsStatsHourly = (options) => (options?.client ?? client).get({
2381
2381
  ...options
2382
2382
  });
2383
2383
  /**
2384
- * Get SMS statistics by originator
2384
+ * Get outbound SMS statistics by originator
2385
2385
  *
2386
2386
  * Returns aggregate delivery and latency stats grouped by originator (the sender address messages were sent from) for the requested period. Rows are ranked by the `sort` metric (default `accepted`) descending and capped at the requested `limit` (default 50, hard maximum 200). Use this to compare sending performance across the senders you dispatch from.
2387
2387
  *
@@ -2403,7 +2403,7 @@ const getSmsStatsByOriginator = (options) => (options?.client ?? client).get({
2403
2403
  ...options
2404
2404
  });
2405
2405
  /**
2406
- * Get SMS statistics by country
2406
+ * Get outbound SMS statistics by country
2407
2407
  *
2408
2408
  * Returns aggregate delivery and latency stats grouped by destination country for the requested period. Rows are ranked by the `sort` metric (default `accepted`) descending and capped at the requested `limit` (default 50, hard maximum 200). Use this to compare sending performance across the countries you send to.
2409
2409
  *
@@ -2425,7 +2425,7 @@ const getSmsStatsByCountry = (options) => (options?.client ?? client).get({
2425
2425
  ...options
2426
2426
  });
2427
2427
  /**
2428
- * Get SMS statistics by category
2428
+ * Get outbound SMS statistics by category
2429
2429
  *
2430
2430
  * Returns aggregate delivery and latency stats grouped by message category for the requested period. Rows are ranked by the `sort` metric (default `accepted`) descending and capped at the requested `limit` (default 50, hard maximum 200). Use this to compare sending performance across the categories you send under.
2431
2431
  *
@@ -2447,7 +2447,7 @@ const getSmsStatsByCategory = (options) => (options?.client ?? client).get({
2447
2447
  ...options
2448
2448
  });
2449
2449
  /**
2450
- * Get SMS statistics by error code
2450
+ * Get outbound SMS statistics by error code
2451
2451
  *
2452
2452
  * Returns aggregate delivery and latency statistics grouped by normalized failure reason for the requested period. The grouping key matches the `error_code` filter on the message list, so each row maps directly to the affected messages rather than a raw carrier code. Rows are ranked by the `sort` metric (default `failed`) descending and capped at the requested `limit` (default 50, hard maximum 200).
2453
2453
  *
@@ -2467,7 +2467,7 @@ const getSmsStatsByErrorCode = (options) => (options?.client ?? client).get({
2467
2467
  ...options
2468
2468
  });
2469
2469
  /**
2470
- * Get SMS statistics by carrier
2470
+ * Get outbound SMS statistics by carrier
2471
2471
  *
2472
2472
  * Returns aggregate delivery and latency stats grouped by delivery carrier for the requested period. Rows are ranked by the `sort` metric (default `accepted`) descending and capped at the requested `limit` (default 50, hard maximum 200). Use this to compare delivery performance across the carriers that handled your messages.
2473
2473
  *
@@ -2489,7 +2489,7 @@ const getSmsStatsByCarrier = (options) => (options?.client ?? client).get({
2489
2489
  ...options
2490
2490
  });
2491
2491
  /**
2492
- * Get SMS statistics by tag
2492
+ * Get outbound SMS statistics by tag
2493
2493
  *
2494
2494
  * Returns delivery and latency statistics grouped by tag (`name:value`). Rows sort by the selected metric in descending order and are capped by `limit`. The default sort is `accepted`; the default limit is 50 and the maximum is 200.
2495
2495
  *
@@ -2511,7 +2511,7 @@ const getSmsStatsByTag = (options) => (options?.client ?? client).get({
2511
2511
  ...options
2512
2512
  });
2513
2513
  /**
2514
- * Get SMS statistics by status
2514
+ * Get outbound SMS statistics by status
2515
2515
  *
2516
2516
  * Returns one row per lifecycle status with activity in the requested period, ordered by count descending. The statuses are `accepted`, `sent`, `delivered`, `undelivered`, `failed`, `rejected`, and `expired`.
2517
2517
  *
@@ -2533,11 +2533,11 @@ const getSmsStatsByStatus = (options) => (options?.client ?? client).get({
2533
2533
  ...options
2534
2534
  });
2535
2535
  /**
2536
- * Get a received-message summary
2536
+ * Get aggregate inbound SMS statistics
2537
2537
  *
2538
2538
  * Returns the total number of messages your numbers received over the period, using the time the carrier received each message.
2539
2539
  *
2540
- * The response contains only a count because a received message has one state. Use the send statistics endpoints for delivery rates and latency data about messages you send.
2540
+ * The response contains only a count because a received message has one state. Use the outbound statistics endpoints for delivery rates and latency data about messages you send.
2541
2541
  *
2542
2542
  * The maximum window is 365 days; a longer range returns 422. Set `timezone` to resolve the period against your local calendar instead of UTC.
2543
2543
  *
@@ -2555,11 +2555,11 @@ const getSmsInboundStatsSummary = (options) => (options?.client ?? client).get({
2555
2555
  ...options
2556
2556
  });
2557
2557
  /**
2558
- * Get daily received-message counts
2558
+ * Get daily inbound SMS statistics
2559
2559
  *
2560
2560
  * Returns the number of messages your numbers received, one row per calendar day. Rows use the time the carrier received each message, and days with no messages contain a zero count.
2561
2561
  *
2562
- * Each row contains only a count because a received message has one state. Use the send statistics endpoints for lifecycle and delivery-latency data about messages you send.
2562
+ * Each row contains only a count because a received message has one state. Use the outbound statistics endpoints for lifecycle and delivery-latency data about messages you send.
2563
2563
  *
2564
2564
  * The maximum window is 365 days; a longer range returns 422. Set `timezone` to bucket rows by your local calendar day instead of UTC.
2565
2565
  *
@@ -2577,11 +2577,11 @@ const getSmsInboundStatsDaily = (options) => (options?.client ?? client).get({
2577
2577
  ...options
2578
2578
  });
2579
2579
  /**
2580
- * Get hourly received-message counts
2580
+ * Get hourly inbound SMS statistics
2581
2581
  *
2582
2582
  * Returns the number of messages your numbers received, one row per hour. Rows use the time the carrier received each message, and hours with no messages contain a zero count.
2583
2583
  *
2584
- * Each row contains only a count because a received message has one state. Use the send statistics endpoints for lifecycle and delivery-latency data about messages you send.
2584
+ * Each row contains only a count because a received message has one state. Use the outbound statistics endpoints for lifecycle and delivery-latency data about messages you send.
2585
2585
  *
2586
2586
  * The maximum window is 720 hours; a longer range returns 422. Set `timezone` to bucket rows by your local hour instead of UTC.
2587
2587
  *
@@ -2599,7 +2599,7 @@ const getSmsInboundStatsHourly = (options) => (options?.client ?? client).get({
2599
2599
  ...options
2600
2600
  });
2601
2601
  /**
2602
- * Get received messages by country
2602
+ * Get inbound SMS statistics by country
2603
2603
  *
2604
2604
  * Returns the number of messages your numbers received, grouped by the receiving number's country. Rows are ranked by volume, highest first, and use the time the carrier received each message.
2605
2605
  *
@@ -2619,7 +2619,7 @@ const getSmsInboundStatsByCountry = (options) => (options?.client ?? client).get
2619
2619
  ...options
2620
2620
  });
2621
2621
  /**
2622
- * Get received messages by operator
2622
+ * Get inbound SMS statistics by operator
2623
2623
  *
2624
2624
  * Returns the number of messages your numbers received, grouped by the sender's mobile operator. Rows are ranked by volume, highest first, and use the time the carrier received each message. Operators are identified by MCC-MNC when the carrier reports it.
2625
2625
  *
@@ -2641,7 +2641,7 @@ const getSmsInboundStatsByOperator = (options) => (options?.client ?? client).ge
2641
2641
  ...options
2642
2642
  });
2643
2643
  /**
2644
- * Get received messages by number
2644
+ * Get inbound SMS statistics by number
2645
2645
  *
2646
2646
  * Returns how many messages each of your numbers received. Rows are ranked by volume, highest first, and use the time the carrier received each message.
2647
2647
  *
@@ -2859,6 +2859,8 @@ const listWhatsAppMessages = (options) => (options?.client ?? client).get({
2859
2859
  * - A `from` this workspace cannot send from.
2860
2860
  * - A recipient that is neither a valid phone number nor a business-scoped user ID.
2861
2861
  *
2862
+ * A send from a workspace with no wallet balance fails with a `402`.
2863
+ *
2862
2864
  */
2863
2865
  const createWhatsAppMessage = (options) => (options.client ?? client).post({
2864
2866
  security: [{
@@ -3859,6 +3861,159 @@ const listMailboxLabels = (options) => (options.client ?? client).get({
3859
3861
  ...options
3860
3862
  });
3861
3863
  /**
3864
+ * List your allocated numbers
3865
+ *
3866
+ * Returns a paginated list of the phone numbers currently allocated to your workspace, newest first. Each entry is either a dedicated number you bought or a shared number managed for you, as its `kind` field indicates. Pass `number` to look one up, or narrow the list with `country_code`, `number_type`, `prefix`, and `capabilities`. An allocated number is not always enough to send from it: some countries also require an approved registration for the sender.
3867
+ */
3868
+ const listWorkspaceNumbers = (options) => (options?.client ?? client).get({
3869
+ security: [{
3870
+ scheme: "bearer",
3871
+ type: "http"
3872
+ }, {
3873
+ in: "cookie",
3874
+ name: "bird_session",
3875
+ type: "apiKey"
3876
+ }],
3877
+ url: "/v1/numbers",
3878
+ ...options
3879
+ });
3880
+ /**
3881
+ * List available phone numbers
3882
+ *
3883
+ * Returns phone numbers available for purchase in a country, newest first. Narrow the search with `number_type`, `capabilities`, and `prefix`. Inventory numbers are returned first and support pagination. The final page can include a live snapshot of numbers available from suppliers.
3884
+ */
3885
+ const listAvailableNumbers = (options) => (options.client ?? client).get({
3886
+ security: [{
3887
+ scheme: "bearer",
3888
+ type: "http"
3889
+ }, {
3890
+ in: "cookie",
3891
+ name: "bird_session",
3892
+ type: "apiKey"
3893
+ }],
3894
+ url: "/v1/numbers/available",
3895
+ ...options
3896
+ });
3897
+ /**
3898
+ * Get an available phone number
3899
+ *
3900
+ * Returns a single phone number available for purchase, whether it is already in inventory or can be acquired for you. Numbers supplied through a carrier remain available only while the carrier has them, so a number listed a moment ago may already be gone. A `404` means the number is currently unavailable for sale.
3901
+ */
3902
+ const getAvailableNumber = (options) => (options.client ?? client).get({
3903
+ security: [{
3904
+ scheme: "bearer",
3905
+ type: "http"
3906
+ }, {
3907
+ in: "cookie",
3908
+ name: "bird_session",
3909
+ type: "apiKey"
3910
+ }],
3911
+ url: "/v1/numbers/available/{number}",
3912
+ ...options
3913
+ });
3914
+ /**
3915
+ * List your number orders
3916
+ *
3917
+ * Returns your workspace's number orders, newest first. Filter by status to find in-progress or failed orders.
3918
+ */
3919
+ const listNumbersOrders = (options) => (options?.client ?? client).get({
3920
+ security: [{
3921
+ scheme: "bearer",
3922
+ type: "http"
3923
+ }, {
3924
+ in: "cookie",
3925
+ name: "bird_session",
3926
+ type: "apiKey"
3927
+ }],
3928
+ url: "/v1/numbers/orders",
3929
+ ...options
3930
+ });
3931
+ /**
3932
+ * Create a number order
3933
+ *
3934
+ * Orders a number for your workspace and starts its monthly charge. Pass a
3935
+ * number from `GET /v1/numbers/available`. Whether the number is already in
3936
+ * inventory or acquired from a supplier, the response contains an order.
3937
+ *
3938
+ * Most orders complete immediately and return `201` with `status` of
3939
+ * `completed` and `number_id` populated. Read the number with
3940
+ * `GET /v1/numbers/{number_id}`. An order that cannot complete in the request
3941
+ * returns `202`; poll `GET /v1/numbers/orders/{order_id}` until it is
3942
+ * `completed` or `failed`.
3943
+ *
3944
+ * A `412` means the workspace has not
3945
+ * completed the identity verification required to acquire a sender. Complete
3946
+ * it, then retry.
3947
+ *
3948
+ */
3949
+ const createNumbersOrder = (options) => (options.client ?? client).post({
3950
+ security: [{
3951
+ scheme: "bearer",
3952
+ type: "http"
3953
+ }, {
3954
+ in: "cookie",
3955
+ name: "bird_session",
3956
+ type: "apiKey"
3957
+ }],
3958
+ url: "/v1/numbers/orders",
3959
+ ...options,
3960
+ headers: {
3961
+ "Content-Type": "application/json",
3962
+ ...options.headers
3963
+ }
3964
+ });
3965
+ /**
3966
+ * Get a number order
3967
+ *
3968
+ * Returns a single number order by id, including its current lifecycle state and, once completed, the number it produced.
3969
+ */
3970
+ const getNumbersOrder = (options) => (options.client ?? client).get({
3971
+ security: [{
3972
+ scheme: "bearer",
3973
+ type: "http"
3974
+ }, {
3975
+ in: "cookie",
3976
+ name: "bird_session",
3977
+ type: "apiKey"
3978
+ }],
3979
+ url: "/v1/numbers/orders/{order_id}",
3980
+ ...options
3981
+ });
3982
+ /**
3983
+ * Release a dedicated number
3984
+ *
3985
+ * Releases one of your workspace's dedicated numbers and stops its monthly charge. Your workspace can no longer use the number after release. Shared numbers cannot be released because they serve multiple workspaces.
3986
+ */
3987
+ const releaseWorkspaceNumber = (options) => (options.client ?? client).delete({
3988
+ security: [{
3989
+ scheme: "bearer",
3990
+ type: "http"
3991
+ }, {
3992
+ in: "cookie",
3993
+ name: "bird_session",
3994
+ type: "apiKey"
3995
+ }],
3996
+ url: "/v1/numbers/{number_id}",
3997
+ ...options
3998
+ });
3999
+ /**
4000
+ * Get an allocated number
4001
+ *
4002
+ * Returns a single phone number allocated to your workspace, whether it is a dedicated number you bought or a shared number managed for you. Numbers you have released are no longer returned. An allocated number is not always enough to send from it: some countries also require an approved registration for the sender.
4003
+ */
4004
+ const getWorkspaceNumber = (options) => (options.client ?? client).get({
4005
+ security: [{
4006
+ scheme: "bearer",
4007
+ type: "http"
4008
+ }, {
4009
+ in: "cookie",
4010
+ name: "bird_session",
4011
+ type: "apiKey"
4012
+ }],
4013
+ url: "/v1/numbers/{number_id}",
4014
+ ...options
4015
+ });
4016
+ /**
3862
4017
  * List calls
3863
4018
  *
3864
4019
  * Returns a paginated list of the workspace's calls, ordered by start time
@@ -5126,7 +5281,7 @@ var DomainsResource = class extends Resource {
5126
5281
  }));
5127
5282
  }
5128
5283
  /**
5129
- * Update a sending domain's tracking and inbound configuration. Tracking: click_tracking and open_tracking apply immediately to new sends, and the tracking domain can be set, changed, or removed (the name part only, and the sending domain is appended for you). Enabling either toggle with no tracking domain configured returns 409, and 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: inbound.enabled starts or stops 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 receiving starts only once inbound.enabled is set, even when those records are already published.
5284
+ * Update a sending domain's tracking and inbound configuration. Tracking: click_tracking and open_tracking apply immediately to new sends, and the tracking domain can be set, changed, or removed (the name part only, and the sending domain is appended for you). Enabling either toggle with no tracking domain configured returns 409, and 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: inbound.enabled starts or stops 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, marked optional until inbound.enabled is set, so receiving starts only once you set it even when those records are already published. Publishing them earlier is not free: on a domain at the zone apex they replace the MX records carrying its existing mail, changing where that mail is delivered.
5130
5285
  *
5131
5286
  * @example Enable tracking on a domain
5132
5287
  * await bird.domains.update("dom_01krdgeqcxet5s7t44vh8rt9mg", {
@@ -6706,6 +6861,181 @@ var LookupResource = class extends Resource {
6706
6861
  }
6707
6862
  };
6708
6863
  //#endregion
6864
+ //#region src/resources/numbers.gen.ts
6865
+ var NumbersResourceBase = class extends Resource {
6866
+ /**
6867
+ * Pages the numbers allocated to the workspace, dedicated and shared alike. Narrows on country, type, prefix and capability, so one number is reached without walking every page.
6868
+ *
6869
+ * @example List the numbers allocated to you
6870
+ * for await (const allocated of bird.numbers.list({ country_code: "GB" })) {
6871
+ * // kind tells a number you bought from one Bird manages for several workspaces.
6872
+ * console.log(allocated.number, allocated.kind, allocated.status);
6873
+ * }
6874
+ */
6875
+ list(query, options) {
6876
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listWorkspaceNumbers({
6877
+ client: this.client,
6878
+ query: {
6879
+ ...query,
6880
+ starting_after: cursor ?? query?.starting_after
6881
+ },
6882
+ headers,
6883
+ signal
6884
+ }));
6885
+ }
6886
+ /**
6887
+ * Reads one allocated number by the id `numbers.list` returns. Carries its status and, where a country demands ownership paperwork, what is still outstanding on it.
6888
+ *
6889
+ * @example Read one number allocated to you
6890
+ * const allocated = await bird.numbers.get("nda_01krdgeqcxet5s7t44vh8rt9mg");
6891
+ * // A country that asks for ownership paperwork answers here; most answer null.
6892
+ * console.log(allocated.status, allocated.ownership ?? "no paperwork required");
6893
+ */
6894
+ get(numberId, options) {
6895
+ return this.call("GET", options, ({ signal, headers }) => getWorkspaceNumber({
6896
+ client: this.client,
6897
+ path: { number_id: numberId },
6898
+ headers,
6899
+ signal
6900
+ }));
6901
+ }
6902
+ /**
6903
+ * Gives a dedicated number back and stops its monthly charge. Irreversible: the number leaves the workspace and the channels built on it stop sending. A shared number cannot be released.
6904
+ *
6905
+ * @example Give a dedicated number back
6906
+ * // Releasing stops the monthly charge and the number stops working for you.
6907
+ * // Only a dedicated number can be released; a shared one answers E14002.
6908
+ * await bird.numbers.release("nda_01krdgeqcxet5s7t44vh8rt9mg");
6909
+ */
6910
+ release(numberId, options) {
6911
+ return this.call("DELETE", options, ({ signal, headers }) => releaseWorkspaceNumber({
6912
+ client: this.client,
6913
+ path: { number_id: numberId },
6914
+ headers,
6915
+ signal
6916
+ }));
6917
+ }
6918
+ };
6919
+ //#endregion
6920
+ //#region src/resources/numbersAvailable.gen.ts
6921
+ var NumbersAvailableResource = class extends Resource {
6922
+ /**
6923
+ * Searches one country's numbers on sale. Our own inventory answers first and pages; the last page can carry a live carrier snapshot, so a number seen here may be gone by the time it is ordered.
6924
+ *
6925
+ * @example Find a number to buy in one country
6926
+ * // The search is always country-scoped, so country_code is required.
6927
+ * const page = await bird.numbers.available.list({
6928
+ * country_code: "GB",
6929
+ * capabilities: ["sms", "voice"],
6930
+ * });
6931
+ * for (const candidate of page.data) {
6932
+ * console.log(candidate.number, candidate.number_type);
6933
+ * }
6934
+ */
6935
+ list(query, options) {
6936
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listAvailableNumbers({
6937
+ client: this.client,
6938
+ query: {
6939
+ ...query,
6940
+ starting_after: cursor ?? query?.starting_after
6941
+ },
6942
+ headers,
6943
+ signal
6944
+ }));
6945
+ }
6946
+ /**
6947
+ * Re-checks one number from `numbers.available.list` against the carrier, so a stale search result is caught before it is ordered.
6948
+ *
6949
+ * @example Check one number is still for sale
6950
+ * // A number a carrier supplies is only on sale while the carrier still has it,
6951
+ * // so a 404 here means someone else took it.
6952
+ * const candidate = await bird.numbers.available.get("+447700900201");
6953
+ * console.log(candidate.country_code, candidate.capabilities);
6954
+ */
6955
+ get(number, options) {
6956
+ return this.call("GET", options, ({ signal, headers }) => getAvailableNumber({
6957
+ client: this.client,
6958
+ path: { number },
6959
+ headers,
6960
+ signal
6961
+ }));
6962
+ }
6963
+ };
6964
+ //#endregion
6965
+ //#region src/resources/numbersOrders.gen.ts
6966
+ var NumbersOrdersResource = class extends Resource {
6967
+ /**
6968
+ * Buys a number and starts its monthly charge. Most orders settle inline; one waiting on a carrier comes back pending and is followed with `numbers.orders.get`. A setup fee already taken is not refunded if the order then fails.
6969
+ *
6970
+ * @example Buy a number
6971
+ * const order = await bird.numbers.orders.create({ number: "+447700900201" });
6972
+ * // Most orders finish inside the request. One that has to wait on a carrier
6973
+ * // comes back without a number_id. Poll it until it is completed or failed.
6974
+ * if (order.status === "completed") {
6975
+ * console.log("allocated as", order.number_id);
6976
+ * } else {
6977
+ * console.log("still", order.status, "; poll", order.id);
6978
+ * }
6979
+ */
6980
+ create(params, options) {
6981
+ return this.call("POST", options, ({ signal, headers }) => createNumbersOrder({
6982
+ client: this.client,
6983
+ body: params,
6984
+ headers,
6985
+ signal
6986
+ }));
6987
+ }
6988
+ /**
6989
+ * Pages the workspace's purchase attempts, newest first, filtered by status. An order outlives its attempt, so a failure stays readable with the reason it carried.
6990
+ *
6991
+ * @example Find the purchases that did not complete
6992
+ * const page = await bird.numbers.orders.list({ status: "failed" });
6993
+ * for (const order of page.data) {
6994
+ * console.log(order.number, order.failure_reason ?? "");
6995
+ * }
6996
+ */
6997
+ list(query, options) {
6998
+ return this.paginated("GET", options, ({ signal, headers }, cursor) => listNumbersOrders({
6999
+ client: this.client,
7000
+ query: {
7001
+ ...query,
7002
+ starting_after: cursor ?? query?.starting_after
7003
+ },
7004
+ headers,
7005
+ signal
7006
+ }));
7007
+ }
7008
+ /**
7009
+ * Reads one order's current state, and the number it produced once completed. This is the poll for an order that came back pending.
7010
+ *
7011
+ * @example Poll an order that did not finish inline
7012
+ * const order = await bird.numbers.orders.get("nor_01krdgeqcxet5s7t44vh8rt9mg");
7013
+ * // failure_reason says what went wrong, and only ever on a failed order.
7014
+ * console.log(order.status, order.failure_reason ?? "");
7015
+ */
7016
+ get(orderId, options) {
7017
+ return this.call("GET", options, ({ signal, headers }) => getNumbersOrder({
7018
+ client: this.client,
7019
+ path: { order_id: orderId },
7020
+ headers,
7021
+ signal
7022
+ }));
7023
+ }
7024
+ };
7025
+ //#endregion
7026
+ //#region src/resources/numbers.ts
7027
+ var NumbersResource = class extends NumbersResourceBase {
7028
+ /** Numbers on sale — `bird.numbers.available.list(...)`, `.get(...)`. */
7029
+ available;
7030
+ /** Purchases — `bird.numbers.orders.create(...)`, `.list(...)`, `.get(...)`. */
7031
+ orders;
7032
+ constructor(core, client) {
7033
+ super(core, client);
7034
+ this.available = new NumbersAvailableResource(core, client);
7035
+ this.orders = new NumbersOrdersResource(core, client);
7036
+ }
7037
+ };
7038
+ //#endregion
6709
7039
  //#region src/client.ts
6710
7040
  const DEFAULT_TIMEOUT_MS = 6e4;
6711
7041
  const DEFAULT_MAX_RETRIES = 2;
@@ -6785,6 +7115,8 @@ var BirdClient = class {
6785
7115
  domains;
6786
7116
  /** Recipient intelligence: `bird.lookup.email(...)`, `.phoneNumber(...)`. Every answer is billed. */
6787
7117
  lookup;
7118
+ /** Numbers: `bird.numbers.available.list(...)`, `.orders.create(...)`, `.list(...)`, `.release(...)`. */
7119
+ numbers;
6788
7120
  /** Webhooks: `bird.webhooks.unwrap(payload, headers)` verifies an inbound delivery. */
6789
7121
  webhooks;
6790
7122
  /** Realtime: `bird.realtime.publish(...)`, `.channels.list(...)`, `.members.disconnect(...)`, … */
@@ -6796,9 +7128,9 @@ var BirdClient = class {
6796
7128
  this.#headers = {
6797
7129
  ...opts.defaultHeaders,
6798
7130
  Authorization: `Bearer ${opts.apiKey}`,
6799
- "User-Agent": `bird-sdk-js/0.30.0`,
7131
+ "User-Agent": `bird-sdk-js/0.32.0`,
6800
7132
  "Bird-Surface": "sdk-js",
6801
- "Bird-Version": "0.30.0"
7133
+ "Bird-Version": "0.32.0"
6802
7134
  };
6803
7135
  const caller = detectCaller();
6804
7136
  if (caller) this.#headers["Bird-Caller"] = caller;
@@ -6836,6 +7168,7 @@ var BirdClient = class {
6836
7168
  this.contactProperties = new ContactPropertiesResource(this.core, this.#client);
6837
7169
  this.domains = new DomainsResource(this.core, this.#client);
6838
7170
  this.lookup = new LookupResource(this.core, this.#client);
7171
+ this.numbers = new NumbersResource(this.core, this.#client);
6839
7172
  this.webhooks = new WebhooksResource(opts.webhooks);
6840
7173
  this.realtime = new RealtimeResource(this.core, this.#client, opts.realtime);
6841
7174
  }
@@ -7017,6 +7350,41 @@ const LookupPropertyStatus = {
7017
7350
  Unavailable: "unavailable"
7018
7351
  };
7019
7352
  /**
7353
+ * Values of NumberCapability known at this SDK version. The wire value is an open
7354
+ * string: a value added by a newer server deserializes unchanged, so switch on
7355
+ * these with a `default` branch rather than treating the set as closed.
7356
+ */
7357
+ const NumberCapability = {
7358
+ Mms: "mms",
7359
+ Sms: "sms",
7360
+ Voice: "voice"
7361
+ };
7362
+ /**
7363
+ * Values of NumberType known at this SDK version. The wire value is an open
7364
+ * string: a value added by a newer server deserializes unchanged, so switch on
7365
+ * these with a `default` branch rather than treating the set as closed.
7366
+ */
7367
+ const NumberType = {
7368
+ Local: "local",
7369
+ Mobile: "mobile",
7370
+ National: "national",
7371
+ ShortCode: "short_code",
7372
+ ShortCodeFteu: "short_code_fteu",
7373
+ TollFree: "toll_free"
7374
+ };
7375
+ /**
7376
+ * Values of NumbersOrderStatus known at this SDK version. The wire value is an open
7377
+ * string: a value added by a newer server deserializes unchanged, so switch on
7378
+ * these with a `default` branch rather than treating the set as closed.
7379
+ */
7380
+ const NumbersOrderStatus = {
7381
+ Charging: "charging",
7382
+ Completed: "completed",
7383
+ Failed: "failed",
7384
+ Ordering: "ordering",
7385
+ Pending: "pending"
7386
+ };
7387
+ /**
7020
7388
  * Values of SMSErrorCode known at this SDK version. The wire value is an open
7021
7389
  * string: a value added by a newer server deserializes unchanged, so switch on
7022
7390
  * these with a `default` branch rather than treating the set as closed.
@@ -7150,6 +7518,7 @@ const VerificationTerminalReason = {
7150
7518
  const WhatsAppErrorCode = {
7151
7519
  InsufficientBalance: "insufficient_balance",
7152
7520
  InternalError: "internal_error",
7521
+ MediaRejected: "media_rejected",
7153
7522
  PriceNotFound: "price_not_found",
7154
7523
  RateLimited: "rate_limited",
7155
7524
  RecipientSuppressed: "recipient_suppressed",
@@ -7194,6 +7563,6 @@ const WhatsAppTemplateParameterType = {
7194
7563
  Video: "video"
7195
7564
  };
7196
7565
  //#endregion
7197
- export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, EmailLookupFlag, EmailLookupReason, EmailLookupResult, LookupFlag, LookupPropertyStatus, SMSErrorCode, SMSKeywordOperation, SMSSuppressionCoverage, SMSSuppressionEndReason, SMSSuppressionOrigin, SMSSuppressionReason, TemplateLanguageStatus, TemplateStatus, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppEventType, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
7566
+ export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, EmailLookupFlag, EmailLookupReason, EmailLookupResult, LookupFlag, LookupPropertyStatus, NumberCapability, NumberType, NumbersOrderStatus, SMSErrorCode, SMSKeywordOperation, SMSSuppressionCoverage, SMSSuppressionEndReason, SMSSuppressionOrigin, SMSSuppressionReason, TemplateLanguageStatus, TemplateStatus, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppEventType, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
7198
7567
 
7199
7568
  //# sourceMappingURL=index.mjs.map