@zavudev/sdk 0.50.0 → 0.52.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/package.json +1 -1
  3. package/resources/functions/functions.d.mts +22 -8
  4. package/resources/functions/functions.d.mts.map +1 -1
  5. package/resources/functions/functions.d.ts +22 -8
  6. package/resources/functions/functions.d.ts.map +1 -1
  7. package/resources/functions/functions.js +6 -4
  8. package/resources/functions/functions.js.map +1 -1
  9. package/resources/functions/functions.mjs +6 -4
  10. package/resources/functions/functions.mjs.map +1 -1
  11. package/resources/invitations.d.mts +84 -23
  12. package/resources/invitations.d.mts.map +1 -1
  13. package/resources/invitations.d.ts +84 -23
  14. package/resources/invitations.d.ts.map +1 -1
  15. package/resources/invitations.js +13 -10
  16. package/resources/invitations.js.map +1 -1
  17. package/resources/invitations.mjs +13 -10
  18. package/resources/invitations.mjs.map +1 -1
  19. package/resources/messages.d.mts +66 -20
  20. package/resources/messages.d.mts.map +1 -1
  21. package/resources/messages.d.ts +66 -20
  22. package/resources/messages.d.ts.map +1 -1
  23. package/resources/messages.js +23 -3
  24. package/resources/messages.js.map +1 -1
  25. package/resources/messages.mjs +23 -3
  26. package/resources/messages.mjs.map +1 -1
  27. package/resources/number-10dlc/brands.d.mts +5 -1
  28. package/resources/number-10dlc/brands.d.mts.map +1 -1
  29. package/resources/number-10dlc/brands.d.ts +5 -1
  30. package/resources/number-10dlc/brands.d.ts.map +1 -1
  31. package/resources/number-10dlc/brands.js +5 -1
  32. package/resources/number-10dlc/brands.js.map +1 -1
  33. package/resources/number-10dlc/brands.mjs +5 -1
  34. package/resources/number-10dlc/brands.mjs.map +1 -1
  35. package/resources/number-10dlc/campaigns/campaigns.d.mts +6 -1
  36. package/resources/number-10dlc/campaigns/campaigns.d.mts.map +1 -1
  37. package/resources/number-10dlc/campaigns/campaigns.d.ts +6 -1
  38. package/resources/number-10dlc/campaigns/campaigns.d.ts.map +1 -1
  39. package/resources/number-10dlc/campaigns/campaigns.js +6 -1
  40. package/resources/number-10dlc/campaigns/campaigns.js.map +1 -1
  41. package/resources/number-10dlc/campaigns/campaigns.mjs +6 -1
  42. package/resources/number-10dlc/campaigns/campaigns.mjs.map +1 -1
  43. package/resources/phone-numbers.d.mts +5 -0
  44. package/resources/phone-numbers.d.mts.map +1 -1
  45. package/resources/phone-numbers.d.ts +5 -0
  46. package/resources/phone-numbers.d.ts.map +1 -1
  47. package/resources/senders/agent/agent.d.mts +307 -0
  48. package/resources/senders/agent/agent.d.mts.map +1 -1
  49. package/resources/senders/agent/agent.d.ts +307 -0
  50. package/resources/senders/agent/agent.d.ts.map +1 -1
  51. package/resources/senders/agent/agent.js +6 -0
  52. package/resources/senders/agent/agent.js.map +1 -1
  53. package/resources/senders/agent/agent.mjs +6 -0
  54. package/resources/senders/agent/agent.mjs.map +1 -1
  55. package/resources/senders/agent/executions.d.mts +5 -0
  56. package/resources/senders/agent/executions.d.mts.map +1 -1
  57. package/resources/senders/agent/executions.d.ts +5 -0
  58. package/resources/senders/agent/executions.d.ts.map +1 -1
  59. package/resources/senders/agent/executions.js +5 -0
  60. package/resources/senders/agent/executions.js.map +1 -1
  61. package/resources/senders/agent/executions.mjs +5 -0
  62. package/resources/senders/agent/executions.mjs.map +1 -1
  63. package/resources/senders/senders.d.mts +71 -21
  64. package/resources/senders/senders.d.mts.map +1 -1
  65. package/resources/senders/senders.d.ts +71 -21
  66. package/resources/senders/senders.d.ts.map +1 -1
  67. package/resources/senders/senders.js.map +1 -1
  68. package/resources/senders/senders.mjs.map +1 -1
  69. package/resources/templates.d.mts +12 -3
  70. package/resources/templates.d.mts.map +1 -1
  71. package/resources/templates.d.ts +12 -3
  72. package/resources/templates.d.ts.map +1 -1
  73. package/src/resources/functions/functions.ts +23 -8
  74. package/src/resources/invitations.ts +90 -23
  75. package/src/resources/messages.ts +67 -19
  76. package/src/resources/number-10dlc/brands.ts +5 -1
  77. package/src/resources/number-10dlc/campaigns/campaigns.ts +6 -1
  78. package/src/resources/phone-numbers.ts +6 -0
  79. package/src/resources/senders/agent/agent.ts +357 -0
  80. package/src/resources/senders/agent/executions.ts +5 -0
  81. package/src/resources/senders/senders.ts +78 -21
  82. package/src/resources/templates.ts +13 -4
  83. package/src/version.ts +1 -1
  84. package/version.d.mts +1 -1
  85. package/version.d.ts +1 -1
  86. package/version.js +1 -1
  87. package/version.mjs +1 -1
