@wuapidev/sdk 0.1.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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +355 -0
  3. package/dist/client.d.ts +50 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +80 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/core.d.ts +58 -0
  8. package/dist/core.d.ts.map +1 -0
  9. package/dist/core.js +191 -0
  10. package/dist/core.js.map +1 -0
  11. package/dist/errors.d.ts +26 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +29 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +8 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/pagination.d.ts +23 -0
  20. package/dist/pagination.d.ts.map +1 -0
  21. package/dist/pagination.js +53 -0
  22. package/dist/pagination.js.map +1 -0
  23. package/dist/resources/accounts.d.ts +76 -0
  24. package/dist/resources/accounts.d.ts.map +1 -0
  25. package/dist/resources/accounts.js +139 -0
  26. package/dist/resources/accounts.js.map +1 -0
  27. package/dist/resources/base.d.ts +18 -0
  28. package/dist/resources/base.d.ts.map +1 -0
  29. package/dist/resources/base.js +34 -0
  30. package/dist/resources/base.js.map +1 -0
  31. package/dist/resources/channels.d.ts +22 -0
  32. package/dist/resources/channels.d.ts.map +1 -0
  33. package/dist/resources/channels.js +45 -0
  34. package/dist/resources/channels.js.map +1 -0
  35. package/dist/resources/chats.d.ts +35 -0
  36. package/dist/resources/chats.d.ts.map +1 -0
  37. package/dist/resources/chats.js +64 -0
  38. package/dist/resources/chats.js.map +1 -0
  39. package/dist/resources/contacts.d.ts +45 -0
  40. package/dist/resources/contacts.d.ts.map +1 -0
  41. package/dist/resources/contacts.js +79 -0
  42. package/dist/resources/contacts.js.map +1 -0
  43. package/dist/resources/groups.d.ts +36 -0
  44. package/dist/resources/groups.d.ts.map +1 -0
  45. package/dist/resources/groups.js +81 -0
  46. package/dist/resources/groups.js.map +1 -0
  47. package/dist/resources/messages.d.ts +36 -0
  48. package/dist/resources/messages.d.ts.map +1 -0
  49. package/dist/resources/messages.js +60 -0
  50. package/dist/resources/messages.js.map +1 -0
  51. package/dist/resources/misc.d.ts +21 -0
  52. package/dist/resources/misc.d.ts.map +1 -0
  53. package/dist/resources/misc.js +23 -0
  54. package/dist/resources/misc.js.map +1 -0
  55. package/dist/resources/projects.d.ts +65 -0
  56. package/dist/resources/projects.d.ts.map +1 -0
  57. package/dist/resources/projects.js +115 -0
  58. package/dist/resources/projects.js.map +1 -0
  59. package/dist/types.d.ts +1073 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +46 -0
  62. package/dist/types.js.map +1 -0
  63. package/dist/webhook.d.ts +15 -0
  64. package/dist/webhook.d.ts.map +1 -0
  65. package/dist/webhook.js +77 -0
  66. package/dist/webhook.js.map +1 -0
  67. package/package.json +56 -0
