@funnelchat-hq/sdk 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -3780,7 +3780,11 @@ interface paths {
3780
3780
  */
3781
3781
  get: operations["device.index"];
3782
3782
  put?: never;
3783
- post?: never;
3783
+ /**
3784
+ * Create a number connected by QR code
3785
+ * @description Same path and same rejections as the panel: `403 numbers_not_included`, `403 number_limit_reached`, `409 pending_number_exists` (the account already has a QR number waiting to be scanned: its `device_id` comes in the body), `422 qr_requires_coexistence`, `422 method_already_present` (with `device_id`), `409 operation_in_progress`. The provider is chosen by the system. Then ask for the QR with `GET devices/{device}/qr`. `country` is the country of the phone that will scan the QR, where the WhatsApp session is opened from.
3786
+ */
3787
+ post: operations["pendingDevice.store"];
3784
3788
  delete?: never;
3785
3789
  options?: never;
3786
3790
  head?: never;
@@ -4887,6 +4891,71 @@ interface paths {
4887
4891
  patch?: never;
4888
4892
  trace?: never;
4889
4893
  };
4894
+ "/api/v1/devices/{device}/qr": {
4895
+ parameters: {
4896
+ query?: never;
4897
+ header?: never;
4898
+ path?: never;
4899
+ cookie?: never;
4900
+ };
4901
+ /**
4902
+ * The QR code to connect a number
4903
+ * @description Creates the WhatsApp instance when needed. Only for QR numbers: an official one answers `422 provider_unsupported`. Scanning the QR gives control of a WhatsApp, so it needs **WhatsApp numbers → Create, connect and delete** (`accounts:operate`). Every call brings the code of that moment: ask again every `expires_in` seconds (5 with a QR) and replace the image with the latest one; the answer carries `Cache-Control: no-store`.
4904
+ */
4905
+ get: operations["pendingDevice.qr"];
4906
+ put?: never;
4907
+ post?: never;
4908
+ delete?: never;
4909
+ options?: never;
4910
+ head?: never;
4911
+ patch?: never;
4912
+ trace?: never;
4913
+ };
4914
+ "/api/v1/connect-links": {
4915
+ parameters: {
4916
+ query?: never;
4917
+ header?: never;
4918
+ path?: never;
4919
+ cookie?: never;
4920
+ };
4921
+ /**
4922
+ * List connect links
4923
+ * @description Without the token: `url` is not shown again. Newest first.
4924
+ */
4925
+ get: operations["pendingConnectLink.index"];
4926
+ put?: never;
4927
+ /**
4928
+ * Create a connect link
4929
+ * @description A single-use page where your customer connects a number: by QR code, or an official one through the Meta sign-up. The number is created when the page finishes. The quota is checked now (except on a reconnection) and again at the end, with the rejections of `POST devices`. `provision_us_number` needs `dedicated` in `allowed_connection_types` and no `device_id` (`422 invalid_request`). At most 20 open links per account (`429 too_many_open_links`); `type: "meta"` answers `503 meta_connect_disabled` while the official sign-up is off, as it is in production until the domain is registered with Meta. `country` (only `qr`, not with `device_id`) is the country of the phone that will scan the QR.
4930
+ */
4931
+ post: operations["pendingConnectLink.store"];
4932
+ delete?: never;
4933
+ options?: never;
4934
+ head?: never;
4935
+ patch?: never;
4936
+ trace?: never;
4937
+ };
4938
+ "/api/v1/connect-links/{link}": {
4939
+ parameters: {
4940
+ query?: never;
4941
+ header?: never;
4942
+ path?: never;
4943
+ cookie?: never;
4944
+ };
4945
+ /** Read a connect link */
4946
+ get: operations["pendingConnectLink.show"];
4947
+ put?: never;
4948
+ post?: never;
4949
+ /**
4950
+ * Revoke a connect link
4951
+ * @description Only a `pending` link: any other answers `409 link_not_pending`.
4952
+ */
4953
+ delete: operations["pendingConnectLink.destroy"];
4954
+ options?: never;
4955
+ head?: never;
4956
+ patch?: never;
4957
+ trace?: never;
4958
+ };
4890
4959
  }