@@ -8,18 +8,21 @@ import { path } from '../internal/utils/path';
8
8
 
9
9
  export class Invitations extends APIResource {
10
10
  /**
11
- * Create a partner invitation link for a client to connect WhatsApp. The client
12
- * opens the returned `url` and connects. Set `connectionType` to choose how they
13
- * connect:
11
+ * Create a partner invitation link for a client to connect a Meta channel. The
12
+ * client opens the returned `url` and authorizes with Meta; the resulting sender
13
+ * is created in your project when they finish, and the invitation transitions to
14
+ * `completed`.
14
15
  *
15
- * - `whatsapp_waba` (default): the client completes Meta's embedded signup,
16
- * linking an official WhatsApp Business Account.
17
- * - `whatsapp_alt`: the client links their number by scanning a QR code. Requires
18
- * the WhatsApp Alternative feature to be enabled for your team (otherwise
19
- * returns 400).
16
+ * `connectionType` picks the channel:
20
17
  *
21
- * Either way, the resulting sender is created in your project when the client
22
- * completes the flow, and the invitation transitions to `completed`.
18
+ * - `whatsapp_waba` (default): Meta's embedded signup links an official WhatsApp
19
+ * Business Account.
20
+ * - `messenger`: the client picks a Facebook Page they administer; its Messenger
21
+ * inbox (including Marketplace chats) is routed to Zavu.
22
+ *
23
+ * One invitation connects one channel — create one per channel to onboard a client
24
+ * on several. `phoneNumberId` and `allowedPhoneCountries` apply to `whatsapp_waba`
25
+ * only.
23
26
  *
24
27
  * @example
25
28
  * ```ts
@@ -99,8 +102,13 @@ export interface Invitation {
99
102
 
100
103
  /**
101
104
  * Current status of the partner invitation.
105
+ *
106
+ * `failed` means the client started the connection and it did not finish (they
107
+ * cancelled Meta's dialog, denied a permission, or abandoned the tab). A failed
108
+ * invitation is still usable: the same link can be retried, and it moves back to
109
+ * `in_progress` when the client tries again.
102
110
  */
103
- status: 'pending' | 'in_progress' | 'completed' | 'expired' | 'cancelled';
111
+ status: 'pending' | 'in_progress' | 'completed' | 'expired' | 'cancelled' | 'failed';
104
112
 
105
113
  updatedAt: string;
106
114
 
@@ -118,13 +126,33 @@ export interface Invitation {
118
126
  completedAt?: string | null;
119
127
 
120
128
  /**
121
- * How the client connects WhatsApp: `whatsapp_waba` (official Cloud API via
122
- * embedded signup) or `whatsapp_alt` (QR-linked).
129
+ * The account the client linked, populated once the invitation is `completed`.
130
+ * Null before that. Use it to show the partner what was connected without fetching
131
+ * the sender.
132
+ */
133
+ connectedAccount?: Invitation.ConnectedAccount | null;
134
+
135
+ /**
136
+ * Which Meta channel the client connects: `whatsapp_waba` (official WhatsApp Cloud
137
+ * API via embedded signup) or `messenger` (a Facebook Page's Messenger inbox,
138
+ * including Marketplace chats).
139
+ */
140
+ connectionType?: 'whatsapp_waba' | 'messenger';
141
+
142
+ failedAt?: string | null;
143
+
144
+ /**
145
+ * Stable code for why the last attempt failed, present when `status` is `failed`.
146
+ * Values include `fb_cancelled` (client closed Meta's dialog), `fb_not_authorized`
147
+ * (permission denied), `signup_abandoned` (started but never finished),
148
+ * `meta_no_pages` (the client administers no Facebook Page), and `internal_error`.
149
+ * Treat unknown codes as a generic failure.
123
150
  */
124
- connectionType?: 'whatsapp_waba' | 'whatsapp_alt';
151
+ failureReason?: string | null;
125
152
 
126
153
  /**
127
- * ID of a pre-assigned Zavu phone number for WhatsApp registration.
154
+ * ID of a pre-assigned Zavu phone number for WhatsApp registration. Always null
155
+ * for `messenger` invitations.
128
156
  */
129
157
  phoneNumberId?: string | null;
130
158
 
@@ -138,6 +166,28 @@ export interface Invitation {
138
166
  viewedAt?: string | null;
139
167
  }
140
168
 
169
+ export namespace Invitation {
170
+ /**
171
+ * The account the client linked, populated once the invitation is `completed`.
172
+ * Null before that. Use it to show the partner what was connected without fetching
173
+ * the sender.
174
+ */
175
+ export interface ConnectedAccount {
176
+ /**
177
+ * Provider-side identifier: the WhatsApp phone number ID, or the Facebook Page ID.
178
+ */
179
+ id: string;
180
+
181
+ channel: 'whatsapp' | 'messenger';
182
+
183
+ /**
184
+ * Display name of the connected account: the WhatsApp verified name, or the
185
+ * Facebook Page name.
186
+ */
187
+ name?: string | null;
188
+ }
189
+ }
190
+
141
191
  export interface InvitationCreateResponse {
142
192
  invitation: Invitation;
143
193
  }
@@ -152,7 +202,8 @@ export interface InvitationCancelResponse {
152
202
 
153
203
  export interface InvitationCreateParams {
154
204
  /**
155
- * ISO country codes for allowed phone numbers.
205
+ * ISO country codes for allowed phone numbers. Only valid when `connectionType` is
206
+ * `whatsapp_waba` — sending it with `messenger` returns 400.
156
207
  */
157
208
  allowedPhoneCountries?: Array<string>;
158
209
 
@@ -172,12 +223,21 @@ export interface InvitationCreateParams {
172
223
  clientPhone?: string;
173
224
 
174
225
  /**
175
- * How the client connects WhatsApp. `whatsapp_waba` (default) runs Meta's embedded
176
- * signup to link an official WhatsApp Business Account. `whatsapp_alt` links the
177
- * number by scanning a QR code — available only to teams with the WhatsApp
178
- * Alternative feature enabled.
226
+ * Which Meta channel the client connects, and how.
227
+ *
228
+ * - `whatsapp_waba` (default): Meta's embedded signup links an official WhatsApp
229
+ * Business Account. Accepts `phoneNumberId` and `allowedPhoneCountries`.
230
+ * - `messenger`: the client authorizes with Facebook and picks a Facebook Page
231
+ * they administer. The Page's Messenger inbox — including Marketplace chats — is
232
+ * routed to Zavu. They must be an admin of at least one Page. A Page can only be
233
+ * connected to one Zavu project at a time: if the client picks a Page that
234
+ * another project already connected, the newer connection wins and the older one
235
+ * is disconnected.
236
+ *
237
+ * One invitation connects one channel. To onboard a client on several channels,
238
+ * create one invitation per channel; each completes into its own sender.
179
239
  */
180
- connectionType?: 'whatsapp_waba' | 'whatsapp_alt';
240
+ connectionType?: 'whatsapp_waba' | 'messenger';
181
241
 
182
242
  /**
183
243
  * Number of days until the invitation expires.
@@ -186,7 +246,9 @@ export interface InvitationCreateParams {
186
246
 
187
247
  /**
188
248
  * ID of a Zavu phone number to pre-assign for WhatsApp registration. If provided,
189
- * the client will use this number instead of their own.
249
+ * the client will use this number instead of their own. Only valid when
250
+ * `connectionType` is `whatsapp_waba` — sending it with `messenger` returns 400,
251
+ * since a Facebook Page has no phone number.
190
252
  */
191
253
  phoneNumberId?: string;
192
254
  }
@@ -194,8 +256,13 @@ export interface InvitationCreateParams {
194
256
  export interface InvitationListParams extends CursorParams {
195
257
  /**
196
258
  * Current status of the partner invitation.
259
+ *
260
+ * `failed` means the client started the connection and it did not finish (they
261
+ * cancelled Meta's dialog, denied a permission, or abandoned the tab). A failed
262
+ * invitation is still usable: the same link can be retried, and it moves back to
263
+ * `in_progress` when the client tries again.
197
264
  */
198
- status?: 'pending' | 'in_progress' | 'completed' | 'expired' | 'cancelled';
265
+ status?: 'pending' | 'in_progress' | 'completed' | 'expired' | 'cancelled' | 'failed';
199
266
  }
200
267
 
201
268
  export declare namespace Invitations {
@@ -82,10 +82,30 @@ export class Messages extends APIResource {
82
82
  * - Window opens when the user messages you first
83
83
  * - Use template messages to initiate conversations outside the window
84
84
  *
85
- * **Daily limits:**
85
+ * **Plan allowances and email billing:**
86
86
  *
87
- * - Unverified accounts: 200 messages per channel per day
88
- * - Complete KYC verification to increase limits to 10,000/day
87
+ * - WhatsApp, Telegram, Instagram and Messenger share an allowance of 2,000
88
+ * messages per month on Free. Over it, sends return 429 with code
89
+ * `a2p_limit_exceeded` and upgrade details; the counter resets on the 1st of
90
+ * each month. Paid plans have no message caps
91
+ * - Email is billed from your prepaid balance in 1,000-message blocks: $0.40 per
92
+ * 1,000 transactional emails, $0.80 per 1,000 marketing (broadcast) emails. A
93
+ * block is charged when your monthly count crosses each 1,000 boundary, and at
94
+ * zero balance email sends return 402 with code `insufficient_balance`. Free
95
+ * teams start with $2 of credit and additionally cap at 3,000 emails/month and
96
+ * 100/day. Teams on earlier plans keep their original email quotas instead
97
+ * - SMS and voice are billed per message from your balance on every plan
98
+ *
99
+ * **Email recipient pre-flight:** Email messages are validated automatically
100
+ * before dispatch. Sends that would be a guaranteed hard bounce are failed instead
101
+ * of sent, protecting your bounce rate: the message transitions to `failed`
102
+ * (visible via `GET /v1/messages/{messageId}` and the `message.failed` webhook)
103
+ * with `errorCode` set to `EMAIL_INVALID_RECIPIENT` (malformed address),
104
+ * `EMAIL_DOMAIN_NOT_FOUND` (recipient domain has no MX or A records), or
105
+ * `EMAIL_RECIPIENT_SUPPRESSED` (address is on your suppression list after a
106
+ * previous bounce or complaint). Advisory signals (role addresses, disposable
107
+ * domains) do not block sends — check them beforehand with
108
+ * `POST /v1/introspect/email`.
89
109
  *
90
110
  * @example
91
111
  * ```ts
@@ -140,17 +160,13 @@ export class Messages extends APIResource {
140
160
  export type MessagesCursor = Cursor<Message>;
141
161
 
142
162
  /**
143
- * Delivery channel. Use 'auto' for intelligent routing. `whatsapp_alt` is the
144
- * QR-linked WhatsApp channel and is only accepted for teams with the WhatsApp
145
- * Alternative feature enabled; the sender must have a connected whatsapp_alt
146
- * session.
163
+ * Delivery channel. Use 'auto' for intelligent routing.
147
164
  */
148
165
  export type Channel =
149
166
  | 'auto'
150
167
  | 'sms'
151
168
  | 'sms_oneway'
152
169
  | 'whatsapp'
153
- | 'whatsapp_alt'
154
170
  | 'telegram'
155
171
  | 'email'
156
172
  | 'instagram'
@@ -161,10 +177,7 @@ export interface Message {
161
177
  id: string;
162
178
 
163
179
  /**
164
- * Delivery channel. Use 'auto' for intelligent routing. `whatsapp_alt` is the
165
- * QR-linked WhatsApp channel and is only accepted for teams with the WhatsApp
166
- * Alternative feature enabled; the sender must have a connected whatsapp_alt
167
- * session.
180
+ * Delivery channel. Use 'auto' for intelligent routing.
168
181
  */
169
182
  channel: Channel;
170
183
 
@@ -173,6 +186,20 @@ export interface Message {
173
186
  /**
174
187
  * Type of message. Non-text types are supported by WhatsApp and Telegram (varies
175
188
  * by type).
189
+ *
190
+ * `location_request` asks the recipient to share their location and is
191
+ * WhatsApp-only. It takes no `content` object — the prompt goes in `text` (max
192
+ * 1024 characters) and the button label is fixed by WhatsApp. The recipient's
193
+ * answer arrives as an inbound `location` message whose `content.replyToMessageId`
194
+ * is the ID of the request.
195
+ *
196
+ * `request_contact_info` asks the recipient to share their phone number and is
197
+ * WhatsApp-only. Like `location_request` it takes no `content` object — the prompt
198
+ * goes in `text` (max 1024 characters) and WhatsApp renders a fixed **Share
199
+ * Contact Info** button. The answer arrives as an inbound `contact` message. Use
200
+ * it to recover the phone number of a contact who adopted a WhatsApp username and
201
+ * is only known by their business-scoped user ID (BSUID); when they share it, Zavu
202
+ * automatically links the phone number to that contact.
176
203
  */
177
204
  messageType: MessageType;
178
205
 
@@ -185,6 +212,14 @@ export interface Message {
185
212
  */
186
213
  content?: MessageContent;
187
214
 
215
+ /**
216
+ * ID of the conversation (inbox thread) this message belongs to. Use it to build a
217
+ * direct dashboard link:
218
+ * `https://dashboard.zavu.dev/{locale}/inbox?conv={conversationId}`. Omitted only
219
+ * on legacy messages created before conversation threading.
220
+ */
221
+ conversationId?: string;
222
+
188
223
  /**
189
224
  * Zavu platform charge in USD for this message. Messaging is billed against your
190
225
  * plan's monthly limits plus usage-based overage.
@@ -449,6 +484,20 @@ export type MessageStatus =
449
484
  /**
450
485
  * Type of message. Non-text types are supported by WhatsApp and Telegram (varies
451
486
  * by type).
487
+ *
488
+ * `location_request` asks the recipient to share their location and is
489
+ * WhatsApp-only. It takes no `content` object — the prompt goes in `text` (max
490
+ * 1024 characters) and the button label is fixed by WhatsApp. The recipient's
491
+ * answer arrives as an inbound `location` message whose `content.replyToMessageId`
492
+ * is the ID of the request.
493
+ *
494
+ * `request_contact_info` asks the recipient to share their phone number and is
495
+ * WhatsApp-only. Like `location_request` it takes no `content` object — the prompt
496
+ * goes in `text` (max 1024 characters) and WhatsApp renders a fixed **Share
497
+ * Contact Info** button. The answer arrives as an inbound `contact` message. Use
498
+ * it to recover the phone number of a contact who adopted a WhatsApp username and
499
+ * is only known by their business-scoped user ID (BSUID); when they share it, Zavu
500
+ * automatically links the phone number to that contact.
452
501
  */
453
502
  export type MessageType =
454
503
  | 'text'
@@ -462,6 +511,8 @@ export type MessageType =
462
511
  | 'buttons'
463
512
  | 'list'
464
513
  | 'cta_url'
514
+ | 'request_contact_info'
515
+ | 'location_request'
465
516
  | 'reaction'
466
517
  | 'template';
467
518
 
@@ -499,13 +550,10 @@ export interface MessageReactParams {
499
550
  export interface MessageSendParams {
500
551
  /**
501
552
  * Body param: Recipient phone number in E.164 format, email address, WhatsApp
502
- * business-scoped user ID (BSUID, e.g. `US.13491208655302741918`), WhatsApp group
503
- * JID (`<id>@g.us`, e.g. `120363000000000000@g.us`), or numeric chat ID (for
504
- * Telegram/Instagram/Messenger). A BSUID is routed to WhatsApp and sent via the
505
- * `recipient` field; use it to message a contact who adopted a username and whose
506
- * phone number is hidden. A group JID is only valid on the `whatsapp_alt` channel
507
- * and supports text and media (image, video, audio, document, sticker, location,
508
- * contact).
553
+ * business-scoped user ID (BSUID, e.g. `US.13491208655302741918`), or numeric chat
554
+ * ID (for Telegram/Instagram/Messenger). A BSUID is routed to WhatsApp and sent
555
+ * via the `recipient` field; use it to message a contact who adopted a username
556
+ * and whose phone number is hidden.
509
557
  */
510
558
  to: string;
511
559
 
@@ -115,7 +115,11 @@ export class Brands extends APIResource {
115
115
 
116
116
  /**
117
117
  * Submit a draft brand to The Campaign Registry (TCR) for vetting. The brand must
118
- * be in draft status. A $35 registration fee is charged from your balance.
118
+ * be in draft status. TCR's one-time $4 brand registration fee is charged from
119
+ * your balance at submission (passed through at cost) and refunded if the carrier
120
+ * rejects the registration. A team that already paid this fee through the
121
+ * compliance flow is not charged again. Campaign registration is billed separately
122
+ * when a campaign is submitted.
119
123
  *
120
124
  * @example
121
125
  * ```ts
@@ -117,7 +117,12 @@ export class Campaigns extends APIResource {
117
117
 
118
118
  /**
119
119
  * Submit a draft campaign for carrier review. The campaign must be in draft status
120
- * and its brand must be verified.
120
+ * and its brand must be verified. TCR's one-time registration fee is charged from
121
+ * your balance at submission ($15 for standard use cases, $2 for LOW_VOLUME),
122
+ * passed through at cost and refunded if the carrier rejects it. Once approved,
123
+ * the campaign's monthly TCR fee ($10 standard, $2 LOW_VOLUME) is charged from
124
+ * your balance while the campaign is active — see registrationCostCents and
125
+ * monthlyFeeCents on the campaign object.
121
126
  *
122
127
  * @example
123
128
  * ```ts
@@ -350,6 +350,12 @@ export interface PhoneNumberSearchAvailableParams {
350
350
  */
351
351
  countryCode: string;
352
352
 
353
+ /**
354
+ * Comma-separated capabilities the number must have: `sms`, `voice`, `mms`.
355
+ * Numbers missing any of them are dropped.
356
+ */
357
+ capabilities?: string;
358
+
353
359
  /**
354
360
  * Search for numbers containing this string.
355
361
  */