@@ -0,0 +1,1073 @@
1
+ /**
2
+ * Types matching the wuapi REST API (https://wuapi.dev/openapi.json).
3
+ *
4
+ * Every resource carries `object` naming its type. Timestamps are ISO 8601
5
+ * strings in UTC named `…At`. Contacts are E.164 (`+584241112233`), or
6
+ * `lid:<digits>` when WhatsApp hides the number. Groups are `…@g.us`,
7
+ * channels `…@newsletter`, and the account's stories are the chat `stories`.
8
+ */
9
+ export interface ErrorBody {
10
+ code: string;
11
+ message: string;
12
+ details?: Record<string, unknown>;
13
+ }
14
+ /** Every list: one page of items. */
15
+ export interface Page<T> {
16
+ object: "list";
17
+ items: T[];
18
+ /** Pass as `cursor` to get the next page. `null` on the last page. */
19
+ nextCursor: string | null;
20
+ }
21
+ export interface ListParams {
22
+ /** Page size, 1-100. Defaults to 50. */
23
+ limit?: number;
24
+ /** Cursor from a previous page's `nextCursor`. */
25
+ cursor?: string;
26
+ }
27
+ export interface ProjectListParams extends ListParams {
28
+ /**
29
+ * Filter by project: a project id, `ext:<externalId>`, or `none` for
30
+ * unassigned resources only. A project-scoped client always lists its own
31
+ * project.
32
+ */
33
+ projectId?: string;
34
+ }
35
+ /** Options every method accepts as its last argument. */
36
+ export interface CallOptions {
37
+ /**
38
+ * Sent as the `Idempotency-Key` header. POSTs get a random key when you do
39
+ * not pass one, so automatic retries never repeat a send or a create. Pass
40
+ * your own to make retries across processes safe too.
41
+ */
42
+ idempotencyKey?: string;
43
+ signal?: AbortSignal;
44
+ }
45
+ /** A contact id: E.164 (`+584241112233`), bare digits, or `lid:<digits>`. */
46
+ export type ContactId = string;
47
+ /** A chat: a contact id, a group id (`…@g.us`), a channel id (`…@newsletter`), or `stories`. */
48
+ export type ChatId = string;
49
+ export interface Organization {
50
+ object: "organization";
51
+ id: string;
52
+ name: string;
53
+ }
54
+ export interface ApiKey {
55
+ object: "api_key";
56
+ id: string;
57
+ name: string;
58
+ projectId: string | null;
59
+ keyPrefix: string;
60
+ last4: string;
61
+ /** The key itself. Only on the response that created it. */
62
+ key?: string;
63
+ createdAt: string;
64
+ lastUsedAt: string | null;
65
+ revokedAt: string | null;
66
+ }
67
+ export interface AuthContext {
68
+ object: "auth_context";
69
+ organization: Organization;
70
+ apiKey: ApiKey;
71
+ /** The project this request is scoped to, or `null` for the whole organization. */
72
+ project: Project | null;
73
+ }
74
+ export type ProjectStatus = "active" | "suspended";
75
+ export interface Project {
76
+ object: "project";
77
+ id: string;
78
+ name: string;
79
+ /** Your own id for this customer, unique among live projects. */
80
+ externalId: string | null;
81
+ metadata: Record<string, string>;
82
+ status: ProjectStatus;
83
+ /** Account limit. `null` means no limit. */
84
+ maxAccounts: number | null;
85
+ accountCount: number;
86
+ createdAt: string;
87
+ updatedAt: string;
88
+ }
89
+ export interface ProjectCreateParams {
90
+ name: string;
91
+ externalId?: string;
92
+ metadata?: Record<string, string>;
93
+ maxAccounts?: number;
94
+ }
95
+ export interface ProjectUpdateParams {
96
+ name?: string;
97
+ /** `null` clears it. */
98
+ externalId?: string | null;
99
+ /** Replaces the whole metadata object. */
100
+ metadata?: Record<string, string>;
101
+ /** `null` removes the limit. */
102
+ maxAccounts?: number | null;
103
+ status?: ProjectStatus;
104
+ }
105
+ export interface ProjectListFilter extends ListParams {
106
+ /** Exact match. */
107
+ externalId?: string;
108
+ status?: ProjectStatus;
109
+ }
110
+ export interface ApiKeyCreateParams {
111
+ name: string;
112
+ }
113
+ export interface UsagePeriod {
114
+ startsAt: string;
115
+ endsAt: string;
116
+ }
117
+ export interface Usage {
118
+ object: "usage";
119
+ period: UsagePeriod;
120
+ currency: "usd";
121
+ billableAccountCount: number;
122
+ accountUnitPriceCents: number;
123
+ accountFeeCents: number;
124
+ /** Every proxy byte used this month, included or not. */
125
+ proxyBytes: number;
126
+ /** The month's pooled allowance: 0.5 GB per billable account, at the month's peak count. */
127
+ includedProxyBytes: number;
128
+ /** Proxy bytes past the allowance, trial traffic excluded: what `proxyFeeCents` bills. */
129
+ billableProxyBytes: number;
130
+ proxyFeeCents: number;
131
+ totalCents: number;
132
+ }
133
+ export interface UsageLine {
134
+ billableAccountCount: number;
135
+ accountCount: number;
136
+ proxyBytes: number;
137
+ sentMessageCount: number;
138
+ receivedMessageCount: number;
139
+ }
140
+ export interface UsageReport {
141
+ object: "usage_report";
142
+ period: UsagePeriod;
143
+ projects: Array<UsageLine & {
144
+ projectId: string;
145
+ externalId: string | null;
146
+ name: string;
147
+ }>;
148
+ unassigned: UsageLine;
149
+ totals: UsageLine;
150
+ }
151
+ export interface ProjectUsage extends UsageLine {
152
+ object: "project_usage";
153
+ projectId: string;
154
+ period: UsagePeriod;
155
+ }
156
+ export interface MonthParams {
157
+ /** `YYYY-MM` in UTC. Defaults to the current month. */
158
+ month?: string;
159
+ }
160
+ export interface Branding {
161
+ object: "branding";
162
+ displayName: string | null;
163
+ logoUrl: string | null;
164
+ accentColor: string | null;
165
+ supportUrl: string | null;
166
+ hideWuapiBranding: boolean;
167
+ }
168
+ export interface BrandingUpdateParams {
169
+ displayName?: string;
170
+ logoUrl?: string | null;
171
+ accentColor?: string | null;
172
+ supportUrl?: string | null;
173
+ /** `true` needs the White label add-on (402 `addon_required` otherwise). */
174
+ hideWuapiBranding?: boolean;
175
+ }
176
+ /** Where an account's residential proxy exits. Values come from `proxyLocations.list()`. */
177
+ export interface ProxyLocation {
178
+ /** ISO 3166-1 alpha-2, uppercase: `"CL"`. */
179
+ country: string;
180
+ /** City code from `proxyLocations.list()`: lowercase, one word, accents kept: `"santiago"`, `"bogotá"`. The unaccented form is accepted too. */
181
+ city: string;
182
+ }
183
+ export interface ProxyLocationItem {
184
+ object: "proxy_location";
185
+ country: string;
186
+ countryName: string;
187
+ city: string;
188
+ cityName: string;
189
+ }
190
+ export interface ProxyLocationListParams extends ListParams {
191
+ /** Only this country (ISO 3166-1 alpha-2). */
192
+ country?: string;
193
+ /**
194
+ * Search text, 1 to 100 characters: city name, city code, country name or ISO code, ignoring case and accents.
195
+ * Results come best first: exact, then prefix (`"bogo"` finds Bogotá), then a later word (`"york"`), then anywhere; ties go to the bigger city.
196
+ */
197
+ q?: string;
198
+ }
199
+ export type AccountStatus = "initializing" | "qr_ready" | "authenticating" | "ready" | "disconnected" | "failed";
200
+ /** Effective pacing of an account. Defaults: 12/min, 5/min to first contacts, typing 800 to 6000 ms at 25 chars/s, 60 min queue timeout. */
201
+ export interface AccountPacing {
202
+ messagesPerMinute: number;
203
+ firstContactPerMinute: number;
204
+ typing: {
205
+ enabled: boolean;
206
+ minMs: number;
207
+ maxMs: number;
208
+ charsPerSecond: number;
209
+ };
210
+ queueTimeoutMinutes: number;
211
+ /** `true` when any value differs from the defaults. */
212
+ custom: boolean;
213
+ }
214
+ /** A pacing change, merged over the stored values. `null` on a field resets it to the default. */
215
+ export interface AccountPacingUpdate {
216
+ messagesPerMinute?: number | null;
217
+ firstContactPerMinute?: number | null;
218
+ typing?: {
219
+ enabled?: boolean | null;
220
+ minMs?: number | null;
221
+ maxMs?: number | null;
222
+ charsPerSecond?: number | null;
223
+ } | null;
224
+ queueTimeoutMinutes?: number | null;
225
+ }
226
+ export interface Account {
227
+ object: "account";
228
+ id: string;
229
+ projectId: string | null;
230
+ name: string | null;
231
+ status: AccountStatus;
232
+ /** Linked number in E.164, once known. */
233
+ phone: string | null;
234
+ /** The linked number's WhatsApp display name. */
235
+ profileName: string | null;
236
+ /** Where the account's proxy exits. `null` on accounts linked before proxy locations existed. */
237
+ proxyLocation: ProxyLocation | null;
238
+ /** PNG data URL of the QR code, while `status` is `qr_ready` and the account links by QR code. */
239
+ qrCodeUrl: string | null;
240
+ /** Pairing code (`XXXX-XXXX`) for accounts linking by phone number. `null` once `ready`. */
241
+ pairingCode: string | null;
242
+ pairingCodeExpiresAt: string | null;
243
+ billable: boolean;
244
+ disconnectReason: string | null;
245
+ lastError: string | null;
246
+ rejectCalls: boolean;
247
+ rejectCallsMessage: string | null;
248
+ pacing: AccountPacing;
249
+ metadata: Record<string, string>;
250
+ linkedAt: string | null;
251
+ lastConnectedAt: string | null;
252
+ createdAt: string;
253
+ updatedAt: string;
254
+ }
255
+ export interface AccountListParams extends ProjectListParams {
256
+ }
257
+ export interface AccountCreateParams {
258
+ /** Required. Where the account's residential proxy exits; one of `proxyLocations.list()`. 400 `unsupported_proxy_location` otherwise. */
259
+ proxyLocation: ProxyLocation;
260
+ name?: string;
261
+ /** Link by pairing code instead of QR code: the number to link. The code appears as `account.pairingCode`. */
262
+ pairingPhone?: string;
263
+ /** Organization keys only: create the account in this project (id or `ext:<externalId>`). */
264
+ projectId?: string;
265
+ }
266
+ export interface AccountUpdateParams {
267
+ name?: string;
268
+ rejectCalls?: boolean;
269
+ /** Sent to the caller after an automatic reject. At most 1000 characters. */
270
+ rejectCallsMessage?: string;
271
+ /** `null` resets every value to the default. */
272
+ pacing?: AccountPacingUpdate | null;
273
+ }
274
+ export interface PairingCode {
275
+ object: "pairing_code";
276
+ accountId: string;
277
+ /** Type this on the phone: Linked devices > Link a device > Link with phone number instead. */
278
+ code: string;
279
+ expiresAt: string | null;
280
+ }
281
+ export type AccountPresenceState = "online" | "offline";
282
+ export type ChatPresenceState = "typing" | "recording" | "paused";
283
+ export type DisappearingSeconds = 0 | 86400 | 604800 | 7776000;
284
+ export type ChatType = "direct" | "group" | "channel" | "story";
285
+ export type MessageDirection = "inbound" | "outbound";
286
+ export type MessageSource = "api" | "phone" | "contact" | "history";
287
+ export type MessageType = "text" | "image" | "video" | "audio" | "voice" | "document" | "sticker" | "location" | "contact" | "contacts" | "poll" | "reaction" | "calendar_event" | "unknown";
288
+ export type MessageStatus = "queued" | "sent" | "delivered" | "read" | "failed" | "received";
289
+ export interface MessageMedia {
290
+ url: string | null;
291
+ mimeType: string | null;
292
+ filename: string | null;
293
+ }
294
+ export interface MessageLocation {
295
+ latitude: number;
296
+ longitude: number;
297
+ name: string | null;
298
+ address: string | null;
299
+ }
300
+ export interface ContactCard {
301
+ name: string;
302
+ /** E.164. */
303
+ phone: string;
304
+ }
305
+ export interface MessagePoll {
306
+ name: string;
307
+ options: Array<{
308
+ name: string;
309
+ voteCount: number;
310
+ }>;
311
+ /** 0 means any number of options. */
312
+ selectableCount: number;
313
+ voterCount: number;
314
+ }
315
+ export interface MessageCalendarEvent {
316
+ name: string;
317
+ description: string | null;
318
+ startsAt: string | null;
319
+ endsAt: string | null;
320
+ location: {
321
+ name: string | null;
322
+ address: string | null;
323
+ latitude: number | null;
324
+ longitude: number | null;
325
+ } | null;
326
+ callType: "audio" | "video" | null;
327
+ joinUrl: string | null;
328
+ allowExtraGuests: boolean;
329
+ cancelled: boolean;
330
+ }
331
+ export interface Message {
332
+ object: "message";
333
+ id: string;
334
+ projectId: string | null;
335
+ accountId: string;
336
+ chatId: ChatId;
337
+ chatType: ChatType;
338
+ direction: MessageDirection;
339
+ source: MessageSource;
340
+ from: string;
341
+ to: string;
342
+ /** The sender's WhatsApp display name, on inbound messages. */
343
+ profileName: string | null;
344
+ type: MessageType;
345
+ /** Text, caption of media, or the emoji of a reaction. */
346
+ text: string | null;
347
+ media: MessageMedia | null;
348
+ location: MessageLocation | null;
349
+ contact: ContactCard | null;
350
+ contacts: ContactCard[] | null;
351
+ poll: MessagePoll | null;
352
+ calendarEvent: MessageCalendarEvent | null;
353
+ mentions: ContactId[];
354
+ forwarded: boolean;
355
+ viewOnce: boolean;
356
+ starred: boolean;
357
+ replyToMessageId: string | null;
358
+ status: MessageStatus;
359
+ error: {
360
+ code: string;
361
+ message: string;
362
+ } | null;
363
+ metadata: Record<string, string>;
364
+ /** WhatsApp's timestamp. */
365
+ sentAt: string | null;
366
+ editedAt: string | null;
367
+ deletedAt: string | null;
368
+ createdAt: string;
369
+ updatedAt: string;
370
+ }
371
+ export interface SendMedia {
372
+ /** https URL our servers fetch. */
373
+ url: string;
374
+ /** Guessed from the URL extension when omitted. Voice notes: send ogg/opus, nothing is transcoded. */
375
+ mimeType?: string;
376
+ filename?: string;
377
+ }
378
+ export interface SendVideoMedia extends SendMedia {
379
+ /** Play it as a GIF. */
380
+ gifPlayback?: boolean;
381
+ }
382
+ export interface SendLocation {
383
+ latitude: number;
384
+ longitude: number;
385
+ name?: string;
386
+ address?: string;
387
+ }
388
+ export interface SendPoll {
389
+ name: string;
390
+ /** 2 to 12 unique, non-blank options of at most 100 characters. */
391
+ options: string[];
392
+ /** How many options a voter may pick. 0 (default) means any number. */
393
+ selectableCount?: number;
394
+ }
395
+ export interface SendCalendarEvent {
396
+ name: string;
397
+ description?: string;
398
+ /** ISO 8601. */
399
+ startsAt: string;
400
+ /** Not before `startsAt`. */
401
+ endsAt?: string;
402
+ location?: {
403
+ name: string;
404
+ latitude?: number;
405
+ longitude?: number;
406
+ };
407
+ /** Make it a scheduled WhatsApp call. WhatsApp generates the call link. */
408
+ callType?: "audio" | "video";
409
+ allowExtraGuests?: boolean;
410
+ }
411
+ export interface SendLinkPreview {
412
+ url: string;
413
+ title: string;
414
+ description?: string;
415
+ /** JPEG, base64. */
416
+ thumbnailBase64?: string;
417
+ }
418
+ /** Fields every send type takes. */
419
+ export interface SendMessageBase {
420
+ /** The account to send from. It must be `ready`. */
421
+ accountId: string;
422
+ /**
423
+ * A contact id, a group id (`…@g.us`) or a channel id (`…@newsletter`,
424
+ * admins only). Channels take only `text`, `image`, `video` and `document`.
425
+ */
426
+ to: string;
427
+ /** Contact ids to mention. Not for channel posts. */
428
+ mentions?: ContactId[];
429
+ /** Groups only: mention every participant. */
430
+ mentionAll?: boolean;
431
+ forwarded?: boolean;
432
+ disappearingSeconds?: DisappearingSeconds;
433
+ /** A wuapi message id in the same chat to quote. Not for channel posts. */
434
+ replyToMessageId?: string;
435
+ metadata?: Record<string, string>;
436
+ }
437
+ /** A text message. `type` may be omitted: the API sends a body without one as text. */
438
+ export interface SendTextMessageParams extends SendMessageBase {
439
+ type?: "text";
440
+ /** Not blank; at most 4096 characters. */
441
+ text: string;
442
+ linkPreview?: SendLinkPreview;
443
+ }
444
+ export interface SendImageMessageParams extends SendMessageBase {
445
+ type: "image";
446
+ media: SendMedia;
447
+ /** Caption. */
448
+ text?: string;
449
+ viewOnce?: boolean;
450
+ }
451
+ export interface SendVideoMessageParams extends SendMessageBase {
452
+ type: "video";
453
+ media: SendVideoMedia;
454
+ /** Caption. */
455
+ text?: string;
456
+ viewOnce?: boolean;
457
+ }
458
+ export interface SendAudioMessageParams extends SendMessageBase {
459
+ type: "audio";
460
+ media: SendMedia;
461
+ /** Caption. */
462
+ text?: string;
463
+ viewOnce?: boolean;
464
+ }
465
+ /** An audio sent as a voice note. Send ogg/opus: nothing is transcoded. */
466
+ export interface SendVoiceMessageParams extends SendMessageBase {
467
+ type: "voice";
468
+ media: SendMedia;
469
+ /** Caption. */
470
+ text?: string;
471
+ viewOnce?: boolean;
472
+ }
473
+ export interface SendDocumentMessageParams extends SendMessageBase {
474
+ type: "document";
475
+ media: SendMedia;
476
+ /** Caption. */
477
+ text?: string;
478
+ }
479
+ export interface SendStickerMessageParams extends SendMessageBase {
480
+ type: "sticker";
481
+ media: SendMedia;
482
+ /** Caption. */
483
+ text?: string;
484
+ }
485
+ export interface SendLocationMessageParams extends SendMessageBase {
486
+ type: "location";
487
+ location: SendLocation;
488
+ }
489
+ export interface SendContactMessageParams extends SendMessageBase {
490
+ type: "contact";
491
+ contact: ContactCard;
492
+ }
493
+ export interface SendContactsMessageParams extends SendMessageBase {
494
+ type: "contacts";
495
+ /** 2 to 20 cards. Use `type: "contact"` for one. */
496
+ contacts: ContactCard[];
497
+ }
498
+ export interface SendPollMessageParams extends SendMessageBase {
499
+ type: "poll";
500
+ poll: SendPoll;
501
+ }
502
+ export interface SendCalendarEventMessageParams extends SendMessageBase {
503
+ type: "calendar_event";
504
+ calendarEvent: SendCalendarEvent;
505
+ }
506
+ /**
507
+ * What `messages.send()` takes, discriminated by `type`: each type requires
508
+ * its own field (`text`, `media`, `location`, `contact`, `contacts`, `poll` or
509
+ * `calendarEvent`). Mirrors `SendMessageRequest` in openapi.json.
510
+ */
511
+ export type SendMessageParams = SendTextMessageParams | SendImageMessageParams | SendVideoMessageParams | SendAudioMessageParams | SendVoiceMessageParams | SendDocumentMessageParams | SendStickerMessageParams | SendLocationMessageParams | SendContactMessageParams | SendContactsMessageParams | SendPollMessageParams | SendCalendarEventMessageParams;
512
+ export type SendType = NonNullable<SendMessageParams["type"]>;
513
+ export interface MessageListParams extends ProjectListParams {
514
+ accountId?: string;
515
+ chatId?: ChatId;
516
+ direction?: MessageDirection;
517
+ }
518
+ export interface MessageDeleteParams {
519
+ /** `false` deletes on the linked devices only. Default `true`. */
520
+ forEveryone?: boolean;
521
+ }
522
+ /** A text story. `type` may be omitted: the API posts a body without one as text. */
523
+ export interface TextStoryCreateParams {
524
+ type?: "text";
525
+ /** Not blank; at most 4096 characters. */
526
+ text: string;
527
+ /** `#RRGGBB`. */
528
+ backgroundColor?: string;
529
+ /** WhatsApp's story font: 0, 1, 2, 6, 7, 8, 9 or 10. */
530
+ font?: 0 | 1 | 2 | 6 | 7 | 8 | 9 | 10;
531
+ }
532
+ /** An image or video story. */
533
+ export interface MediaStoryCreateParams {
534
+ type: "image" | "video";
535
+ media: {
536
+ url: string;
537
+ mimeType?: string;
538
+ };
539
+ /** Caption. */
540
+ text?: string;
541
+ }
542
+ /** What `stories.create()` takes, discriminated by `type`. Mirrors `StoryCreateRequest` in openapi.json. */
543
+ export type StoryCreateParams = TextStoryCreateParams | MediaStoryCreateParams;
544
+ export interface ChatRead {
545
+ object: "chat_read";
546
+ accountId: string;
547
+ chatId: ChatId;
548
+ messageCount: number;
549
+ }
550
+ export interface ReadReceiptsParams {
551
+ /** wuapi message ids in this chat. Default: every unread inbound message wuapi stores for it. */
552
+ messageIds?: string[];
553
+ }
554
+ export interface Label {
555
+ object: "label";
556
+ id: string;
557
+ accountId: string;
558
+ name: string;
559
+ color: number;
560
+ }
561
+ export interface LabelUpsertParams {
562
+ name: string;
563
+ /** 0 to 19. */
564
+ color?: number;
565
+ }
566
+ export interface ContactCheck {
567
+ object: "contact_check";
568
+ phone: string;
569
+ onWhatsApp: boolean;
570
+ contactId: ContactId | null;
571
+ businessName: string | null;
572
+ }
573
+ export interface Contact {
574
+ object: "contact";
575
+ id: ContactId;
576
+ accountId: string;
577
+ lid: string | null;
578
+ about: string | null;
579
+ pictureId: string | null;
580
+ businessName: string | null;
581
+ deviceCount: number | null;
582
+ }
583
+ export interface Picture {
584
+ object: "picture";
585
+ id: string | null;
586
+ url: string | null;
587
+ preview: boolean;
588
+ }
589
+ export type PictureInput = {
590
+ url: string;
591
+ } | {
592
+ base64: string;
593
+ };
594
+ export interface BusinessProfile {
595
+ object: "business_profile";
596
+ contactId: ContactId;
597
+ address: string | null;
598
+ email: string | null;
599
+ categories: Array<{
600
+ id: string;
601
+ name: string;
602
+ }>;
603
+ profileOptions: Record<string, string>;
604
+ timeZone: string | null;
605
+ businessHours: Array<{
606
+ dayOfWeek: string;
607
+ mode: string;
608
+ openTime: string | null;
609
+ closeTime: string | null;
610
+ }>;
611
+ }
612
+ export interface BlockedContact {
613
+ object: "blocked_contact";
614
+ contactId: ContactId;
615
+ }
616
+ export interface ContactLink {
617
+ object: "contact_link";
618
+ url: string | null;
619
+ }
620
+ export interface ResolvedLink {
621
+ object: "resolved_link";
622
+ kind: "contact" | "business";
623
+ contactId: ContactId | null;
624
+ type: string | null;
625
+ profileName: string | null;
626
+ businessName: string | null;
627
+ verifiedLevel: string | null;
628
+ prefilledText: string | null;
629
+ }
630
+ export interface LinkResolveParams {
631
+ kind: "contact" | "business";
632
+ /** The code or the full link. */
633
+ code: string;
634
+ }
635
+ export interface Bot {
636
+ object: "bot";
637
+ id: string;
638
+ personaId: string | null;
639
+ name: string | null;
640
+ description: string | null;
641
+ category: string | null;
642
+ default: boolean;
643
+ prompts: string[];
644
+ commands: Array<{
645
+ name: string;
646
+ description: string | null;
647
+ }>;
648
+ }
649
+ export interface ProfileUpdateParams {
650
+ /** At most 139 characters. */
651
+ about?: string;
652
+ /** At most 25 characters. */
653
+ name?: string;
654
+ }
655
+ export interface PrivacySettings {
656
+ object: "privacy_settings";
657
+ groupAdd: string | null;
658
+ lastSeen: string | null;
659
+ stories: string | null;
660
+ profile: string | null;
661
+ readReceipts: string | null;
662
+ online: string | null;
663
+ callAdd: string | null;
664
+ messages: string | null;
665
+ defense: string | null;
666
+ stickers: string | null;
667
+ }
668
+ export interface PrivacyUpdateParams {
669
+ groupAdd?: string;
670
+ lastSeen?: string;
671
+ stories?: string;
672
+ profile?: string;
673
+ readReceipts?: string;
674
+ online?: string;
675
+ callAdd?: string;
676
+ messages?: string;
677
+ }
678
+ export interface StoryPrivacy {
679
+ object: "story_privacy";
680
+ lists: Array<{
681
+ type: "contacts" | "blacklist" | "whitelist";
682
+ contactIds: ContactId[];
683
+ default: boolean;
684
+ }>;
685
+ }
686
+ export interface StickerPack {
687
+ object: "sticker_pack";
688
+ id: string;
689
+ name: string;
690
+ publisher: string;
691
+ description: string | null;
692
+ animated: boolean;
693
+ trayImageId: string | null;
694
+ stickers: Array<{
695
+ url: string | null;
696
+ directPath: string | null;
697
+ sizeBytes: number;
698
+ mimeType: string;
699
+ width: number;
700
+ height: number;
701
+ emojis: string[];
702
+ }>;
703
+ }
704
+ export interface Order {
705
+ object: "order";
706
+ id: string;
707
+ currency: string;
708
+ subtotalCents: number;
709
+ totalCents: number;
710
+ products: Array<{
711
+ id: string;
712
+ name: string;
713
+ quantity: number;
714
+ priceCents: number;
715
+ currency: string;
716
+ imageUrl: string | null;
717
+ }>;
718
+ createdAt: string | null;
719
+ }
720
+ export interface GroupParticipant {
721
+ contactId: ContactId;
722
+ name: string | null;
723
+ role: "member" | "admin" | "owner";
724
+ }
725
+ export interface Group {
726
+ object: "group";
727
+ id: string;
728
+ accountId: string;
729
+ name: string;
730
+ description: string | null;
731
+ ownerId: ContactId | null;
732
+ community: boolean;
733
+ locked: boolean;
734
+ announce: boolean;
735
+ participants: GroupParticipant[];
736
+ createdAt: string | null;
737
+ }
738
+ export interface GroupCreateParams {
739
+ name: string;
740
+ /** Contact ids. Required unless `community` is true. */
741
+ participants?: ContactId[];
742
+ /** Create a community instead of a group. */
743
+ community?: boolean;
744
+ }
745
+ export interface GroupUpdateParams {
746
+ name?: string;
747
+ description?: string;
748
+ /** Only admins can send. */
749
+ announce?: boolean;
750
+ /** Only admins can edit the group info. */
751
+ locked?: boolean;
752
+ /** New members need admin approval. */
753
+ joinApproval?: boolean;
754
+ memberAddMode?: "admins" | "all_members";
755
+ }
756
+ export interface ParticipantResult {
757
+ object: "participant_result";
758
+ contactId: ContactId;
759
+ /** Why it failed for this participant, e.g. `privacy_restricted`. `null` when done. */
760
+ error: string | null;
761
+ /** Returned instead of an add when the person must be invited. */
762
+ inviteCode: string | null;
763
+ }
764
+ export interface GroupJoin {
765
+ object: "group_join";
766
+ accountId: string;
767
+ groupId: string;
768
+ }
769
+ export interface GroupInviteLink {
770
+ object: "group_invite_link";
771
+ groupId: string;
772
+ url: string;
773
+ }
774
+ export interface GroupJoinRequest {
775
+ object: "group_join_request";
776
+ accountId: string;
777
+ groupId: string;
778
+ contactId: ContactId;
779
+ requestedAt: string | null;
780
+ }
781
+ export interface Subgroup {
782
+ object: "subgroup";
783
+ id: string;
784
+ name: string;
785
+ default: boolean;
786
+ }
787
+ export interface CommunityParticipant {
788
+ object: "community_participant";
789
+ contactId: ContactId;
790
+ }
791
+ export interface Channel {
792
+ object: "channel";
793
+ id: string;
794
+ accountId: string;
795
+ name: string;
796
+ description: string | null;
797
+ inviteCode: string | null;
798
+ subscriberCount: number;
799
+ verified: boolean;
800
+ status: string | null;
801
+ role: string | null;
802
+ muted: boolean;
803
+ pictureUrl: string | null;
804
+ previewUrl: string | null;
805
+ createdAt: string | null;
806
+ }
807
+ export interface ChannelCreateParams {
808
+ name: string;
809
+ description?: string;
810
+ /** JPEG, base64. */
811
+ pictureBase64?: string;
812
+ }
813
+ export interface ChannelMessage {
814
+ object: "channel_message";
815
+ id: string;
816
+ accountId: string;
817
+ channelId: string;
818
+ type: string;
819
+ text: string | null;
820
+ viewCount: number | null;
821
+ /** Count per emoji. */
822
+ reactions: Record<string, number>;
823
+ sentAt: string | null;
824
+ }
825
+ export type InvitationStatus = "pending" | "in_progress" | "completed" | "failed" | "cancelled" | "expired";
826
+ export type InvitationMethod = "qr_code" | "pairing_code";
827
+ export interface Invitation {
828
+ object: "invitation";
829
+ id: string;
830
+ projectId: string | null;
831
+ status: InvitationStatus;
832
+ /** The page to send. Only on create and resend. */
833
+ url: string | null;
834
+ inviteeName: string | null;
835
+ inviteeEmail: string | null;
836
+ inviteePhone: string | null;
837
+ suggestedCountry: string | null;
838
+ methods: InvitationMethod[];
839
+ accountName: string | null;
840
+ /** Set once `status` is `completed`. */
841
+ accountId: string | null;
842
+ /** The preset location, or what the invitee picked on the page. `null` until chosen. */
843
+ proxyLocation: ProxyLocation | null;
844
+ failureReason: string | null;
845
+ returnUrl: string | null;
846
+ metadata: Record<string, string>;
847
+ /** When the invitation email was queued, if any. */
848
+ emailSentAt: string | null;
849
+ expiresAt: string;
850
+ viewedAt: string | null;
851
+ startedAt: string | null;
852
+ completedAt: string | null;
853
+ createdAt: string;
854
+ updatedAt: string;
855
+ }
856
+ export interface InvitationCreateParams {
857
+ projectId?: string;
858
+ /** Preset the proxy location. Without it, the invitee picks the country and city on the page. */
859
+ proxyLocation?: ProxyLocation;
860
+ accountName?: string;
861
+ inviteeName?: string;
862
+ inviteeEmail?: string;
863
+ inviteePhone?: string;
864
+ suggestedCountry?: string;
865
+ methods?: InvitationMethod[];
866
+ returnUrl?: string;
867
+ expiresInDays?: number;
868
+ metadata?: Record<string, string>;
869
+ }
870
+ export interface InvitationListParams extends ProjectListParams {
871
+ status?: InvitationStatus;
872
+ }
873
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["account.qr_code_issued", "account.pairing_code_issued", "account.connected", "account.disconnected", "account.failed", "message.received", "message.sent", "message.delivered", "message.read", "message.failed", "message.edited", "message.deleted", "poll.voted", "group.joined", "group.updated", "group.join_requested", "group.join_request_revoked", "chat.updated", "chat.presence_updated", "contact.presence_updated", "contact.picture_updated", "contact.updated", "blocklist.updated", "label.updated", "call.received", "call.ended", "channel.message_received", "channel.message_updated", "channel.updated", "history.synced", "project.created", "project.updated", "project.deleted", "invitation.status_changed"];
874
+ export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
875
+ export interface WebhookEndpoint {
876
+ object: "webhook_endpoint";
877
+ id: string;
878
+ /** `null`: an organization endpoint, which receives every project's events. */
879
+ projectId: string | null;
880
+ url: string;
881
+ events: WebhookEventType[];
882
+ active: boolean;
883
+ /** Signing secret (`whsec_…`). Only on create and rotate. */
884
+ secret?: string;
885
+ createdAt: string;
886
+ updatedAt: string;
887
+ }
888
+ export interface WebhookEndpointCreateParams {
889
+ url: string;
890
+ events: WebhookEventType[];
891
+ projectId?: string;
892
+ }
893
+ export interface WebhookEndpointUpdateParams {
894
+ url?: string;
895
+ events?: WebhookEventType[];
896
+ active?: boolean;
897
+ }
898
+ export interface PollVote {
899
+ object: "poll_vote";
900
+ accountId: string;
901
+ chatId: ChatId | null;
902
+ messageId: string | null;
903
+ voterId: ContactId;
904
+ options: string[];
905
+ votedAt: string;
906
+ poll: Message | null;
907
+ }
908
+ export interface GroupChange {
909
+ object: "group_change";
910
+ accountId: string;
911
+ groupId: string;
912
+ actorId: ContactId | null;
913
+ added: ContactId[];
914
+ removed: ContactId[];
915
+ promoted: ContactId[];
916
+ demoted: ContactId[];
917
+ name: string | null;
918
+ description: string | null;
919
+ locked: boolean | null;
920
+ announce: boolean | null;
921
+ changes: string[];
922
+ changedAt: string | null;
923
+ }
924
+ export interface ChatChange {
925
+ object: "chat_change";
926
+ accountId: string;
927
+ chatId: ChatId;
928
+ change: "archive" | "pin" | "mute" | "read" | "delete" | "clear" | "star";
929
+ value: unknown;
930
+ messageId: string | null;
931
+ mutedUntil: string | null;
932
+ }
933
+ export interface ChatPresence {
934
+ object: "chat_presence";
935
+ accountId: string;
936
+ chatId: ChatId;
937
+ contactId: ContactId;
938
+ state: ChatPresenceState;
939
+ }
940
+ export interface ContactPresence {
941
+ object: "contact_presence";
942
+ accountId: string;
943
+ contactId: ContactId;
944
+ online: boolean;
945
+ lastSeenAt: string | null;
946
+ }
947
+ export interface PictureChange {
948
+ object: "picture_change";
949
+ accountId: string;
950
+ chatId: ChatId;
951
+ pictureId: string | null;
952
+ removed: boolean;
953
+ changedBy: ContactId | null;
954
+ changedAt: string | null;
955
+ }
956
+ export interface BlocklistChange {
957
+ object: "blocklist_change";
958
+ accountId: string;
959
+ changes: Array<{
960
+ contactId: ContactId;
961
+ action: "block" | "unblock";
962
+ }>;
963
+ /** WhatsApp only said the list changed: call `contacts.listBlocked()`. */
964
+ refetch: boolean;
965
+ }
966
+ export interface LabelChange {
967
+ object: "label_change";
968
+ accountId: string;
969
+ kind: "label" | "chat" | "message";
970
+ labelId: string;
971
+ name: string | null;
972
+ color: number | null;
973
+ deleted: boolean | null;
974
+ chatId: ChatId | null;
975
+ messageId: string | null;
976
+ labeled: boolean | null;
977
+ }
978
+ export interface Call {
979
+ object: "call";
980
+ id: string | null;
981
+ accountId: string;
982
+ from: ContactId | null;
983
+ video: boolean;
984
+ groupId: string | null;
985
+ endReason: string | null;
986
+ startedAt: string | null;
987
+ endedAt: string | null;
988
+ }
989
+ export interface ChannelChange {
990
+ object: "channel_change";
991
+ accountId: string;
992
+ channelId: string;
993
+ change: "followed" | "unfollowed" | "muted" | "unmuted";
994
+ name: string | null;
995
+ role: string | null;
996
+ }
997
+ export interface HistorySync {
998
+ object: "history_sync";
999
+ accountId: string;
1000
+ chunk: number | null;
1001
+ syncType: string | null;
1002
+ progress: number | null;
1003
+ part: number | null;
1004
+ conversationCount: number;
1005
+ messageCount: number;
1006
+ duplicateCount: number;
1007
+ }
1008
+ export interface EventObjectMap {
1009
+ "account.qr_code_issued": Account;
1010
+ "account.pairing_code_issued": Account;
1011
+ "account.connected": Account;
1012
+ "account.disconnected": Account;
1013
+ "account.failed": Account;
1014
+ "message.received": Message;
1015
+ "message.sent": Message;
1016
+ "message.delivered": Message;
1017
+ "message.read": Message;
1018
+ "message.failed": Message;
1019
+ "message.edited": Message;
1020
+ "message.deleted": Message;
1021
+ "poll.voted": PollVote;
1022
+ "group.joined": Group;
1023
+ "group.updated": GroupChange;
1024
+ "group.join_requested": GroupJoinRequest;
1025
+ "group.join_request_revoked": GroupJoinRequest;
1026
+ "chat.updated": ChatChange;
1027
+ "chat.presence_updated": ChatPresence;
1028
+ "contact.presence_updated": ContactPresence;
1029
+ "contact.picture_updated": PictureChange;
1030
+ "contact.updated": Contact;
1031
+ "blocklist.updated": BlocklistChange;
1032
+ "label.updated": LabelChange;
1033
+ "call.received": Call;
1034
+ "call.ended": Call;
1035
+ "channel.message_received": ChannelMessage;
1036
+ "channel.message_updated": ChannelMessage;
1037
+ "channel.updated": ChannelChange;
1038
+ "history.synced": HistorySync;
1039
+ "project.created": Project;
1040
+ "project.updated": Project;
1041
+ "project.deleted": Project;
1042
+ "invitation.status_changed": Invitation;
1043
+ }
1044
+ interface PreviousAttributesMap {
1045
+ "message.edited": {
1046
+ text: string | null;
1047
+ };
1048
+ "invitation.status_changed": {
1049
+ status: InvitationStatus;
1050
+ };
1051
+ }
1052
+ /** One webhook delivery body. Deduplicate on `id`. */
1053
+ export type WebhookEventOf<T extends WebhookEventType> = {
1054
+ id: string;
1055
+ object: "event";
1056
+ type: T;
1057
+ createdAt: string;
1058
+ organizationId: string;
1059
+ /** The project the event belongs to. `null` when unassigned. */
1060
+ projectId: string | null;
1061
+ data: T extends keyof PreviousAttributesMap ? {
1062
+ object: EventObjectMap[T];
1063
+ previousAttributes: PreviousAttributesMap[T];
1064
+ } : {
1065
+ object: EventObjectMap[T];
1066
+ };
1067
+ };
1068
+ /** Every webhook event, discriminated on `type`. */
1069
+ export type WebhookEvent = {
1070
+ [T in WebhookEventType]: WebhookEventOf<T>;
1071
+ }[WebhookEventType];
1072
+ export {};
1073
+ //# sourceMappingURL=types.d.ts.map