4891
4960
  interface webhooks {
4892
4961
  "message.received": {
@@ -6136,7 +6205,7 @@ interface webhooks {
6136
6205
  put?: never;
6137
6206
  /**
6138
6207
  * device.connected
6139
- * @description One of the numbers of the account got connected: by scanning the QR code or by finishing the sign-up of a WhatsApp Cloud number.
6208
+ * @description One of the numbers of the account got connected: by scanning the QR code, by finishing the sign-up of a WhatsApp Cloud number, or through a connect link.
6140
6209
  */
6141
6210
  post: {
6142
6211
  parameters: {
@@ -6149,14 +6218,11 @@ interface webhooks {
6149
6218
  content: {
6150
6219
  "application/json": {
6151
6220
  data?: {
6152
- device: {
6153
- id: number;
6154
- name: string | null;
6155
- /** @description Digits only, without `+`. */
6156
- number: string | null;
6157
- };
6221
+ device: components["schemas"]["PendingWebhookDevice"];
6158
6222
  /** Format: date-time */
6159
6223
  connected_at: string;
6224
+ /** @description The connect link of this connection, or `null` when it did not come from a link. */
6225
+ connect_link_id?: number | null;
6160
6226
  };
6161
6227
  };
6162
6228
  };
@@ -6180,7 +6246,7 @@ interface webhooks {
6180
6246
  put?: never;
6181
6247
  /**
6182
6248
  * device.disconnected
6183
- * @description One of the numbers of the account disconnected and can no longer send or receive.
6249
+ * @description One of the numbers of the account disconnected and can no longer send or receive: a QR session that closed or was protected from a shadow ban, an official number that failed its re-registration, or one disconnected from the panel.
6184
6250
  */
6185
6251
  post: {
6186
6252
  parameters: {
@@ -6193,14 +6259,13 @@ interface webhooks {
6193
6259
  content: {
6194
6260
  "application/json": {
6195
6261
  data?: {
6196
- device: {
6197
- id: number;
6198
- name: string | null;
6199
- /** @description Digits only, without `+`. */
6200
- number: string | null;
6201
- };
6262
+ device: components["schemas"]["PendingWebhookDevice"];
6202
6263
  /** Format: date-time */
6203
6264
  disconnected_at: string;
6265
+ /** @enum {string} */
6266
+ reason?: "qr_logged_out" | "meta_account_not_registered" | "shadow_ban_protection" | "provider_error" | "unknown" | "disconnected_by_user";
6267
+ /** @description The connect link that last connected the number, or `null`. */
6268
+ connect_link_id?: number | null;
6204
6269
  };
6205
6270
  };
6206
6271
  };
@@ -7352,6 +7417,92 @@ interface webhooks {
7352
7417
  patch?: never;
7353
7418
  trace?: never;
7354
7419
  };
7420
+ "device.deleted": {
7421
+ parameters: {
7422
+ query?: never;
7423
+ header?: never;
7424
+ path?: never;
7425
+ cookie?: never;
7426
+ };
7427
+ get?: never;
7428
+ put?: never;
7429
+ /**
7430
+ * device.deleted
7431
+ * @description A number of the account was deleted: its slot of the plan is free again.
7432
+ */
7433
+ post: {
7434
+ parameters: {
7435
+ query?: never;
7436
+ header?: never;
7437
+ path?: never;
7438
+ cookie?: never;
7439
+ };
7440
+ requestBody?: {
7441
+ content: {
7442
+ "application/json": {
7443
+ data?: {
7444
+ device: components["schemas"]["PendingWebhookDevice"];
7445
+ /** Format: date-time */
7446
+ deleted_at: string;
7447
+ /** @description The connect link that last connected the number, or `null`. */
7448
+ connect_link_id?: number | null;
7449
+ };
7450
+ };
7451
+ };
7452
+ };
7453
+ responses: never;
7454
+ };
7455
+ delete?: never;
7456
+ options?: never;
7457
+ head?: never;
7458
+ patch?: never;
7459
+ trace?: never;
7460
+ };
7461
+ "device.health_changed": {
7462
+ parameters: {
7463
+ query?: never;
7464
+ header?: never;
7465
+ path?: never;
7466
+ cookie?: never;
7467
+ };
7468
+ get?: never;
7469
+ put?: never;
7470
+ /**
7471
+ * device.health_changed
7472
+ * @description The health of an official number changed (what Meta lets it do). Emitted only when the overall state changes.
7473
+ */
7474
+ post: {
7475
+ parameters: {
7476
+ query?: never;
7477
+ header?: never;
7478
+ path?: never;
7479
+ cookie?: never;
7480
+ };
7481
+ requestBody?: {
7482
+ content: {
7483
+ "application/json": {
7484
+ data?: {
7485
+ device: components["schemas"]["PendingWebhookDevice"];
7486
+ /** @enum {string} */
7487
+ previous_state: "available" | "limited" | "blocked" | "unknown";
7488
+ /** @enum {string} */
7489
+ state: "available" | "limited" | "blocked" | "unknown";
7490
+ /** Format: date-time */
7491
+ changed_at: string;
7492
+ /** @description The connect link that last connected the number, or `null`. */
7493
+ connect_link_id?: number | null;
7494
+ };
7495
+ };
7496
+ };
7497
+ };
7498
+ responses: never;
7499
+ };
7500
+ delete?: never;
7501
+ options?: never;
7502
+ head?: never;
7503
+ patch?: never;
7504
+ trace?: never;
7505
+ };
7355
7506
  }
7356
7507
  interface components {
7357
7508
  schemas: {
@@ -8422,6 +8573,8 @@ interface components {
8422
8573
  /** @description The statuses `message.status_changed` reports for the messages of this number. */
8423
8574
  statuses: ("sent" | "delivered" | "read" | "failed")[];
8424
8575
  };
8576
+ connection?: components["schemas"]["PendingDeviceConnection"];
8577
+ external_reference?: components["schemas"]["PendingExternalReference"];
8425
8578
  };
8426
8579
  /** DisconnectSurveyResource */
8427
8580
  DisconnectSurveyResource: {
@@ -9441,7 +9594,7 @@ interface components {
9441
9594
  /** @description `https`, public and without user or password. */
9442
9595
  url: string;
9443
9596
  description?: string | null;
9444
- /** @description Types of the catalog (`GET /api/v1/webhooks/events`). The key needs the `{area}:read` permission of the area of each type. */
9597
+ /** @description Types of the catalog (`GET /api/v1/webhooks/events`). The key needs the **View** permission of the area of each type in the panel (`{area}:read`), such as **WhatsApp numbers → View** (`accounts:read`). */
9445
9598
  events: string[];
9446
9599
  filters?: components["schemas"]["PendingWebhookSubscriptionFilters"] | null;
9447
9600
  };
@@ -9587,6 +9740,115 @@ interface components {
9587
9740
  /** Format: date-time */
9588
9741
  updated_at?: string | null;
9589
9742
  };
9743
+ /**
9744
+ * @description `qr`: connected by scanning a QR code (not official). `coexistence`: WhatsApp Cloud API together with the WhatsApp Business app. `dedicated`: WhatsApp Cloud API only. `null` when it cannot be told yet.
9745
+ * @enum {string|null}
9746
+ */
9747
+ PendingDeviceConnection: "qr" | "coexistence" | "dedicated" | null;
9748
+ /** @description Your own reference for the number (for example the id of your customer). Free text, not unique. */
9749
+ PendingExternalReference: string | null;
9750
+ PendingDeviceCreate: {
9751
+ /**
9752
+ * @description How the number connects. Only `qr` for now: an official number is created through a connect link.
9753
+ * @enum {string}
9754
+ */
9755
+ connection: "qr";
9756
+ /** @description The name of the number in the panel. */
9757
+ alias?: string;
9758
+ external_reference?: components["schemas"]["PendingExternalReference"];
9759
+ /** @description Adds QR to a number that already exists (in coexistence) instead of taking a new slot of the plan. */
9760
+ same_number_as?: number;
9761
+ country?: components["schemas"]["PendingCountry"];
9762
+ };
9763
+ PendingDeviceQr: {
9764
+ connected: boolean;
9765
+ /** @description A PNG image as a data URI, or `null` when the number is already connected. */
9766
+ qr_code: string | null;
9767
+ /** @description Seconds after which to ask for it again: 5 with a QR, 3 while the session starts, 0 once connected. WhatsApp changes the code every few seconds and an old one no longer links: show the latest one and have it scanned right away; do not store or forward a QR. */
9768
+ expires_in: number;
9769
+ };
9770
+ /** @enum {string} */
9771
+ PendingConnectLinkStatus: "pending" | "completed" | "failed" | "expired" | "revoked";
9772
+ /**
9773
+ * @description Why the link did not complete, or `null`.
9774
+ * @enum {string|null}
9775
+ */
9776
+ PendingConnectLinkErrorCode: "link_expired" | "already_used" | "revoked" | "quota_exceeded" | "trial_number_blocked" | "facebook_auth_failed" | "meta_error" | "number_not_owned" | "qr_timeout" | "provider_error" | null;
9777
+ /** @enum {string} */
9778
+ PendingConnectLinkConnectionType: "coexistence" | "dedicated";
9779
+ PendingConnectLink: {
9780
+ id: number;
9781
+ /** @enum {string} */
9782
+ type: "meta" | "qr";
9783
+ /** @description A Meta link stays `pending` after a failure of Facebook or Meta, so your customer can try again on the page; the fifth failed attempt turns it `failed` (`facebook_auth_failed` or `meta_error`). `quota_exceeded`, `trial_number_blocked` and `number_not_owned` close it at the first attempt. */
9784
+ status: components["schemas"]["PendingConnectLinkStatus"];
9785
+ /** @description The page to send your customer to. It carries the token, so it comes only in the response of `POST connect-links`. */
9786
+ url?: string | null;
9787
+ /** Format: date-time */
9788
+ expires_at: string;
9789
+ allowed_connection_types: components["schemas"]["PendingConnectLinkConnectionType"][] | null;
9790
+ provision_us_number: boolean;
9791
+ /** @description Only `type: qr`: the country the WhatsApp session is opened from, lowercase; `null` when it was not sent. */
9792
+ country: string | null;
9793
+ /** @description The number the link reconnects, or the one it created once `completed`; `null` otherwise. */
9794
+ device_id: number | null;
9795
+ external_reference: components["schemas"]["PendingExternalReference"];
9796
+ return_url: string | null;
9797
+ /** @description Why the link did not complete (`link_expired` when it expired, `revoked` when revoked), or `null`. */
9798
+ error_code: components["schemas"]["PendingConnectLinkErrorCode"];
9799
+ /** Format: date-time */
9800
+ created_at: string;
9801
+ /** Format: date-time */
9802
+ completed_at: string | null;
9803
+ };
9804
+ PendingConnectLinkWithUrl: components["schemas"]["PendingConnectLink"] & {
9805
+ url: string;
9806
+ };
9807
+ PendingConnectLinkCreate: {
9808
+ /** @enum {string} */
9809
+ type: "meta";
9810
+ /** @description With both, your customer chooses on the page. */
9811
+ allowed_connection_types: components["schemas"]["PendingConnectLinkConnectionType"][];
9812
+ /** @description Offers a US number of the pool (3 per account, 1 on trial accounts, held 15 minutes). `false` by default. A pool number is always dedicated: it needs `dedicated` in `allowed_connection_types` and does not go with `device_id`; otherwise `422 invalid_request`. */
9813
+ provision_us_number?: boolean;
9814
+ /** @description Reconnects this number instead of creating one; takes no new slot. `type` must match how the number connects. */
9815
+ device_id?: number;
9816
+ external_reference?: components["schemas"]["PendingExternalReference"];
9817
+ /**
9818
+ * Format: uri
9819
+ * @description Only `https`. When the page finishes it redirects there with `connect_link_id`, `status`, `device_id` and `error_code`.
9820
+ */
9821
+ return_url?: string;
9822
+ /** @description 1440 (24 hours) by default. */
9823
+ expires_in_minutes?: number;
9824
+ } | {
9825
+ /** @enum {string} */
9826
+ type: "qr";
9827
+ /** @description Adds QR to a number in coexistence. */
9828
+ same_number_as?: number;
9829
+ /** @description The country of the phone that will scan the QR code (ISO 3166-1 alpha-2): the WhatsApp session is opened from there. Not with `device_id` (`422 invalid_request`): a reconnection creates nothing. */
9830
+ country?: components["schemas"]["PendingCountry"];
9831
+ /** @description Reconnects this number instead of creating one; takes no new slot. `type` must match how the number connects. */
9832
+ device_id?: number;
9833
+ external_reference?: components["schemas"]["PendingExternalReference"];
9834
+ /**
9835
+ * Format: uri
9836
+ * @description Only `https`. When the page finishes it redirects there with `connect_link_id`, `status`, `device_id` and `error_code`.
9837
+ */
9838
+ return_url?: string;
9839
+ /** @description 1440 (24 hours) by default. */
9840
+ expires_in_minutes?: number;
9841
+ };
9842
+ PendingWebhookDevice: {
9843
+ id: number;
9844
+ name: string | null;
9845
+ /** @description Digits only, without `+`. */
9846
+ number: string | null;
9847
+ connection?: components["schemas"]["PendingDeviceConnection"];
9848
+ external_reference?: components["schemas"]["PendingExternalReference"];
9849
+ };
9850
+ /** @description The country of the phone that will scan the QR code (ISO 3166-1 alpha-2, two letters, any case): the WhatsApp session is opened from there. Without it, Funnelchat chooses one. */
9851
+ PendingCountry: string | null;
9590
9852
  };
9591
9853
  responses: {
9592
9854
  /** @description Unauthenticated */
@@ -17432,7 +17694,10 @@ interface operations {
17432
17694
  };
17433
17695
  "device.index": {
17434
17696
  parameters: {
17435
- query?: never;
17697
+ query?: {
17698
+ /** @description Only the numbers with this reference (exact match). */
17699
+ external_reference?: string;
17700
+ };
17436
17701
  header?: never;
17437
17702
  path?: never;
17438
17703
  cookie?: never;
@@ -17483,6 +17748,35 @@ interface operations {
17483
17748
  403: components["responses"]["AccountsAuthorizationException"];
17484
17749
  };
17485
17750
  };
17751
+ "pendingDevice.store": {
17752
+ parameters: {
17753
+ query?: never;
17754
+ header?: {
17755
+ /** @description Kept 24 hours per account and resource. Only a 2xx is replayed, with `Idempotent-Replayed: true`; a rejection is evaluated again. The same key with another body: `422 idempotency_key_mismatch`; while the first call runs: `409 operation_in_progress`; a malformed key: `422 invalid_idempotency_key`. */
17756
+ "Idempotency-Key"?: string;
17757
+ };
17758
+ path?: never;
17759
+ cookie?: never;
17760
+ };
17761
+ requestBody: {
17762
+ content: {
17763
+ "application/json": components["schemas"]["PendingDeviceCreate"];
17764
+ };
17765
+ };
17766
+ responses: {
17767
+ /** @description Created, with `connected: false` and `connection: "qr"`. */
17768
+ 201: {
17769
+ headers: {
17770
+ [name: string]: unknown;
17771
+ };
17772
+ content: {
17773
+ "application/json": {
17774
+ data: components["schemas"]["DeviceResource"];
17775
+ };
17776
+ };
17777
+ };
17778
+ };
17779
+ };
17486
17780
  "device.me": {
17487
17781
  parameters: {
17488
17782
  query?: never;
@@ -17640,6 +17934,7 @@ interface operations {
17640
17934
  * account (defense in depth, see updateMetaDevice below).
17641
17935
  */
17642
17936
  capi_consent?: boolean;
17937
+ external_reference?: components["schemas"]["PendingExternalReference"];
17643
17938
  };
17644
17939
  };
17645
17940
  };
@@ -19733,6 +20028,134 @@ interface operations {
19733
20028
  };
19734
20029
  };
19735
20030
  };
20031
+ "pendingDevice.qr": {
20032
+ parameters: {
20033
+ query?: never;
20034
+ header?: never;
20035
+ path: {
20036
+ /** @description The device ID */
20037
+ device: number;
20038
+ };
20039
+ cookie?: never;
20040
+ };
20041
+ requestBody?: never;
20042
+ responses: {
20043
+ /** @description OK */
20044
+ 200: {
20045
+ headers: {
20046
+ [name: string]: unknown;
20047
+ };
20048
+ content: {
20049
+ "application/json": {
20050
+ data: components["schemas"]["PendingDeviceQr"];
20051
+ };
20052
+ };
20053
+ };
20054
+ };
20055
+ };
20056
+ "pendingConnectLink.index": {
20057
+ parameters: {
20058
+ query?: {
20059
+ status?: components["schemas"]["PendingConnectLinkStatus"];
20060
+ /** @description Exact match. */
20061
+ external_reference?: string;
20062
+ perPage?: number;
20063
+ page?: number;
20064
+ };
20065
+ header?: never;
20066
+ path?: never;
20067
+ cookie?: never;
20068
+ };
20069
+ requestBody?: never;
20070
+ responses: {
20071
+ /** @description OK */
20072
+ 200: {
20073
+ headers: {
20074
+ [name: string]: unknown;
20075
+ };
20076
+ content: {
20077
+ "application/json": {
20078
+ data: components["schemas"]["PendingConnectLink"][];
20079
+ links?: Record<string, unknown>;
20080
+ meta?: Record<string, unknown>;
20081
+ };
20082
+ };
20083
+ };
20084
+ };
20085
+ };
20086
+ "pendingConnectLink.store": {
20087
+ parameters: {
20088
+ query?: never;
20089
+ header?: {
20090
+ /** @description Kept 24 hours per account. The same key with the same body answers the same response without creating another resource; with another body, `422 idempotency_key_mismatch`; while the first call runs, `409 operation_in_progress`. */
20091
+ "Idempotency-Key"?: string;
20092
+ };
20093
+ path?: never;
20094
+ cookie?: never;
20095
+ };
20096
+ requestBody: {
20097
+ content: {
20098
+ "application/json": components["schemas"]["PendingConnectLinkCreate"];
20099
+ };
20100
+ };
20101
+ responses: {
20102
+ /** @description Created. `url` carries the token and is shown only here. */
20103
+ 201: {
20104
+ headers: {
20105
+ [name: string]: unknown;
20106
+ };
20107
+ content: {
20108
+ "application/json": {
20109
+ data: components["schemas"]["PendingConnectLinkWithUrl"];
20110
+ };
20111
+ };
20112
+ };
20113
+ };
20114
+ };
20115
+ "pendingConnectLink.show": {
20116
+ parameters: {
20117
+ query?: never;
20118
+ header?: never;
20119
+ path: {
20120
+ link: number;
20121
+ };
20122
+ cookie?: never;
20123
+ };
20124
+ requestBody?: never;
20125
+ responses: {
20126
+ /** @description OK */
20127
+ 200: {
20128
+ headers: {
20129
+ [name: string]: unknown;
20130
+ };
20131
+ content: {
20132
+ "application/json": {
20133
+ data: components["schemas"]["PendingConnectLink"];
20134
+ };
20135
+ };
20136
+ };
20137
+ };
20138
+ };
20139
+ "pendingConnectLink.destroy": {
20140
+ parameters: {
20141
+ query?: never;
20142
+ header?: never;
20143
+ path: {
20144
+ link: number;
20145
+ };
20146
+ cookie?: never;
20147
+ };
20148
+ requestBody?: never;
20149
+ responses: {
20150
+ /** @description No Content */
20151
+ 204: {
20152
+ headers: {
20153
+ [name: string]: unknown;
20154
+ };
20155
+ content?: never;
20156
+ };
20157
+ };
20158
+ };
19736
20159
  "webhook.group_created": {
19737
20160
  parameters: {
19738
20161
  query?: never;
@@ -20634,13 +21057,24 @@ interface RequestOptions {
20634
21057
  /** Overrides the client's `maxRetries` for this request. */
20635
21058
  maxRetries?: number;
20636
21059
  /**
20637
- * Allows automatic retries of a non-idempotent send (`POST` with `conversations:send`) for this
20638
- * request. Off by default: a retried send can deliver the same message twice.
21060
+ * Allows automatic retries of a non-idempotent send for this request: a `POST` that needs
21061
+ * **Contacts and conversations → Send** (`conversations:send`). Off by default: a retried send
21062
+ * can deliver the same message twice.
20639
21063
  */
20640
21064
  retrySend?: boolean;
20641
21065
  /** Cancels the request. */
20642
21066
  signal?: AbortSignal;
20643
21067
  }
21068
+ /** Options of the creates that take an `Idempotency-Key` (`devices.create`, `connectLinks.create`). */
21069
+ interface IdempotentRequestOptions extends RequestOptions {
21070
+ /**
21071
+ * Sent as the `Idempotency-Key` header (up to 255 characters, kept 24 hours per account). The same
21072
+ * key with the same body answers the same response without creating another resource, so after a
21073
+ * timeout or a `5xx` you can repeat the call with it safely. With another body: `422
21074
+ * idempotency_key_mismatch`; while the first call runs: `409 operation_in_progress`.
21075
+ */
21076
+ idempotencyKey?: string;
21077
+ }
20644
21078
  type PathPart<P extends ApiPath, M extends HttpMethod> = PathParams<P, M> extends undefined ? {
20645
21079
  path?: undefined;
20646
21080
  } : {
@@ -20688,6 +21122,67 @@ declare abstract class Resource {
20688
21122
  #private;
20689
21123
  constructor(client: Funnelchat);
20690
21124
  protected get client(): Funnelchat;
21125
+ /** The options of a request with `idempotencyKey` turned into the `Idempotency-Key` header. */
21126
+ protected idempotent({ idempotencyKey, ...options }?: IdempotentRequestOptions): RequestOptions;
21127
+ }
21128
+
21129
+ type LinkId = PathParams<'/api/v1/connect-links/{link}', 'GET'>['link'];
21130
+ /**
21131
+ * Connect links (accounts area): a single-use page, on the Funnelchat domain, where your customer
21132
+ * connects a WhatsApp number to your account, by QR code (`type: 'qr'`) or as an official number
21133
+ * through the Meta sign-up (`type: 'meta'`). The number is created when the page finishes; with
21134
+ * `device_id` the link reconnects that number instead, without taking a new slot. The Meta sign-up
21135
+ * is not available in production yet: `type: 'meta'` answers `503 meta_connect_disabled` until it is.
21136
+ *
21137
+ * Reading needs **WhatsApp numbers → View** (`accounts:read`); creating and revoking,
21138
+ * **WhatsApp numbers → Create, connect and delete** (`accounts:operate`). The result arrives three
21139
+ * ways: the `device.connected` webhook (with `connect_link_id` and `external_reference`), the
21140
+ * `return_url`, or `get`. The other `device.*` events carry the link that last connected the number.
21141
+ *
21142
+ * Errors of their own (`APIError.code`): the rejections of `devices.create`, `429
21143
+ * too_many_open_links` (20 open links per account), `503 meta_connect_disabled`, `422
21144
+ * connection_type_mismatch` (`device_id` of a number that connects another way) and `409
21145
+ * link_not_pending` (revoking a link that already ended).
21146
+ */
21147
+ declare class ConnectLinks extends Resource {
21148
+ /**
21149
+ * `POST /api/v1/connect-links`. `url` is the page to send your customer to: it carries the token
21150
+ * and comes only in this response.
21151
+ *
21152
+ * `provision_us_number` (a US number of the pool, always dedicated) needs `dedicated` in
21153
+ * `allowed_connection_types` and does not go with `device_id`: otherwise `422 invalid_request`.
21154
+ * A Meta link stays `pending` after a failure of Facebook or Meta, so your customer can try again;
21155
+ * the fifth failed attempt turns it `failed`.
21156
+ *
21157
+ * `country` (only `qr`, not with `device_id`) is the country of the phone that will scan the QR, in
21158
+ * two letters: the WhatsApp session is opened from there. The link returns it, lowercase.
21159
+ */
21160
+ create(body: Body<'/api/v1/connect-links', 'POST'>, options?: IdempotentRequestOptions): APIPromise<{
21161
+ data: components["schemas"]["PendingConnectLinkWithUrl"];
21162
+ }>;
21163
+ /** `GET /api/v1/connect-links/{link}`: its `status`, and `device_id` and `error_code` once it ends. */
21164
+ get(link: LinkId, options?: RequestOptions): APIPromise<{
21165
+ data: components["schemas"]["PendingConnectLink"];
21166
+ }>;
21167
+ /** `GET /api/v1/connect-links`, paginated, newest first: filter by `status` or `external_reference`. */
21168
+ list(query?: Query<'/api/v1/connect-links'>, options?: RequestOptions): PagePromise<{
21169
+ id: number;
21170
+ type: "meta" | "qr";
21171
+ status: components["schemas"]["PendingConnectLinkStatus"];
21172
+ url?: string | null;
21173
+ expires_at: string;
21174
+ allowed_connection_types: components["schemas"]["PendingConnectLinkConnectionType"][] | null;
21175
+ provision_us_number: boolean;
21176
+ country: string | null;
21177
+ device_id: number | null;
21178
+ external_reference: components["schemas"]["PendingExternalReference"];
21179
+ return_url: string | null;
21180
+ error_code: components["schemas"]["PendingConnectLinkErrorCode"];
21181
+ created_at: string;
21182
+ completed_at: string | null;
21183
+ }>;
21184
+ /** `DELETE /api/v1/connect-links/{link}`: revokes a `pending` link (any other is `409 link_not_pending`). */
21185
+ revoke(link: LinkId, options?: RequestOptions): APIPromise<unknown>;
20691
21186
  }
20692
21187
 
20693
21188
  type ContactId$2 = PathParams<'/api/v1/contacts/{contact}', 'GET'>['contact'];
@@ -21080,50 +21575,30 @@ declare class CustomFields extends Resource {
21080
21575
  }
21081
21576
 
21082
21577
  type DeviceId$3 = PathParams<'/api/v1/devices/{device}', 'GET'>['device'];
21578
+ type Device = ListItem<'/api/v1/devices'>;
21083
21579
  /** WhatsApp numbers of the account (accounts area). The `id` of a number is the `device_id` used to send. */
21084
21580
  declare class Devices extends Resource {
21085
- /** `GET /api/v1/devices`. Iterate it with `for await`, or `await` it for the first page. */
21086
- list(options?: RequestOptions): PagePromise<{
21087
- id: number;
21088
- alias: string;
21089
- image: string;
21090
- color: string;
21091
- number: string;
21092
- normalized_number: string;
21093
- first_conecction_at: string;
21094
- user_id: number;
21095
- provider: components["schemas"]["WhatsAppProviderEnum"];
21096
- waba_id: string;
21097
- whatsapp_username: string | null;
21098
- is_business: number;
21099
- connected: number;
21100
- active: number | null;
21101
- health: string;
21102
- number_key?: string | null;
21103
- number_key_confirmed?: boolean;
21104
- is_coexistence?: boolean;
21105
- slot_state?: "free" | "reserved" | "pending" | "held";
21106
- pool_suspended?: boolean;
21107
- pool_suspension_reason?: "over_pool" | "payment_lapse" | null;
21108
- pool_keep?: boolean;
21109
- qr_allowed?: boolean;
21110
- can_change_to_meta?: boolean;
21111
- capabilities: {
21112
- messages: {
21113
- text: boolean;
21114
- media: boolean;
21115
- buttons: boolean;
21116
- lists: boolean;
21117
- templates: boolean;
21118
- location: boolean;
21119
- voice_note: boolean;
21120
- polls: boolean;
21121
- events: boolean;
21122
- contact_card: boolean;
21123
- reactions: boolean;
21124
- };
21125
- statuses: ("sent" | "delivered" | "read" | "failed")[];
21126
- };
21581
+ /**
21582
+ * `GET /api/v1/devices`. Iterate it with `for await`, or `await` it for the first page.
21583
+ * `external_reference` keeps only the numbers with that reference (exact match).
21584
+ */
21585
+ list(query?: Query<'/api/v1/devices'>, options?: RequestOptions): PagePromise<Device>;
21586
+ /** @deprecated The 0.1.2 signature, still supported: pass the options second, `list({}, options)`. */
21587
+ list(options: RequestOptions): PagePromise<Device>;
21588
+ /**
21589
+ * `POST /api/v1/devices`: creates a number that connects by QR code (`connection: 'qr'`), with
21590
+ * `connected: false`. Then show its QR with `qr`, or send your customer a connect link
21591
+ * (`connectLinks.create`). Needs **WhatsApp numbers → Create, connect and delete**
21592
+ * (`accounts:operate`). It takes a slot of the plan, with the panel's
21593
+ * rejections: `403 numbers_not_included`, `403 number_limit_reached`, `422 qr_requires_coexistence`
21594
+ * and `422 method_already_present` (`same_number_as` adds QR to a number in coexistence instead).
21595
+ * An account has at most one QR number waiting to be scanned: another one is `409
21596
+ * pending_number_exists`, with that number's `device_id` in `error.body`. `country` (two letters,
21597
+ * such as `'br'`) is the country of the phone that will scan the QR: the WhatsApp session is opened
21598
+ * from there.
21599
+ */
21600
+ create(body: Body<'/api/v1/devices', 'POST'>, options?: IdempotentRequestOptions): APIPromise<{
21601
+ data: components["schemas"]["DeviceResource"];
21127
21602
  }>;
21128
21603
  /**
21129
21604
  * `GET /api/v1/devices/{device}`. `capabilities` says what the number can do by API: message
@@ -21170,8 +21645,17 @@ declare class Devices extends Resource {
21170
21645
  };
21171
21646
  statuses: ("sent" | "delivered" | "read" | "failed")[];
21172
21647
  };
21648
+ connection?: components["schemas"]["PendingDeviceConnection"];
21649
+ external_reference?: components["schemas"]["PendingExternalReference"];
21173
21650
  }>;
21174
- /** `PUT /api/v1/devices/{device}`. */
21651
+ /**
21652
+ * `DELETE /api/v1/devices/{device}`: deletes the number and frees its slot of the plan. An
21653
+ * official number stops receiving through Funnelchat but stays registered with Meta; a QR one
21654
+ * logs out. Irreversible; needs **WhatsApp numbers → Create, connect and delete**
21655
+ * (`accounts:operate`). Sends `device.deleted`.
21656
+ */
21657
+ delete(device: DeviceId$3, options?: RequestOptions): APIPromise<Record<string, unknown>>;
21658
+ /** `PUT /api/v1/devices/{device}`: also changes `external_reference`. */
21175
21659
  update(device: DeviceId$3, body: Body<'/api/v1/devices/{device}', 'PUT'>, options?: RequestOptions): APIPromise<{
21176
21660
  id: number;
21177
21661
  alias: string;
@@ -21213,6 +21697,21 @@ declare class Devices extends Resource {
21213
21697
  };
21214
21698
  statuses: ("sent" | "delivered" | "read" | "failed")[];
21215
21699
  };
21700
+ connection?: components["schemas"]["PendingDeviceConnection"];
21701
+ external_reference?: components["schemas"]["PendingExternalReference"];
21702
+ }>;
21703
+ /**
21704
+ * `GET /api/v1/devices/{device}/qr`: the QR code to scan, as a PNG data URI (`qr_code`), or `null`
21705
+ * once `connected`. Ask for it every `expires_in` seconds (5 with a QR, 3 while the session starts,
21706
+ * 0 once connected) and have it scanned right away: WhatsApp changes the code every few seconds and
21707
+ * an old one no longer links, so show the latest and never store or forward a QR. Only for QR
21708
+ * numbers (an official one is `422 provider_unsupported`); needs
21709
+ * **WhatsApp numbers → Create, connect and delete** (`accounts:operate`), since scanning it gives
21710
+ * control of a WhatsApp. A number that cannot connect now
21711
+ * answers `409` (`trial_number_blocked`, `number_suspended_by_plan`, `device_inactive`…).
21712
+ */
21713
+ qr(device: DeviceId$3, options?: RequestOptions): APIPromise<{
21714
+ data: components["schemas"]["PendingDeviceQr"];
21216
21715
  }>;
21217
21716
  /** `GET /api/v1/devices/{device}/status`: connection status. */
21218
21717
  status(device: DeviceId$3, options?: RequestOptions): APIPromise<Record<string, unknown>>;
@@ -21250,7 +21749,8 @@ type RunId = PathParams<'/api/v1/forms/families/{familyId}/responses/{runId}', '
21250
21749
  type DeviceId$2 = PathParams<'/api/v1/forms/{id}/numbers/{deviceId}', 'DELETE'>['deviceId'];
21251
21750
  /**
21252
21751
  * WhatsApp forms (conversations area): build them, publish them on your numbers and read the
21253
- * answers. Reading needs `conversations:read`; the rest, `conversations:write`.
21752
+ * answers. Reading needs **Contacts and conversations → View** (`conversations:read`); the rest,
21753
+ * **Contacts and conversations → Edit** (`conversations:write`).
21254
21754
  *
21255
21755
  * Two ids: `id` is one version of a form; `family_id` is the form itself (every version). You send
21256
21756
  * a form by its `family_id` with `messages.sendForm`, and `whatsapp_form.completed` brings it as
@@ -21407,7 +21907,7 @@ declare class Forms extends Resource {
21407
21907
  type GroupId = PathParams<'/api/v1/groups/{group}', 'GET'>['group'];
21408
21908
  type GroupUid = PathParams<'/api/v1/groups/{groupUid}/metadata', 'GET'>['groupUid'];
21409
21909
  type DeviceId$1 = PathParams<'/api/v1/devices/{device}/groups', 'GET'>['device'];
21410
- /** WhatsApp groups (communities area): read them, their participants, events and messages. Permission `communities:read`. */
21910
+ /** WhatsApp groups (communities area): read them, their participants, events and messages. Permission: **Groups and campaigns → View** (`communities:read`). */
21411
21911
  declare class Groups extends Resource {
21412
21912
  /** `GET /api/v1/groups`, paginated. */
21413
21913
  list(query?: Query<'/api/v1/groups'>, options?: RequestOptions): PagePromise<{
@@ -21614,8 +22114,8 @@ type SendMessageParams = Omit<SendMessageBody, 'contact_id'> & {
21614
22114
  * delivered. The rest arrives by `message.status_changed` (with the same `id` as `message_id`) or
21615
22115
  * with {@link Messages.get}.
21616
22116
  *
21617
- * Sending with an API key needs the `conversations:send` permission and is subject to the
21618
- * WhatsApp rules: `422 window_closed`, `422 antiblock_*`, `422 recipient_*`,
22117
+ * Sending with an API key needs **Contacts and conversations → Send** (`conversations:send`) and
22118
+ * is subject to the WhatsApp rules: `422 window_closed`, `422 antiblock_*`, `422 recipient_*`,
21619
22119
  * `422 provider_unsupported`, `429 rate_limited` (with `retryAfter`) and `429 mac_lockout_24h`. A
21620
22120
  * rejected send stores nothing (see `SEND_ERROR_CODES`). Sends are never retried automatically
21621
22121
  * unless you pass `retrySend: true`.
@@ -21929,7 +22429,7 @@ interface WebhookEventInfo {
21929
22429
  readonly pending: boolean;
21930
22430
  readonly description: string | null;
21931
22431
  }
21932
- /** Every webhook event type known to the spec (53). */
22432
+ /** Every webhook event type known to the spec (55). */
21933
22433
  declare const webhookEvents: readonly [{
21934
22434
  readonly type: "account.blocked";
21935
22435
  readonly domains: readonly ["accounts"];
@@ -22043,13 +22543,25 @@ declare const webhookEvents: readonly [{
22043
22543
  readonly domains: readonly ["accounts"];
22044
22544
  readonly status: "live";
22045
22545
  readonly pending: true;
22046
- readonly description: "One of the numbers of the account got connected: by scanning the QR code or by finishing the sign-up of a WhatsApp Cloud number.";
22546
+ readonly description: "One of the numbers of the account got connected: by scanning the QR code, by finishing the sign-up of a WhatsApp Cloud number, or through a connect link.";
22547
+ }, {
22548
+ readonly type: "device.deleted";
22549
+ readonly domains: readonly ["accounts"];
22550
+ readonly status: "planned";
22551
+ readonly pending: true;
22552
+ readonly description: "A number of the account was deleted: its slot of the plan is free again.";
22047
22553
  }, {
22048
22554
  readonly type: "device.disconnected";
22049
22555
  readonly domains: readonly ["accounts"];
22050
22556
  readonly status: "live";
22051
22557
  readonly pending: true;
22052
- readonly description: "One of the numbers of the account disconnected and can no longer send or receive.";
22558
+ readonly description: "One of the numbers of the account disconnected and can no longer send or receive: a QR session that closed or was protected from a shadow ban, an official number that failed its re-registration, or one disconnected from the panel.";
22559
+ }, {
22560
+ readonly type: "device.health_changed";
22561
+ readonly domains: readonly ["accounts"];
22562
+ readonly status: "planned";
22563
+ readonly pending: true;
22564
+ readonly description: "The health of an official number changed (what Meta lets it do). Emitted only when the overall state changes.";
22053
22565
  }, {
22054
22566
  readonly type: "flow.completed";
22055
22567
  readonly domains: readonly ["conversations"];
@@ -22411,25 +22923,36 @@ interface WebhookEventDataMap {
22411
22923
  leaves: number;
22412
22924
  conversion_rate: number;
22413
22925
  };
22414
- /** `device.connected` (live, pending of the spec; typed from: schema). One of the numbers of the account got connected: by scanning the QR code or by finishing the sign-up of a WhatsApp Cloud number. */
22926
+ /** `device.connected` (live, pending of the spec; typed from: schema). One of the numbers of the account got connected: by scanning the QR code, by finishing the sign-up of a WhatsApp Cloud number, or through a connect link. */
22415
22927
  "device.connected": {
22416
- device: {
22417
- id: number;
22418
- name: string | null;
22419
- /** Digits only, without `+`. */
22420
- number: string | null;
22421
- };
22928
+ device: components["schemas"]["PendingWebhookDevice"];
22422
22929
  connected_at: string;
22930
+ /** The connect link of this connection, or `null` when it did not come from a link. */
22931
+ connect_link_id?: number | null;
22932
+ };
22933
+ /** `device.deleted` (planned, pending of the spec; typed from: schema). A number of the account was deleted: its slot of the plan is free again. */
22934
+ "device.deleted": {
22935
+ device: components["schemas"]["PendingWebhookDevice"];
22936
+ deleted_at: string;
22937
+ /** The connect link that last connected the number, or `null`. */
22938
+ connect_link_id?: number | null;
22423
22939
  };
22424
- /** `device.disconnected` (live, pending of the spec; typed from: schema). One of the numbers of the account disconnected and can no longer send or receive. */
22940
+ /** `device.disconnected` (live, pending of the spec; typed from: schema). One of the numbers of the account disconnected and can no longer send or receive: a QR session that closed or was protected from a shadow ban, an official number that failed its re-registration, or one disconnected from the panel. */
22425
22941
  "device.disconnected": {
22426
- device: {
22427
- id: number;
22428
- name: string | null;
22429
- /** Digits only, without `+`. */
22430
- number: string | null;
22431
- };
22942
+ device: components["schemas"]["PendingWebhookDevice"];
22432
22943
  disconnected_at: string;
22944
+ reason?: "qr_logged_out" | "meta_account_not_registered" | "shadow_ban_protection" | "provider_error" | "unknown" | "disconnected_by_user";
22945
+ /** The connect link that last connected the number, or `null`. */
22946
+ connect_link_id?: number | null;
22947
+ };
22948
+ /** `device.health_changed` (planned, pending of the spec; typed from: schema). The health of an official number changed (what Meta lets it do). Emitted only when the overall state changes. */
22949
+ "device.health_changed": {
22950
+ device: components["schemas"]["PendingWebhookDevice"];
22951
+ previous_state: "available" | "limited" | "blocked" | "unknown";
22952
+ state: "available" | "limited" | "blocked" | "unknown";
22953
+ changed_at: string;
22954
+ /** The connect link that last connected the number, or `null`. */
22955
+ connect_link_id?: number | null;
22433
22956
  };
22434
22957
  /** `flow.completed` (live; typed from: example). Un contacto terminó un flujo de automatización. Se envía una sola vez por cada ejecución de un flujo, cuando termina con éxito. No se envía si la ejecución se cortó, se canceló, quedó bloqueada o falló. `contact` es `null` si la ejecución no tiene un contacto asociado. Un flujo muy usado puede generar muchos eventos seguidos. */
22435
22958
  "flow.completed": {
@@ -22868,7 +23391,9 @@ interface PendingEventData {
22868
23391
  * Sources (production, 22-10): platform-gate v0.8.0 as pinned by accounts v1.4.24; api-edge v0.3.0
22869
23392
  * (src/index.ts); conversations v1.18.10 (Message/Services/ApiSendGuard.php,
22870
23393
  * Message/Support/ApiKeySendResponse.php, WhatsappForm/Support/FormSendPreflight.php). The spec
22871
- * does not document most of them yet; when it does, this list can be generated.
23394
+ * does not document most of them yet; when it does, this list can be generated. The codes of
23395
+ * creating and connecting numbers come from contract 1022-alta-de-numeros v0.1 (23-10-2026, with
23396
+ * its amendment from accounts feat/alta-de-numeros-api 52d49b319), not from production yet.
22872
23397
  */
22873
23398
  /** Errors of the API entry and of the key gate, on any route. */
22874
23399
  declare const ACCESS_ERROR_CODES: {
@@ -22931,13 +23456,75 @@ declare const SEND_ERROR_CODES: {
22931
23456
  /** 422: the number cannot send forms. */
22932
23457
  readonly number_not_eligible: 422;
22933
23458
  };
23459
+ /**
23460
+ * Rejections of creating a number (`devices.create`), asking for its QR (`devices.qr`) or creating,
23461
+ * reading or revoking a connect link: nothing was created. The quota of the plan is the same as in
23462
+ * the panel. A code that comes with two statuses has the one of the create here; the other is noted.
23463
+ */
23464
+ declare const NUMBER_ERROR_CODES: {
23465
+ /** 403: the plan of the account does not include numbers. */
23466
+ readonly numbers_not_included: 403;
23467
+ /** 403: the account already uses every number of its plan (`limit`, `used`, `pending_device_ids` in the body). */
23468
+ readonly number_limit_reached: 403;
23469
+ /** 403: the account cannot connect numbers now. */
23470
+ readonly connect_not_allowed: 403;
23471
+ /** 403: `devices.qr` of a number whose payment is due. */
23472
+ readonly payment_required: 403;
23473
+ /**
23474
+ * 409: the account already has a QR number waiting to be scanned (at most one): its `device_id`
23475
+ * comes in the body. Show that one's QR, or delete it, instead of creating another.
23476
+ */
23477
+ readonly pending_number_exists: 409;
23478
+ /** 422 (409 on `devices.qr`): QR can only be added to an official number that is in coexistence. */
23479
+ readonly qr_requires_coexistence: 422;
23480
+ /** 422: the number already has that connection method; the body brings its `device_id`. */
23481
+ readonly method_already_present: 422;
23482
+ /** 422: `same_number_as` or `device_id` is not a number of the account that can take it. */
23483
+ readonly invalid_reference_device: 422;
23484
+ /** 422: a connect link with `device_id` of a number that connects another way than `type`. */
23485
+ readonly connection_type_mismatch: 422;
23486
+ /** 422 (409 on `devices.qr`): the number is suspended because the plan has fewer numbers than the account uses. */
23487
+ readonly number_suspended_by_plan: 422;
23488
+ /** 422: the body is not valid; `errors` says which fields. */
23489
+ readonly invalid_request: 422;
23490
+ /** 409: `devices.qr` of a trial number that is blocked. */
23491
+ readonly trial_number_blocked: 409;
23492
+ /** 409: `devices.qr` of a number that is turned off. */
23493
+ readonly device_inactive: 409;
23494
+ /** 409: `devices.qr` when no more QR sessions can be started now. */
23495
+ readonly provisioning_quota_exceeded: 409;
23496
+ /** 409: revoking a connect link that is no longer `pending`. */
23497
+ readonly link_not_pending: 409;
23498
+ /** 429: the account has 20 connect links open. Revoke some, or wait for them to end. Not worth retrying. */
23499
+ readonly too_many_open_links: 429;
23500
+ /** 500 (502 on `devices.qr`): the WhatsApp provider failed. */
23501
+ readonly provider_error: 500;
23502
+ /** 503: official numbers (`type: 'meta'`) cannot be connected by link yet. QR links work. Not worth retrying. */
23503
+ readonly meta_connect_disabled: 503;
23504
+ /** 403: the connect page was opened with an API key or a session. The page is for your customer, without credentials. */
23505
+ readonly credentials_not_allowed: 403;
23506
+ };
23507
+ /** Rejections of a create sent with `idempotencyKey`. */
23508
+ declare const IDEMPOTENCY_ERROR_CODES: {
23509
+ /** 422: the key was already used with another body. Use a new key for a new resource. */
23510
+ readonly idempotency_key_mismatch: 422;
23511
+ /** 422: the key is not 1 to 255 characters. */
23512
+ readonly invalid_idempotency_key: 422;
23513
+ /** 409: the first call with that key, or another operation on the number, is still running. Read the state, or repeat it later. */
23514
+ readonly operation_in_progress: 409;
23515
+ };
22934
23516
  type AccessErrorCode = keyof typeof ACCESS_ERROR_CODES;
22935
23517
  /** An error code of a send rejected by the WhatsApp rules (`APIError.code`). */
22936
23518
  type SendErrorCode = keyof typeof SEND_ERROR_CODES;
23519
+ /** An error code of creating a number or a connect link (`APIError.code`). */
23520
+ type NumberErrorCode = keyof typeof NUMBER_ERROR_CODES;
23521
+ type IdempotencyErrorCode = keyof typeof IDEMPOTENCY_ERROR_CODES;
22937
23522
  /** Every `error` code the SDK knows. The API can send others: treat `code` as a `string`. */
22938
- type KnownErrorCode = AccessErrorCode | SendErrorCode;
23523
+ type KnownErrorCode = AccessErrorCode | SendErrorCode | NumberErrorCode | IdempotencyErrorCode;
22939
23524
  /** Whether an `APIError.code` is a rejection of a send: nothing was sent and nothing was stored. */
22940
23525
  declare function isSendRuleError(code: string | undefined): code is SendErrorCode;
23526
+ /** Whether an `APIError.code` is a rejection by the number quota of the plan (the same as the panel's). */
23527
+ declare function isNumberQuotaError(code: string | undefined): code is 'numbers_not_included' | 'number_limit_reached' | 'pending_number_exists' | 'qr_requires_coexistence' | 'method_already_present';
22941
23528
 
22942
23529
  /**
22943
23530
  * Errors thrown by the SDK.
@@ -23030,14 +23617,16 @@ declare class UnprocessableEntityError extends APIError {
23030
23617
  }
23031
23618
  /**
23032
23619
  * `429`: rate limit (`rate_limited`, `daily_cap_exceeded`; `retryAfter` says how many seconds to
23033
- * wait) or the monthly active contacts (`mac_lockout_24h`, `mac_limit_reached`), which waiting
23034
- * does not fix.
23620
+ * wait), the monthly active contacts (`mac_lockout_24h`, `mac_limit_reached`) or the open connect
23621
+ * links (`too_many_open_links`), which waiting does not fix.
23035
23622
  */
23036
23623
  declare class RateLimitError extends APIError {
23037
23624
  }
23038
23625
  /**
23039
23626
  * `5xx`. `502 origin_unreachable` and `500 edge_misconfigured` come from the API entry. After a
23040
- * `5xx` on a write, read the state before repeating it: it may have been applied.
23627
+ * `5xx` on a write, read the state before repeating it: it may have been applied (or repeat a create
23628
+ * with the same `idempotencyKey`). `503 meta_connect_disabled`: official numbers cannot be connected
23629
+ * by link yet.
23041
23630
  */
23042
23631
  declare class InternalServerError extends APIError {
23043
23632
  }
@@ -23124,10 +23713,13 @@ type SubscriptionId = PathParams<'/api/v1/webhooks/{id}', 'GET'>['id'];
23124
23713
  /**
23125
23714
  * Webhook subscriptions (accounts area) and the verification of deliveries.
23126
23715
  *
23127
- * Reading needs `webhooks:read` and the rest `webhooks:write`; the catalog (`events()`) needs
23128
- * `accounts:read`. A key only sees and manages subscriptions to events of the areas it can read
23129
- * (`conversations:read`, `communities:read`, `accounts:read`): asking for others is a `422` on
23130
- * `events`, and touching a subscription that has them is `403 permission_denied`.
23716
+ * Reading needs **Notifications (webhooks) → View** (`webhooks:read`) and the rest
23717
+ * **Notifications (webhooks) → Manage** (`webhooks:write`); the catalog (`events()`) needs
23718
+ * **WhatsApp numbers → View** (`accounts:read`). A key only sees and manages subscriptions to
23719
+ * events of the areas it can read: **Contacts and conversations → View** (`conversations:read`),
23720
+ * **Groups and campaigns → View** (`communities:read`) and **WhatsApp numbers → View**
23721
+ * (`accounts:read`). Asking for others is a `422` on `events`, and touching a subscription that
23722
+ * has them is `403 permission_denied`.
23131
23723
  */
23132
23724
  declare class Webhooks extends Resource {
23133
23725
  /** Same as `Funnelchat.webhooks.verify`. */
@@ -23325,7 +23917,7 @@ declare class Funnelchat {
23325
23917
  readonly verify: typeof verify;
23326
23918
  readonly constructEvent: typeof constructEvent;
23327
23919
  };
23328
- static readonly VERSION = "0.1.2";
23920
+ static readonly VERSION = "0.2.1";
23329
23921
  readonly baseUrl: string;
23330
23922
  readonly timeoutMs: number;
23331
23923
  readonly maxRetries: number;
@@ -23339,6 +23931,8 @@ declare class Funnelchat {
23339
23931
  readonly customFields: CustomFields;
23340
23932
  readonly groups: Groups;
23341
23933
  readonly devices: Devices;
23934
+ /** Single-use pages where your customer connects a WhatsApp number to your account. */
23935
+ readonly connectLinks: ConnectLinks;
23342
23936
  /** Webhook subscriptions, plus `verify` and `constructEvent`. */
23343
23937
  readonly webhooks: Webhooks;
23344
23938
  constructor(options?: ClientOptions);
@@ -23384,10 +23978,10 @@ interface RouteInfo {
23384
23978
  readonly summary: string | null;
23385
23979
  readonly pending: boolean;
23386
23980
  }
23387
- /** Every operation of the spec (258), sorted by path. */
23981
+ /** Every operation of the spec (264), sorted by path. */
23388
23982
  declare const routes: readonly RouteInfo[];
23389
23983
 
23390
23984
  /** The SDK version, sent in the `User-Agent`. A test keeps it equal to package.json. */
23391
- declare const VERSION = "0.1.2";
23985
+ declare const VERSION = "0.2.1";
23392
23986
 
23393
- export { ACCESS_ERROR_CODES, APIConnectionError, APIConnectionTimeoutError, APIError, APIPromise, type APIResponse, APIUserAbortError, type AccessErrorCode, type ApiPath, AuthenticationError, BASE_URLS, BadRequestError, type Body, type ClientOptions, ConflictError, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DEFAULT_TOLERANCE_SECONDS, type Environment, type FieldErrors, Funnelchat, FunnelchatError, type HttpMethod, InternalServerError, type KnownErrorCode, type ListItem, NotFoundError, Page, PagePromise, type PathParams, PermissionDeniedError, type Query, type QueryParams, REQUEST_ID_HEADER, RateLimitError, type RawBody, type RequestBody, type RequestOptions, type ResponseBody, type RouteInfo, SEND_ERROR_CODES, SIGNATURE_HEADER, type SendErrorCode, type SendMessageParams, type TypedRequestOptions, UnprocessableEntityError, UnsupportedMediaTypeError, type UntypedRequestOptions, VERSION, type VerifyOptions, type WebhookEvent, type WebhookEventData, type WebhookEventEnvelope, type WebhookEventInfo, type WebhookEventOf, type WebhookEventType, type webhooks as WebhookSchemas, WebhookVerificationError, type WebhookVerificationFailure, type components, constructEvent, Funnelchat as default, isSendRuleError, type operations, type paths, routes, verify, webhookEvents };
23987
+ export { ACCESS_ERROR_CODES, APIConnectionError, APIConnectionTimeoutError, APIError, APIPromise, type APIResponse, APIUserAbortError, type AccessErrorCode, type ApiPath, AuthenticationError, BASE_URLS, BadRequestError, type Body, type ClientOptions, ConflictError, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DEFAULT_TOLERANCE_SECONDS, type Environment, type FieldErrors, Funnelchat, FunnelchatError, type HttpMethod, IDEMPOTENCY_ERROR_CODES, type IdempotencyErrorCode, type IdempotentRequestOptions, InternalServerError, type KnownErrorCode, type ListItem, NUMBER_ERROR_CODES, NotFoundError, type NumberErrorCode, Page, PagePromise, type PathParams, PermissionDeniedError, type Query, type QueryParams, REQUEST_ID_HEADER, RateLimitError, type RawBody, type RequestBody, type RequestOptions, type ResponseBody, type RouteInfo, SEND_ERROR_CODES, SIGNATURE_HEADER, type SendErrorCode, type SendMessageParams, type TypedRequestOptions, UnprocessableEntityError, UnsupportedMediaTypeError, type UntypedRequestOptions, VERSION, type VerifyOptions, type WebhookEvent, type WebhookEventData, type WebhookEventEnvelope, type WebhookEventInfo, type WebhookEventOf, type WebhookEventType, type webhooks as WebhookSchemas, WebhookVerificationError, type WebhookVerificationFailure, type components, constructEvent, Funnelchat as default, isNumberQuotaError, isSendRuleError, type operations, type paths, routes, verify, webhookEvents };