meta-cloud-api 1.2.0 → 1.4.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.
@@ -1,4 +1,4 @@
1
- import { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum } from "./enums-mxRGX-JN.js";
1
+ import { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum } from "./enums-Dx5yD3dt.js";
2
2
  import { IncomingHttpHeaders, IncomingMessage } from "http";
3
3
 
4
4
  //#region src/types/config.d.ts
@@ -126,6 +126,17 @@ interface Paging {
126
126
  };
127
127
  next: string;
128
128
  }
129
+ /**
130
+ * Common error detail structure used in Meta API responses
131
+ * Used for individual item errors in bulk operations
132
+ */
133
+ interface MetaErrorDetail {
134
+ message: string;
135
+ code: string;
136
+ error_data?: {
137
+ details: string;
138
+ };
139
+ }
129
140
  declare class RequesterClass {
130
141
  constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
131
142
  sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
@@ -394,11 +405,49 @@ type VerifyCodeRequest = {
394
405
  type TwoStepVerificationParams = {
395
406
  pin: string;
396
407
  };
408
+ /**
409
+ * Conversational Components - Commands
410
+ */
411
+ type ConversationalCommand = {
412
+ command_name: string;
413
+ command_description: string;
414
+ };
415
+ /**
416
+ * Conversational Components - Ice Breakers (Prompts)
417
+ */
418
+ type ConversationalPrompt = string;
419
+ /**
420
+ * Request payload for configuring conversational automation
421
+ */
422
+ type ConversationalAutomationRequest = {
423
+ enable_welcome_message?: boolean;
424
+ commands?: ConversationalCommand[];
425
+ prompts?: ConversationalPrompt[];
426
+ };
427
+ /**
428
+ * Response from conversational automation GET endpoint
429
+ */
430
+ type ConversationalAutomationResponse = {
431
+ enable_welcome_message?: boolean;
432
+ commands?: ConversationalCommand[];
433
+ prompts?: ConversationalPrompt[];
434
+ id: string;
435
+ };
436
+ /**
437
+ * Response from throughput GET endpoint
438
+ */
439
+ type ThroughputResponse = {
440
+ throughput: Throughput;
441
+ id: string;
442
+ };
397
443
  interface PhoneNumberClass {
398
444
  getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>;
399
445
  getPhoneNumbers(): Promise<PhoneNumbersResponse>;
400
446
  requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
401
447
  verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>;
448
+ setConversationalAutomation(params: ConversationalAutomationRequest): Promise<ResponseSuccess>;
449
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
450
+ getThroughput(): Promise<ThroughputResponse>;
402
451
  }
403
452
  //#endregion
404
453
  //#region src/api/template/types/common.d.ts
@@ -1195,513 +1244,348 @@ interface MediaClass {
1195
1244
  }
1196
1245
  //#endregion
1197
1246
  //#region src/core/webhook/types.d.ts
1247
+ /**
1248
+ * WhatsApp contact information
1249
+ */
1198
1250
  interface WebhookContact {
1199
- /**
1200
- * WhatsApp ID of the contact. Business can respond to this contact using this ID.
1201
- */
1202
1251
  wa_id: string;
1203
- /**
1204
- * Additional unique, alphanumeric identifier for a WhatsApp user
1205
- */
1206
- user_id?: string;
1207
- /**
1208
- * Profile of Whatsapp user
1209
- */
1210
1252
  profile: {
1211
- /**
1212
- * The display name of the contact
1213
- */
1214
1253
  name: string;
1215
1254
  };
1255
+ identity_key_hash?: string;
1216
1256
  }
1217
1257
  /**
1218
- * Base message interface with common properties
1258
+ * Metadata included in all webhooks
1219
1259
  */
1220
- interface BaseMessage {
1221
- id: string;
1260
+ interface WebhookMetadata {
1261
+ display_phone_number: string;
1262
+ phone_number_id: string;
1263
+ }
1264
+ /**
1265
+ * Error object structure
1266
+ */
1267
+ interface WebhookError {
1268
+ code: number;
1269
+ title: string;
1270
+ message: string;
1271
+ error_data?: {
1272
+ details: string;
1273
+ };
1274
+ href?: string;
1275
+ }
1276
+ /**
1277
+ * Click to WhatsApp ad referral information
1278
+ */
1279
+ interface ReferralInfo {
1280
+ source_url: string;
1281
+ source_id: string;
1282
+ source_type: 'ad';
1283
+ body?: string;
1284
+ headline?: string;
1285
+ media_type?: 'image' | 'video';
1286
+ image_url?: string;
1287
+ video_url?: string;
1288
+ thumbnail_url?: string;
1289
+ ctwa_clid?: string;
1290
+ welcome_message?: {
1291
+ text: string;
1292
+ };
1293
+ }
1294
+ /**
1295
+ * Context for forwarded messages
1296
+ */
1297
+ interface ForwardedContext {
1298
+ forwarded?: true;
1299
+ frequently_forwarded?: true;
1300
+ }
1301
+ /**
1302
+ * Context for product inquiry messages
1303
+ */
1304
+ interface ProductContext {
1222
1305
  from: string;
1223
- timestamp: string;
1224
- type: MessageTypesEnum;
1225
- /**
1226
- * Context object, included when a user replies or interacts
1227
- */
1228
- context?: {
1229
- /**
1230
- * ID of the message
1231
- */
1232
- id?: string;
1233
- /**
1234
- * ID of the sender
1235
- */
1236
- from?: string;
1237
- /**
1238
- * ID of the message being replied to or interacted with
1239
- */
1240
- message_id: string;
1241
- /**
1242
- * ID of the forwarded message, if applicable
1243
- */
1244
- forwarded?: boolean;
1245
- /**
1246
- * Frequently forwarded status
1247
- */
1248
- frequently_forwarded?: boolean;
1249
- /**
1250
- * Original message information if the message was referred
1251
- */
1252
- referred_product?: {
1253
- /**
1254
- * Catalog ID
1255
- */
1256
- catalog_id: string;
1257
- /**
1258
- * Product ID
1259
- */
1260
- product_retailer_id: string;
1261
- };
1306
+ id: string;
1307
+ referred_product: {
1308
+ catalog_id: string;
1309
+ product_retailer_id: string;
1262
1310
  };
1263
- /**
1264
- * Errors array, if the message had errors
1265
- */
1266
- errors?: Array<{
1267
- /**
1268
- * Error code
1269
- */
1270
- code: number;
1271
- /**
1272
- * Error title
1273
- */
1274
- title: string;
1275
- /**
1276
- * Error message
1277
- */
1278
- message: string;
1279
- /**
1280
- * Error details object
1281
- */
1282
- error_data?: {
1283
- /**
1284
- * Describes the error details
1285
- */
1286
- details: string;
1287
- };
1288
- }>;
1289
1311
  }
1290
1312
  /**
1291
- * Text message interface
1313
+ * Context for interactive/button replies
1314
+ */
1315
+ interface ReplyContext {
1316
+ from: string;
1317
+ id: string;
1318
+ }
1319
+ /**
1320
+ * Base message properties common to all message types
1292
1321
  */
1322
+ interface BaseMessage {
1323
+ from: string;
1324
+ id: string;
1325
+ timestamp: string;
1326
+ }
1293
1327
  interface TextMessage extends BaseMessage {
1294
1328
  type: MessageTypesEnum.Text;
1295
1329
  text: {
1296
- /**
1297
- * The text content of the message
1298
- */
1299
1330
  body: string;
1300
- preview_url?: boolean;
1301
1331
  };
1332
+ context?: ForwardedContext | ProductContext;
1333
+ referral?: ReferralInfo;
1302
1334
  }
1303
- /**
1304
- * Image message interface
1305
- */
1306
1335
  interface ImageMessage extends BaseMessage {
1307
1336
  type: MessageTypesEnum.Image;
1308
1337
  image: {
1309
- /**
1310
- * The image caption (if provided)
1311
- */
1312
1338
  caption?: string;
1313
- /**
1314
- * The SHA256 hash of the image
1315
- */
1316
- sha256?: string;
1317
- /**
1318
- * The ID for the image
1319
- */
1320
- id: string;
1321
- /**
1322
- * The MIME type of the image
1323
- */
1324
1339
  mime_type: string;
1340
+ sha256: string;
1341
+ id: string;
1342
+ url: string;
1325
1343
  };
1344
+ context?: ForwardedContext;
1345
+ referral?: ReferralInfo;
1326
1346
  }
1327
- /**
1328
- * Video message interface
1329
- */
1330
1347
  interface VideoMessage extends BaseMessage {
1331
1348
  type: MessageTypesEnum.Video;
1332
1349
  video: {
1333
- /**
1334
- * The video caption (if provided)
1335
- */
1336
1350
  caption?: string;
1337
- /**
1338
- * The SHA256 hash of the video
1339
- */
1340
- sha256?: string;
1341
- /**
1342
- * The ID for the video
1343
- */
1344
- id: string;
1345
- /**
1346
- * The MIME type of the video
1347
- */
1348
1351
  mime_type: string;
1352
+ sha256: string;
1353
+ id: string;
1354
+ url: string;
1349
1355
  };
1356
+ context?: ForwardedContext;
1357
+ referral?: ReferralInfo;
1350
1358
  }
1351
- /**
1352
- * Audio message interface
1353
- */
1354
1359
  interface AudioMessage extends BaseMessage {
1355
1360
  type: MessageTypesEnum.Audio;
1356
1361
  audio: {
1357
- /**
1358
- * The ID for the audio file
1359
- */
1360
- id: string;
1361
- /**
1362
- * The MIME type of the audio file
1363
- */
1364
1362
  mime_type: string;
1365
- /**
1366
- * Whether the audio is a voice message
1367
- */
1368
- voice?: boolean;
1363
+ sha256: string;
1364
+ id: string;
1365
+ url: string;
1366
+ voice: boolean;
1369
1367
  };
1368
+ referral?: ReferralInfo;
1370
1369
  }
1371
- /**
1372
- * Document message interface
1373
- */
1374
1370
  interface DocumentMessage extends BaseMessage {
1375
1371
  type: MessageTypesEnum.Document;
1376
1372
  document: {
1377
- /**
1378
- * The document caption (if provided)
1379
- */
1380
1373
  caption?: string;
1381
- /**
1382
- * The document filename
1383
- */
1384
1374
  filename: string;
1385
- /**
1386
- * The SHA256 hash of the document
1387
- */
1388
- sha256?: string;
1389
- /**
1390
- * The ID for the document
1391
- */
1392
- id: string;
1393
- /**
1394
- * The MIME type of the document
1395
- */
1396
1375
  mime_type: string;
1376
+ sha256: string;
1377
+ id: string;
1378
+ url: string;
1397
1379
  };
1380
+ referral?: ReferralInfo;
1398
1381
  }
1399
- /**
1400
- * Sticker message interface
1401
- */
1402
1382
  interface StickerMessage extends BaseMessage {
1403
1383
  type: MessageTypesEnum.Sticker;
1404
1384
  sticker: {
1405
- /**
1406
- * The ID for the sticker
1407
- */
1385
+ mime_type: string;
1386
+ sha256: string;
1408
1387
  id: string;
1409
- /**
1410
- * Whether this is an animated sticker
1411
- */
1388
+ url: string;
1412
1389
  animated: boolean;
1413
- /**
1414
- * The MIME type of the sticker
1415
- */
1416
- mime_type: string;
1417
1390
  };
1391
+ referral?: ReferralInfo;
1418
1392
  }
1419
- /**
1420
- * Reaction message interface
1421
- */
1422
- interface ReactionMessage extends BaseMessage {
1423
- type: MessageTypesEnum.Reaction;
1424
- reaction: {
1425
- /**
1426
- * The ID of the message being reacted to
1427
- */
1428
- message_id: string;
1429
- /**
1430
- * Emoji used for the reaction
1431
- */
1432
- emoji: string;
1393
+ interface InteractiveListReplyMessage extends BaseMessage {
1394
+ type: MessageTypesEnum.Interactive;
1395
+ context: ReplyContext;
1396
+ interactive: {
1397
+ type: 'list_reply';
1398
+ list_reply: {
1399
+ id: string;
1400
+ title: string;
1401
+ description?: string;
1402
+ };
1433
1403
  };
1434
1404
  }
1435
- /**
1436
- * Contacts message interface
1437
- */
1405
+ interface InteractiveButtonReplyMessage extends BaseMessage {
1406
+ type: MessageTypesEnum.Interactive;
1407
+ context: ReplyContext;
1408
+ interactive: {
1409
+ type: 'button_reply';
1410
+ button_reply: {
1411
+ id: string;
1412
+ title: string;
1413
+ };
1414
+ };
1415
+ }
1416
+ type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage;
1417
+ interface ButtonMessage extends BaseMessage {
1418
+ type: MessageTypesEnum.Button;
1419
+ context: ReplyContext;
1420
+ button: {
1421
+ payload: string;
1422
+ text: string;
1423
+ };
1424
+ }
1425
+ interface LocationMessage extends BaseMessage {
1426
+ type: MessageTypesEnum.Location;
1427
+ location: {
1428
+ latitude: number;
1429
+ longitude: number;
1430
+ name?: string;
1431
+ address?: string;
1432
+ url?: string;
1433
+ };
1434
+ referral?: ReferralInfo;
1435
+ }
1438
1436
  interface ContactsMessage extends BaseMessage {
1439
1437
  type: MessageTypesEnum.Contacts;
1440
1438
  contacts: Array<{
1441
- /**
1442
- * The contact's name
1443
- */
1439
+ addresses?: Array<{
1440
+ city?: string;
1441
+ country?: string;
1442
+ country_code?: string;
1443
+ state?: string;
1444
+ street?: string;
1445
+ type?: string;
1446
+ zip?: string;
1447
+ }>;
1448
+ birthday?: string;
1449
+ emails?: Array<{
1450
+ email: string;
1451
+ type?: string;
1452
+ }>;
1444
1453
  name: {
1445
- /**
1446
- * The formatted name
1447
- */
1448
1454
  formatted_name: string;
1449
- /**
1450
- * The first name
1451
- */
1452
1455
  first_name?: string;
1453
- /**
1454
- * The last name
1455
- */
1456
1456
  last_name?: string;
1457
- /**
1458
- * The middle name
1459
- */
1460
1457
  middle_name?: string;
1461
- /**
1462
- * The suffix
1463
- */
1464
1458
  suffix?: string;
1465
- /**
1466
- * The prefix
1467
- */
1468
1459
  prefix?: string;
1469
1460
  };
1470
- /**
1471
- * The contact's phone numbers
1472
- */
1473
- phones?: Array<{
1474
- phone: string;
1475
- type?: string;
1476
- wa_id?: string;
1477
- }>;
1478
- /**
1479
- * The contact's emails
1480
- */
1481
- emails?: Array<{
1482
- email: string;
1483
- type?: string;
1484
- }>;
1485
- /**
1486
- * The contact's addresses
1487
- */
1488
- addresses?: Array<{
1489
- street?: string;
1490
- city?: string;
1491
- state?: string;
1492
- zip?: string;
1493
- country?: string;
1494
- country_code?: string;
1495
- type?: string;
1496
- }>;
1497
- /**
1498
- * The contact's organizations
1499
- */
1500
1461
  org?: {
1501
1462
  company?: string;
1502
1463
  department?: string;
1503
1464
  title?: string;
1504
1465
  };
1505
- /**
1506
- * The contact's URLs
1507
- */
1466
+ phones?: Array<{
1467
+ phone: string;
1468
+ wa_id?: string;
1469
+ type?: string;
1470
+ }>;
1508
1471
  urls?: Array<{
1509
1472
  url: string;
1510
1473
  type?: string;
1511
1474
  }>;
1512
- /**
1513
- * The contact's birthday (YYYY-MM-DD format)
1514
- */
1515
- birthday?: string;
1516
1475
  }>;
1476
+ referral?: ReferralInfo;
1517
1477
  }
1518
- /**
1519
- * Location message interface
1520
- */
1521
- interface LocationMessage extends BaseMessage {
1522
- type: MessageTypesEnum.Location;
1523
- location: {
1524
- /**
1525
- * Latitude of the location
1526
- */
1527
- latitude: number;
1528
- /**
1529
- * Longitude of the location
1530
- */
1531
- longitude: number;
1532
- /**
1533
- * Name of the location
1534
- */
1535
- name?: string;
1536
- /**
1537
- * Address of the location
1538
- */
1539
- address?: string;
1540
- };
1541
- }
1542
- /**
1543
- * Interactive message interface
1544
- */
1545
- interface InteractiveMessage extends BaseMessage {
1546
- type: MessageTypesEnum.Interactive;
1547
- interactive: {
1548
- /**
1549
- * Type of the interactive message
1550
- * Can be: button_reply, list_reply, flow, nfm_reply, etc.
1551
- */
1552
- type: string;
1553
- /**
1554
- * ID for the button that was clicked
1555
- */
1556
- button_reply?: {
1557
- id: string;
1558
- title: string;
1559
- };
1560
- /**
1561
- * ID for the list item that was selected
1562
- */
1563
- list_reply?: {
1564
- id: string;
1565
- title: string;
1566
- description?: string;
1567
- };
1568
- /**
1569
- * NFM (No-Code Flow Message) reply data
1570
- */
1571
- nfm_reply?: {
1572
- /**
1573
- * Response data in JSON format
1574
- */
1575
- response_json: string;
1576
- /**
1577
- * Body text of the reply
1578
- */
1579
- body: string;
1580
- /**
1581
- * Name of the flow
1582
- */
1583
- name: string;
1584
- };
1585
- };
1586
- }
1587
- /**
1588
- * System message interface
1589
- */
1590
- interface SystemMessage extends BaseMessage {
1591
- type: MessageTypesEnum.System;
1592
- system: {
1593
- /**
1594
- * The type of system update
1595
- */
1596
- type: string;
1597
- /**
1598
- * User's identity if the update is a customer identity change
1599
- */
1600
- identity?: string;
1601
- /**
1602
- * Old and new phone numbers if the update is a phone number change
1603
- */
1604
- customer?: {
1605
- /**
1606
- * The previous phone number
1607
- */
1608
- previous_wa_id: string;
1609
- /**
1610
- * The new phone number
1611
- */
1612
- wa_id: string;
1613
- };
1478
+ interface ReactionMessage extends BaseMessage {
1479
+ type: MessageTypesEnum.Reaction;
1480
+ reaction: {
1481
+ message_id: string;
1482
+ emoji?: string;
1614
1483
  };
1615
1484
  }
1616
- /**
1617
- * Order message interface
1618
- */
1619
1485
  interface OrderMessage extends BaseMessage {
1620
1486
  type: MessageTypesEnum.Order;
1621
1487
  order: {
1622
- /**
1623
- * Catalog ID
1624
- */
1625
1488
  catalog_id: string;
1626
- /**
1627
- * Product items in the order
1628
- */
1489
+ text?: string;
1629
1490
  product_items: Array<{
1630
- /**
1631
- * Product ID
1632
- */
1633
1491
  product_retailer_id: string;
1634
- /**
1635
- * Quantity of the product
1636
- */
1637
1492
  quantity: number;
1638
- /**
1639
- * Item price
1640
- */
1641
1493
  item_price: number;
1642
- /**
1643
- * Currency code
1644
- */
1645
1494
  currency: string;
1646
1495
  }>;
1647
- /**
1648
- * Text message included with the order
1649
- */
1650
- text?: string;
1651
1496
  };
1652
1497
  }
1498
+ interface SystemMessage extends BaseMessage {
1499
+ type: MessageTypesEnum.System;
1500
+ system: {
1501
+ body: string;
1502
+ wa_id: string;
1503
+ type: 'user_changed_number';
1504
+ };
1505
+ }
1506
+ interface UnsupportedMessage extends BaseMessage {
1507
+ type: MessageTypesEnum.Unsupported;
1508
+ errors: Array<WebhookError>;
1509
+ }
1510
+ type GroupMessage = {
1511
+ group_id: string;
1512
+ } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
1513
+ type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1514
+ interface StatusWebhook {
1515
+ id: string;
1516
+ status: 'sent' | 'delivered' | 'read' | 'failed';
1517
+ timestamp: string;
1518
+ recipient_id: string;
1519
+ recipient_type?: 'group';
1520
+ recipient_participant_id?: string;
1521
+ recipient_identity_key_hash?: string;
1522
+ biz_opaque_callback_data?: string;
1523
+ conversation?: {
1524
+ id: string;
1525
+ expiration_timestamp?: string;
1526
+ origin: {
1527
+ type: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1528
+ };
1529
+ };
1530
+ pricing?: {
1531
+ billable: boolean;
1532
+ pricing_model: 'CBP' | 'PMP';
1533
+ type: 'regular' | 'free_customer_service' | 'free_entry_point';
1534
+ category: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1535
+ };
1536
+ errors?: Array<WebhookError>;
1537
+ }
1653
1538
  /**
1654
- * Button message interface
1539
+ * Webhook value for incoming messages
1655
1540
  */
1656
- interface ButtonMessage extends BaseMessage {
1657
- type: MessageTypesEnum.Button;
1658
- button: {
1659
- /**
1660
- * The payload for the button
1661
- */
1662
- payload: string;
1663
- /**
1664
- * Button text
1665
- */
1666
- text: string;
1667
- };
1541
+ interface MessageWebhookValue {
1542
+ messaging_product: 'whatsapp';
1543
+ metadata: WebhookMetadata;
1544
+ contacts: Array<WebhookContact>;
1545
+ messages: Array<WhatsAppMessage>;
1668
1546
  }
1669
1547
  /**
1548
+ * Webhook value for status updates
1549
+ */
1550
+ interface StatusWebhookValue {
1551
+ messaging_product: 'whatsapp';
1552
+ metadata: WebhookMetadata;
1553
+ statuses: Array<StatusWebhook>;
1554
+ }
1555
+ /**
1556
+ * Webhook value for errors (no contacts or messages)
1557
+ */
1558
+ interface ErrorWebhookValue {
1559
+ messaging_product: 'whatsapp';
1560
+ metadata: WebhookMetadata;
1561
+ errors: Array<WebhookError>;
1562
+ }
1563
+ /**
1564
+ * Union type for all webhook value types
1565
+ */
1566
+ type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
1567
+ interface WebhookPayload {
1568
+ object: 'whatsapp_business_account';
1569
+ entry: Array<{
1570
+ id: string;
1571
+ changes: Array<{
1572
+ value: WebhookValue;
1573
+ field: 'messages';
1574
+ }>;
1575
+ }>;
1576
+ }
1577
+ /**
1578
+ * @deprecated Use specific message types instead
1670
1579
  * Represents a message received through the webhook
1671
- * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
1672
1580
  */
1673
1581
  interface WebhookMessage {
1674
- /**
1675
- * The WhatsApp Business Account ID
1676
- */
1677
1582
  wabaId: string;
1678
- /**
1679
- * The message ID
1680
- */
1681
1583
  id: string;
1682
- /**
1683
- * The sender's phone number
1684
- */
1685
1584
  from: string;
1686
- /**
1687
- * The timestamp of the message
1688
- */
1689
1585
  timestamp: string;
1690
- /**
1691
- * The type of message (text, image, etc.)
1692
- */
1693
1586
  type: MessageTypesEnum;
1694
- /**
1695
- * The phone number ID that received the message
1696
- */
1697
1587
  phoneNumberId: string;
1698
- /**
1699
- * The display phone number that received the message
1700
- */
1701
1588
  displayPhoneNumber: string;
1702
- /**
1703
- * The profile name of the sender
1704
- */
1705
1589
  profileName: string;
1706
1590
  text?: TextMessage['text'];
1707
1591
  image?: ImageMessage['image'];
@@ -1716,129 +1600,15 @@ interface WebhookMessage {
1716
1600
  order?: OrderMessage['order'];
1717
1601
  system?: SystemMessage['system'];
1718
1602
  reaction?: ReactionMessage['reaction'];
1719
- statuses?: {
1720
- /**
1721
- * Arbitrary string included in sent message
1722
- */
1723
- biz_opaque_callback_data?: string;
1724
- /**
1725
- * Information about the conversation
1726
- */
1727
- conversation?: {
1728
- /**
1729
- * Represents the ID of the conversation the given status notification belongs to
1730
- */
1731
- id: string;
1732
- /**
1733
- * Describes conversation category
1734
- */
1735
- origin: {
1736
- /**
1737
- * Indicates conversation category. This can also be referred to as a conversation entry point
1738
- * - authentication: Conversation opened by business sending template categorized as AUTHENTICATION
1739
- * - marketing: Conversation opened by business sending template categorized as MARKETING
1740
- * - utility: Conversation opened by business sending template categorized as UTILITY
1741
- * - service: Conversation opened by business replying to customer within service window
1742
- * - referral_conversion: Free entry point conversation
1743
- */
1744
- type: 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1745
- };
1746
- /**
1747
- * Date when the conversation expires. Only present for messages with status 'sent'
1748
- */
1749
- expiration_timestamp?: string;
1750
- };
1751
- /**
1752
- * Array of error objects describing the error
1753
- */
1754
- errors?: Array<{
1755
- /**
1756
- * Error code
1757
- */
1758
- code: number;
1759
- /**
1760
- * Error code title
1761
- */
1762
- title: string;
1763
- /**
1764
- * Error code message
1765
- */
1766
- message: string;
1767
- /**
1768
- * Error details object
1769
- */
1770
- error_data?: {
1771
- /**
1772
- * Describes the error details
1773
- */
1774
- details: string;
1775
- };
1776
- }>;
1777
- /**
1778
- * The ID for the message that the business sent to a customer
1779
- */
1780
- id: string;
1781
- /**
1782
- * Pricing information for the message/conversation
1783
- */
1784
- pricing?: {
1785
- /**
1786
- * Indicates if the given message or conversation is billable
1787
- * @deprecated This field is deprecated. Visit the WhatsApp Changelog for more information.
1788
- */
1789
- billable?: boolean;
1790
- /**
1791
- * Indicates the conversation category:
1792
- * - authentication: Authentication conversation
1793
- * - authentication_international: Authentication-international conversation
1794
- * - marketing: Marketing conversation
1795
- * - utility: Utility conversation
1796
- * - service: Service conversation
1797
- * - referral_conversion: Free entry point conversation
1798
- */
1799
- category: 'authentication' | 'authentication_international' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1800
- /**
1801
- * Type of pricing model used by the business. Current supported value is CBP
1802
- */
1803
- pricing_model: 'CBP';
1804
- };
1805
- /**
1806
- * The customer's WhatsApp ID. Business can respond to customer using this ID.
1807
- * This ID may not match the customer's phone number.
1808
- */
1809
- recipient_id: string;
1810
- /**
1811
- * Status of the message:
1812
- * - delivered: Message has been delivered
1813
- * - read: Message has been read by the customer
1814
- * - sent: Message has been sent to the customer
1815
- */
1816
- status: 'delivered' | 'read' | 'sent';
1817
- /**
1818
- * Unix timestamp for the status message
1819
- */
1820
- timestamp: string;
1821
- };
1822
- /**
1823
- * The original message data as received from the webhook
1824
- */
1603
+ statuses?: StatusWebhook;
1825
1604
  originalData: any;
1826
1605
  }
1827
1606
  /**
1828
1607
  * Webhook event received from WhatsApp
1829
1608
  */
1830
1609
  interface WebhookEvent {
1831
- /**
1832
- * The field type of the event
1833
- */
1834
1610
  field: string;
1835
- /**
1836
- * The event data
1837
- */
1838
1611
  value: any;
1839
- /**
1840
- * The timestamp when the event was received
1841
- */
1842
1612
  timestamp: number;
1843
1613
  }
1844
1614
  //#endregion
@@ -2423,5 +2193,90 @@ interface FlowClass {
2423
2193
  }): Promise<FlowMigrationResponse>;
2424
2194
  }
2425
2195
  //#endregion
2426
- export { type AccountMode, type AudioMediaObject, AudioMediaTypesEnum, type AuthenticationTemplateOptions, type BaseClass, type BodyOptions, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, BusinessVerticalEnum, type ButtonOptions, ButtonPositionEnum, type CarouselCard, type CarouselOptions, type CatalogButton, type CatalogTemplateOptions, CategoryEnum, type CodeVerificationStatus, type ComponentTypes, ComponentTypesEnum, type ContactObject, ConversationTypesEnum, type CopyCodeButton, type CouponTemplateOptions, CreateFlowResponse, type CreateQrCodeRequest, CurrencyCodesEnum, type CurrencyParameter, type Cursors, DataLocalizationRegionEnum, type DateTimeParameter, type DocumentMediaObject, DocumentMediaTypesEnum, type EncryptionPublicKeyResponse, type Flow, FlowActionEnum, type FlowAsset, type FlowAssetsResponse, type FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type HeaderOptions, type HealthStatus, type HealthStatusEntity, HttpMethodsEnum, type HttpsClientClass, type HttpsClientResponseClass, type ImageMediaObject, ImageMediaTypesEnum, type InteractiveObject, InteractiveTypesEnum, LanguagesEnum, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, type LocationObject, type LocationParameter, type LoggerInterface, type MPMButton, type MPMTemplateOptions, type MediaCardCarouselTemplateOptions, type MediaCarouselCard, MediaClass, type MediaParameter, MediaResponse, MediasResponse, type MessageRequestBody, type MessageRequestParams, type MessageTemplateObject, MessageTypesEnum, type MessagesClass, type MessagesResponse, type MessagingLimitTier, type MetaError, type OTPButton, type OTPTemplateOptions, type Pagination, type PaginationCursors, type Paging, ParametersTypesEnum, type PhoneNumberButton, type PhoneNumberClass, type PhoneNumberResponse, type PhoneNumbersResponse, type PlatformType, type ProductCardCarouselTemplateOptions, type ProductCarouselCard, type ProductParameter, type ProductSection, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, type QualityRating, type QualityScore, type QuickReplyButton, type ReactionParams, ReferralSourceTypesEnum, type RegistrationClass, type RegistrationRequest, RequestCodeMethodsEnum, type RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, type SPMButton, type SPMTemplateOptions, StatusEnum, type StatusParams, type StickerMediaObject, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, type TemplateBody, type TemplateButton, type TemplateButtons, type TemplateCarousel, type TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateLimitedTimeOffer, type TemplateOptions, type TemplateParameter, type TemplateRequestBody, type TemplateResponse, TemplateStatusEnum, type TextMessageParams, type TextObject, type TextParameter, type Throughput, type ThroughputLevel, type TwoStepVerificationClass, type TwoStepVerificationParams, type TwoStepVerificationRequest, type URLButton, type UpdateBusinessProfileRequest, type UpdateFlowResponse, type UpdateQrCodeRequest, type UpdateWabaSubscription, UploadMediaResponse, type ValidateFlowJsonResponse, type VerifyCodeRequest, type VideoMediaObject, VideoMediaTypesEnum, type WABAClass, type WabaAccount, type WabaAccountFields, type WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, type WabaHealthStatus, WabaHealthStatusCanSendMessage, type WabaHealthStatusEntity, type WabaHealthStatusError, type WabaSubscription, type WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookMessage, WebhookTypesEnum, type WhatsAppConfig };
2196
+ //#region src/api/blockUsers/types/blockUsers.d.ts
2197
+ /**
2198
+ * Blocked user information in response
2199
+ */
2200
+ type BlockedUserInfo = {
2201
+ input: string;
2202
+ wa_id: string;
2203
+ };
2204
+ /**
2205
+ * Failed user information with error details
2206
+ * Uses common MetaErrorDetail type for consistency across APIs
2207
+ */
2208
+ type FailedUserInfo = BlockedUserInfo & {
2209
+ errors?: MetaErrorDetail[];
2210
+ };
2211
+ /**
2212
+ * Response for block/unblock operations
2213
+ */
2214
+ type BlockUsersResponse = {
2215
+ messaging_product: 'whatsapp';
2216
+ block_users: {
2217
+ added_users?: BlockedUserInfo[];
2218
+ failed_users?: FailedUserInfo[];
2219
+ };
2220
+ };
2221
+ /**
2222
+ * Pagination cursors for list operations
2223
+ */
2224
+ type PagingCursors = {
2225
+ after?: string;
2226
+ before?: string;
2227
+ };
2228
+ /**
2229
+ * Pagination information
2230
+ */
2231
+ type PagingInfo = {
2232
+ cursors?: PagingCursors;
2233
+ previous?: string;
2234
+ next?: string;
2235
+ };
2236
+ /**
2237
+ * List blocked users response
2238
+ */
2239
+ type ListBlockedUsersResponse = {
2240
+ data: Array<{
2241
+ block_users: BlockedUserInfo[];
2242
+ }>;
2243
+ paging?: PagingInfo;
2244
+ };
2245
+ /**
2246
+ * Query parameters for listing blocked users
2247
+ */
2248
+ type ListBlockedUsersParams = {
2249
+ limit?: number;
2250
+ after?: string;
2251
+ before?: string;
2252
+ };
2253
+ /**
2254
+ * Block Users API Interface
2255
+ */
2256
+ interface BlockUsersClass {
2257
+ /**
2258
+ * Block one or more WhatsApp users
2259
+ * @param users - Array of phone numbers or WhatsApp IDs to block
2260
+ * @returns Response with successfully blocked and failed users
2261
+ * @throws Error if users have not messaged in last 24 hours
2262
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
2263
+ */
2264
+ block(users: string[]): Promise<BlockUsersResponse>;
2265
+ /**
2266
+ * Unblock one or more WhatsApp users
2267
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
2268
+ * @returns Response with successfully unblocked and failed users
2269
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
2270
+ */
2271
+ unblock(users: string[]): Promise<BlockUsersResponse>;
2272
+ /**
2273
+ * Get list of blocked WhatsApp users with pagination
2274
+ * @param params - Optional pagination parameters
2275
+ * @returns List of blocked users with pagination info
2276
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
2277
+ */
2278
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
2279
+ }
2280
+ //#endregion
2281
+ export { type AccountMode, type AudioMediaObject, AudioMediaTypesEnum, type AudioMessage, type AuthenticationTemplateOptions, type BaseClass, type BlockUsersClass, type BlockUsersResponse, type BlockedUserInfo, type BodyOptions, type BusinessProfileClass, type BusinessProfileData, type BusinessProfileField, type BusinessProfileFieldsParam, type BusinessProfileResponse, BusinessVerticalEnum, type ButtonMessage, type ButtonOptions, ButtonPositionEnum, type CarouselCard, type CarouselOptions, type CatalogButton, type CatalogTemplateOptions, CategoryEnum, type CodeVerificationStatus, type ComponentTypes, ComponentTypesEnum, type ContactObject, type ContactsMessage, ConversationTypesEnum, type CopyCodeButton, type CouponTemplateOptions, CreateFlowResponse, type CreateQrCodeRequest, CurrencyCodesEnum, type CurrencyParameter, type Cursors, DataLocalizationRegionEnum, type DateTimeParameter, type DocumentMediaObject, DocumentMediaTypesEnum, type DocumentMessage, type EncryptionPublicKeyResponse, type ErrorWebhookValue, type FailedUserInfo, type Flow, FlowActionEnum, type FlowAsset, type FlowAssetsResponse, type FlowButton, FlowCategoryEnum, type FlowClass, type FlowDataExchangeRequest, type FlowDataExchangeResponse, type FlowDecryptedRequestResponse, type FlowEncryptedRequestPayload, type FlowEndpointRequest, type FlowEndpointResponse, type FlowErrorNotificationRequest, type FlowErrorNotificationResponse, type FlowHealthCheckRequest, type FlowHealthCheckResponse, type FlowHttpRequest, type FlowMigrationFailure, type FlowMigrationResponse, type FlowMigrationResult, type FlowPreview, type FlowPreviewResponse, FlowStatusEnum, type FlowSuccessScreenResponse, type FlowType, FlowTypeEnum, type FlowValidationError, type FlowValidationErrorPointer, type FlowsListResponse, type FooterOptions, type GeneralHeaderInterface, type GeneralMessageBody, type GeneralRequestBody, type GroupMessage, type HeaderOptions, type HealthStatus, type HealthStatusEntity, HttpMethodsEnum, type HttpsClientClass, type HttpsClientResponseClass, type ImageMediaObject, ImageMediaTypesEnum, type ImageMessage, type InteractiveButtonReplyMessage, type InteractiveListReplyMessage, type InteractiveMessage, type InteractiveObject, InteractiveTypesEnum, LanguagesEnum, type LimitedTimeOfferOptions, type LimitedTimeOfferTemplateOptions, type ListBlockedUsersParams, type ListBlockedUsersResponse, type LocationMessage, type LocationObject, type LocationParameter, type LoggerInterface, type MPMButton, type MPMTemplateOptions, type MediaCardCarouselTemplateOptions, type MediaCarouselCard, MediaClass, type MediaParameter, MediaResponse, MediasResponse, type MessageRequestBody, type MessageRequestParams, type MessageTemplateObject, MessageTypesEnum, type MessageWebhookValue, type MessagesClass, type MessagesResponse, type MessagingLimitTier, type MetaError, type MetaErrorDetail, type OTPButton, type OTPTemplateOptions, type OrderMessage, type Pagination, type PaginationCursors, type Paging, ParametersTypesEnum, type PhoneNumberButton, type PhoneNumberClass, type PhoneNumberResponse, type PhoneNumbersResponse, type PlatformType, type ProductCardCarouselTemplateOptions, type ProductCarouselCard, type ProductParameter, type ProductSection, type QrCodeClass, type QrCodeResponse, type QrCodesResponse, type QualityRating, type QualityScore, type QuickReplyButton, type ReactionMessage, type ReactionParams, ReferralSourceTypesEnum, type RegistrationClass, type RegistrationRequest, RequestCodeMethodsEnum, type RequestVerificationCodeRequest, type RequesterClass, type RequesterResponseInterface, type ResponseData, type ResponseHeaderValue, type ResponseHeaders, type ResponseJSONBody, type ResponsePagination, type ResponseSuccess, type SPMButton, type SPMTemplateOptions, StatusEnum, type StatusParams, type StatusWebhook, type StatusWebhookValue, type StickerMediaObject, StickerMediaTypesEnum, type StickerMessage, SubTypeEnum, SystemChangeTypesEnum, type SystemMessage, type TemplateBody, type TemplateButton, type TemplateButtons, type TemplateCarousel, type TemplateClass, type TemplateDeleteParams, type TemplateFooter, type TemplateFormat, type TemplateGetParams, type TemplateHeader, type TemplateHeaderExample, type TemplateLimitedTimeOffer, type TemplateOptions, type TemplateParameter, type TemplateRequestBody, type TemplateResponse, TemplateStatusEnum, type TextMessage, type TextMessageParams, type TextObject, type TextParameter, type Throughput, type ThroughputLevel, type TwoStepVerificationClass, type TwoStepVerificationParams, type TwoStepVerificationRequest, type URLButton, type UnsupportedMessage, type UpdateBusinessProfileRequest, type UpdateFlowResponse, type UpdateQrCodeRequest, type UpdateWabaSubscription, UploadMediaResponse, type ValidateFlowJsonResponse, type VerifyCodeRequest, type VideoMediaObject, VideoMediaTypesEnum, type VideoMessage, type WABAClass, type WabaAccount, type WabaAccountFields, type WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaBusinessVerificationStatus, WabaConfigEnum, type WabaConfigType, type WabaHealthStatus, WabaHealthStatusCanSendMessage, type WabaHealthStatusEntity, type WabaHealthStatusError, type WabaSubscription, type WabaSubscriptions, type WebhookContact, type WebhookEvent, type WebhookMessage, type WebhookPayload, WebhookTypesEnum, type WebhookValue, type WhatsAppConfig, type WhatsAppMessage };
2427
2282
  //# sourceMappingURL=index.d.ts.map