meta-cloud-api 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -36,7 +36,11 @@ declare enum MessageTypesEnum {
36
36
  Button = "button",
37
37
  Order = "order",
38
38
  System = "system",
39
+ Unsupported = "unsupported",
39
40
  Unknown = "unknown",
41
+ /**
42
+ * @deprecated Use WebhookProcessor.onStatus() instead of onMessage(MessageTypesEnum.Statuses)
43
+ */
40
44
  Statuses = "statuses",
41
45
  '*' = "*",
42
46
  }
@@ -786,6 +790,17 @@ interface Paging {
786
790
  };
787
791
  next: string;
788
792
  }
793
+ /**
794
+ * Common error detail structure used in Meta API responses
795
+ * Used for individual item errors in bulk operations
796
+ */
797
+ interface MetaErrorDetail {
798
+ message: string;
799
+ code: string;
800
+ error_data?: {
801
+ details: string;
802
+ };
803
+ }
789
804
  declare class RequesterClass {
790
805
  constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
791
806
  sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
@@ -794,50 +809,6 @@ declare class RequesterClass {
794
809
  sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
795
810
  }
796
811
  //#endregion
797
- //#region src/types/httpsClient.d.ts
798
- type ResponseHeaderValue = string | string[] | undefined;
799
- type ResponseHeaders = Record<string, ResponseHeaderValue>;
800
- type ResponseJSONBody = Record<string, unknown>;
801
- declare class HttpsClientResponseClass {
802
- constructor(resp: Response);
803
- statusCode: () => number;
804
- headers: () => ResponseHeaders;
805
- rawResponse: () => Response;
806
- json: () => Promise<ResponseJSONBody>;
807
- }
808
- declare class HttpsClientClass {
809
- constructor();
810
- clearSockets: () => boolean;
811
- sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
812
- }
813
- //#endregion
814
- //#region src/utils/http/httpsClient.d.ts
815
- declare class HttpsClient implements HttpsClientClass {
816
- agent: Agent;
817
- constructor();
818
- clearSockets(): boolean;
819
- sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
820
- }
821
- //#endregion
822
- //#region src/utils/http/request.d.ts
823
- declare class Requester implements RequesterClass {
824
- client: Readonly<HttpsClient>;
825
- accessToken: Readonly<string>;
826
- phoneNumberId: Readonly<number>;
827
- businessAcctId: Readonly<string>;
828
- apiVersion: Readonly<string>;
829
- userAgent: Readonly<string>;
830
- host: Readonly<string>;
831
- protocol: Readonly<string>;
832
- constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
833
- buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
834
- buildCAPIPath(endpoint: string): string;
835
- sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
836
- getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
837
- sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
838
- sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
839
- }
840
- //#endregion
841
812
  //#region src/types/base.d.ts
842
813
  declare class BaseClass {
843
814
  constructor(config: WabaConfigType);
@@ -851,534 +822,349 @@ declare class BaseAPI implements BaseClass {
851
822
  protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
852
823
  }
853
824
  //#endregion
854
- //#region src/api/encryption/types/publicKey.d.ts
855
- type EncryptionPublicKeyResponse = ResponseData<{
856
- business_public_key: string;
857
- business_public_key_signature_status: 'VALID' | 'MISMATCH';
858
- }>;
859
- //#endregion
860
- //#region src/api/encryption/types/common.d.ts
861
- interface EncryptionClass {
862
- getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
863
- setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
864
- }
865
- //#endregion
866
- //#region src/api/encryption/EncryptionApi.d.ts
867
- declare class EncryptionApi extends BaseAPI implements EncryptionClass {
868
- private readonly endpoint;
869
- constructor(config: WabaConfigType, client: RequesterClass);
870
- getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
871
- setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
872
- }
873
- //#endregion
874
825
  //#region src/core/webhook/types.d.ts
826
+ /**
827
+ * WhatsApp contact information
828
+ */
875
829
  interface WebhookContact {
876
- /**
877
- * WhatsApp ID of the contact. Business can respond to this contact using this ID.
878
- */
879
830
  wa_id: string;
880
- /**
881
- * Additional unique, alphanumeric identifier for a WhatsApp user
882
- */
883
- user_id?: string;
884
- /**
885
- * Profile of Whatsapp user
886
- */
887
831
  profile: {
888
- /**
889
- * The display name of the contact
890
- */
891
832
  name: string;
892
833
  };
834
+ identity_key_hash?: string;
893
835
  }
894
836
  /**
895
- * Base message interface with common properties
837
+ * Metadata included in all webhooks
896
838
  */
897
- interface BaseMessage {
898
- id: string;
839
+ interface WebhookMetadata {
840
+ display_phone_number: string;
841
+ phone_number_id: string;
842
+ }
843
+ /**
844
+ * Error object structure
845
+ */
846
+ interface WebhookError {
847
+ code: number;
848
+ title: string;
849
+ message: string;
850
+ error_data?: {
851
+ details: string;
852
+ };
853
+ href?: string;
854
+ }
855
+ /**
856
+ * Click to WhatsApp ad referral information
857
+ */
858
+ interface ReferralInfo {
859
+ source_url: string;
860
+ source_id: string;
861
+ source_type: 'ad';
862
+ body?: string;
863
+ headline?: string;
864
+ media_type?: 'image' | 'video';
865
+ image_url?: string;
866
+ video_url?: string;
867
+ thumbnail_url?: string;
868
+ ctwa_clid?: string;
869
+ welcome_message?: {
870
+ text: string;
871
+ };
872
+ }
873
+ /**
874
+ * Context for forwarded messages
875
+ */
876
+ interface ForwardedContext {
877
+ forwarded?: true;
878
+ frequently_forwarded?: true;
879
+ }
880
+ /**
881
+ * Context for product inquiry messages
882
+ */
883
+ interface ProductContext {
899
884
  from: string;
900
- timestamp: string;
901
- type: MessageTypesEnum;
902
- /**
903
- * Context object, included when a user replies or interacts
904
- */
905
- context?: {
906
- /**
907
- * ID of the message
908
- */
909
- id?: string;
910
- /**
911
- * ID of the sender
912
- */
913
- from?: string;
914
- /**
915
- * ID of the message being replied to or interacted with
916
- */
917
- message_id: string;
918
- /**
919
- * ID of the forwarded message, if applicable
920
- */
921
- forwarded?: boolean;
922
- /**
923
- * Frequently forwarded status
924
- */
925
- frequently_forwarded?: boolean;
926
- /**
927
- * Original message information if the message was referred
928
- */
929
- referred_product?: {
930
- /**
931
- * Catalog ID
932
- */
933
- catalog_id: string;
934
- /**
935
- * Product ID
936
- */
937
- product_retailer_id: string;
938
- };
885
+ id: string;
886
+ referred_product: {
887
+ catalog_id: string;
888
+ product_retailer_id: string;
939
889
  };
940
- /**
941
- * Errors array, if the message had errors
942
- */
943
- errors?: Array<{
944
- /**
945
- * Error code
946
- */
947
- code: number;
948
- /**
949
- * Error title
950
- */
951
- title: string;
952
- /**
953
- * Error message
954
- */
955
- message: string;
956
- /**
957
- * Error details object
958
- */
959
- error_data?: {
960
- /**
961
- * Describes the error details
962
- */
963
- details: string;
964
- };
965
- }>;
966
890
  }
967
891
  /**
968
- * Text message interface
892
+ * Context for interactive/button replies
969
893
  */
894
+ interface ReplyContext {
895
+ from: string;
896
+ id: string;
897
+ }
898
+ /**
899
+ * Base message properties common to all message types
900
+ */
901
+ interface BaseMessage {
902
+ from: string;
903
+ id: string;
904
+ timestamp: string;
905
+ }
970
906
  interface TextMessage extends BaseMessage {
971
907
  type: MessageTypesEnum.Text;
972
908
  text: {
973
- /**
974
- * The text content of the message
975
- */
976
909
  body: string;
977
- preview_url?: boolean;
978
910
  };
911
+ context?: ForwardedContext | ProductContext;
912
+ referral?: ReferralInfo;
979
913
  }
980
- /**
981
- * Image message interface
982
- */
983
914
  interface ImageMessage extends BaseMessage {
984
915
  type: MessageTypesEnum.Image;
985
916
  image: {
986
- /**
987
- * The image caption (if provided)
988
- */
989
917
  caption?: string;
990
- /**
991
- * The SHA256 hash of the image
992
- */
993
- sha256?: string;
994
- /**
995
- * The ID for the image
996
- */
997
- id: string;
998
- /**
999
- * The MIME type of the image
1000
- */
1001
918
  mime_type: string;
919
+ sha256: string;
920
+ id: string;
921
+ url: string;
1002
922
  };
923
+ context?: ForwardedContext;
924
+ referral?: ReferralInfo;
1003
925
  }
1004
- /**
1005
- * Video message interface
1006
- */
1007
926
  interface VideoMessage extends BaseMessage {
1008
927
  type: MessageTypesEnum.Video;
1009
928
  video: {
1010
- /**
1011
- * The video caption (if provided)
1012
- */
1013
929
  caption?: string;
1014
- /**
1015
- * The SHA256 hash of the video
1016
- */
1017
- sha256?: string;
1018
- /**
1019
- * The ID for the video
1020
- */
1021
- id: string;
1022
- /**
1023
- * The MIME type of the video
1024
- */
1025
930
  mime_type: string;
931
+ sha256: string;
932
+ id: string;
933
+ url: string;
1026
934
  };
935
+ context?: ForwardedContext;
936
+ referral?: ReferralInfo;
1027
937
  }
1028
- /**
1029
- * Audio message interface
1030
- */
1031
938
  interface AudioMessage extends BaseMessage {
1032
939
  type: MessageTypesEnum.Audio;
1033
940
  audio: {
1034
- /**
1035
- * The ID for the audio file
1036
- */
1037
- id: string;
1038
- /**
1039
- * The MIME type of the audio file
1040
- */
1041
941
  mime_type: string;
1042
- /**
1043
- * Whether the audio is a voice message
1044
- */
1045
- voice?: boolean;
942
+ sha256: string;
943
+ id: string;
944
+ url: string;
945
+ voice: boolean;
1046
946
  };
947
+ referral?: ReferralInfo;
1047
948
  }
1048
- /**
1049
- * Document message interface
1050
- */
1051
949
  interface DocumentMessage extends BaseMessage {
1052
950
  type: MessageTypesEnum.Document;
1053
951
  document: {
1054
- /**
1055
- * The document caption (if provided)
1056
- */
1057
952
  caption?: string;
1058
- /**
1059
- * The document filename
1060
- */
1061
953
  filename: string;
1062
- /**
1063
- * The SHA256 hash of the document
1064
- */
1065
- sha256?: string;
1066
- /**
1067
- * The ID for the document
1068
- */
1069
- id: string;
1070
- /**
1071
- * The MIME type of the document
1072
- */
1073
954
  mime_type: string;
955
+ sha256: string;
956
+ id: string;
957
+ url: string;
1074
958
  };
959
+ referral?: ReferralInfo;
1075
960
  }
1076
- /**
1077
- * Sticker message interface
1078
- */
1079
961
  interface StickerMessage extends BaseMessage {
1080
962
  type: MessageTypesEnum.Sticker;
1081
963
  sticker: {
1082
- /**
1083
- * The ID for the sticker
1084
- */
964
+ mime_type: string;
965
+ sha256: string;
1085
966
  id: string;
1086
- /**
1087
- * Whether this is an animated sticker
1088
- */
967
+ url: string;
1089
968
  animated: boolean;
1090
- /**
1091
- * The MIME type of the sticker
1092
- */
1093
- mime_type: string;
1094
969
  };
970
+ referral?: ReferralInfo;
1095
971
  }
1096
- /**
1097
- * Reaction message interface
1098
- */
1099
- interface ReactionMessage extends BaseMessage {
1100
- type: MessageTypesEnum.Reaction;
1101
- reaction: {
1102
- /**
1103
- * The ID of the message being reacted to
1104
- */
1105
- message_id: string;
1106
- /**
1107
- * Emoji used for the reaction
1108
- */
1109
- emoji: string;
972
+ interface InteractiveListReplyMessage extends BaseMessage {
973
+ type: MessageTypesEnum.Interactive;
974
+ context: ReplyContext;
975
+ interactive: {
976
+ type: 'list_reply';
977
+ list_reply: {
978
+ id: string;
979
+ title: string;
980
+ description?: string;
981
+ };
1110
982
  };
1111
983
  }
1112
- /**
1113
- * Contacts message interface
1114
- */
984
+ interface InteractiveButtonReplyMessage extends BaseMessage {
985
+ type: MessageTypesEnum.Interactive;
986
+ context: ReplyContext;
987
+ interactive: {
988
+ type: 'button_reply';
989
+ button_reply: {
990
+ id: string;
991
+ title: string;
992
+ };
993
+ };
994
+ }
995
+ type InteractiveMessage = InteractiveListReplyMessage | InteractiveButtonReplyMessage;
996
+ interface ButtonMessage extends BaseMessage {
997
+ type: MessageTypesEnum.Button;
998
+ context: ReplyContext;
999
+ button: {
1000
+ payload: string;
1001
+ text: string;
1002
+ };
1003
+ }
1004
+ interface LocationMessage extends BaseMessage {
1005
+ type: MessageTypesEnum.Location;
1006
+ location: {
1007
+ latitude: number;
1008
+ longitude: number;
1009
+ name?: string;
1010
+ address?: string;
1011
+ url?: string;
1012
+ };
1013
+ referral?: ReferralInfo;
1014
+ }
1115
1015
  interface ContactsMessage extends BaseMessage {
1116
1016
  type: MessageTypesEnum.Contacts;
1117
1017
  contacts: Array<{
1118
- /**
1119
- * The contact's name
1120
- */
1018
+ addresses?: Array<{
1019
+ city?: string;
1020
+ country?: string;
1021
+ country_code?: string;
1022
+ state?: string;
1023
+ street?: string;
1024
+ type?: string;
1025
+ zip?: string;
1026
+ }>;
1027
+ birthday?: string;
1028
+ emails?: Array<{
1029
+ email: string;
1030
+ type?: string;
1031
+ }>;
1121
1032
  name: {
1122
- /**
1123
- * The formatted name
1124
- */
1125
1033
  formatted_name: string;
1126
- /**
1127
- * The first name
1128
- */
1129
1034
  first_name?: string;
1130
- /**
1131
- * The last name
1132
- */
1133
1035
  last_name?: string;
1134
- /**
1135
- * The middle name
1136
- */
1137
1036
  middle_name?: string;
1138
- /**
1139
- * The suffix
1140
- */
1141
1037
  suffix?: string;
1142
- /**
1143
- * The prefix
1144
- */
1145
1038
  prefix?: string;
1146
1039
  };
1147
- /**
1148
- * The contact's phone numbers
1149
- */
1150
- phones?: Array<{
1151
- phone: string;
1152
- type?: string;
1153
- wa_id?: string;
1154
- }>;
1155
- /**
1156
- * The contact's emails
1157
- */
1158
- emails?: Array<{
1159
- email: string;
1160
- type?: string;
1161
- }>;
1162
- /**
1163
- * The contact's addresses
1164
- */
1165
- addresses?: Array<{
1166
- street?: string;
1167
- city?: string;
1168
- state?: string;
1169
- zip?: string;
1170
- country?: string;
1171
- country_code?: string;
1172
- type?: string;
1173
- }>;
1174
- /**
1175
- * The contact's organizations
1176
- */
1177
1040
  org?: {
1178
1041
  company?: string;
1179
1042
  department?: string;
1180
1043
  title?: string;
1181
1044
  };
1182
- /**
1183
- * The contact's URLs
1184
- */
1045
+ phones?: Array<{
1046
+ phone: string;
1047
+ wa_id?: string;
1048
+ type?: string;
1049
+ }>;
1185
1050
  urls?: Array<{
1186
1051
  url: string;
1187
1052
  type?: string;
1188
1053
  }>;
1189
- /**
1190
- * The contact's birthday (YYYY-MM-DD format)
1191
- */
1192
- birthday?: string;
1193
1054
  }>;
1055
+ referral?: ReferralInfo;
1194
1056
  }
1195
- /**
1196
- * Location message interface
1197
- */
1198
- interface LocationMessage extends BaseMessage {
1199
- type: MessageTypesEnum.Location;
1200
- location: {
1201
- /**
1202
- * Latitude of the location
1203
- */
1204
- latitude: number;
1205
- /**
1206
- * Longitude of the location
1207
- */
1208
- longitude: number;
1209
- /**
1210
- * Name of the location
1211
- */
1212
- name?: string;
1213
- /**
1214
- * Address of the location
1215
- */
1216
- address?: string;
1057
+ interface ReactionMessage extends BaseMessage {
1058
+ type: MessageTypesEnum.Reaction;
1059
+ reaction: {
1060
+ message_id: string;
1061
+ emoji?: string;
1217
1062
  };
1218
1063
  }
1219
- /**
1220
- * Interactive message interface
1221
- */
1222
- interface InteractiveMessage extends BaseMessage {
1223
- type: MessageTypesEnum.Interactive;
1224
- interactive: {
1225
- /**
1226
- * Type of the interactive message
1227
- * Can be: button_reply, list_reply, flow, nfm_reply, etc.
1228
- */
1229
- type: string;
1230
- /**
1231
- * ID for the button that was clicked
1232
- */
1233
- button_reply?: {
1234
- id: string;
1235
- title: string;
1236
- };
1237
- /**
1238
- * ID for the list item that was selected
1239
- */
1240
- list_reply?: {
1241
- id: string;
1242
- title: string;
1243
- description?: string;
1244
- };
1245
- /**
1246
- * NFM (No-Code Flow Message) reply data
1247
- */
1248
- nfm_reply?: {
1249
- /**
1250
- * Response data in JSON format
1251
- */
1252
- response_json: string;
1253
- /**
1254
- * Body text of the reply
1255
- */
1256
- body: string;
1257
- /**
1258
- * Name of the flow
1259
- */
1260
- name: string;
1261
- };
1262
- };
1263
- }
1264
- /**
1265
- * System message interface
1266
- */
1267
- interface SystemMessage extends BaseMessage {
1268
- type: MessageTypesEnum.System;
1269
- system: {
1270
- /**
1271
- * The type of system update
1272
- */
1273
- type: string;
1274
- /**
1275
- * User's identity if the update is a customer identity change
1276
- */
1277
- identity?: string;
1278
- /**
1279
- * Old and new phone numbers if the update is a phone number change
1280
- */
1281
- customer?: {
1282
- /**
1283
- * The previous phone number
1284
- */
1285
- previous_wa_id: string;
1286
- /**
1287
- * The new phone number
1288
- */
1289
- wa_id: string;
1290
- };
1291
- };
1292
- }
1293
- /**
1294
- * Order message interface
1295
- */
1296
1064
  interface OrderMessage extends BaseMessage {
1297
1065
  type: MessageTypesEnum.Order;
1298
1066
  order: {
1299
- /**
1300
- * Catalog ID
1301
- */
1302
1067
  catalog_id: string;
1303
- /**
1304
- * Product items in the order
1305
- */
1068
+ text?: string;
1306
1069
  product_items: Array<{
1307
- /**
1308
- * Product ID
1309
- */
1310
1070
  product_retailer_id: string;
1311
- /**
1312
- * Quantity of the product
1313
- */
1314
1071
  quantity: number;
1315
- /**
1316
- * Item price
1317
- */
1318
1072
  item_price: number;
1319
- /**
1320
- * Currency code
1321
- */
1322
1073
  currency: string;
1323
1074
  }>;
1324
- /**
1325
- * Text message included with the order
1326
- */
1327
- text?: string;
1328
1075
  };
1329
1076
  }
1077
+ interface SystemMessage extends BaseMessage {
1078
+ type: MessageTypesEnum.System;
1079
+ system: {
1080
+ body: string;
1081
+ wa_id: string;
1082
+ type: 'user_changed_number';
1083
+ };
1084
+ }
1085
+ interface UnsupportedMessage extends BaseMessage {
1086
+ type: MessageTypesEnum.Unsupported;
1087
+ errors: Array<WebhookError>;
1088
+ }
1089
+ type GroupMessage = {
1090
+ group_id: string;
1091
+ } & (TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | LocationMessage | ContactsMessage);
1092
+ type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | InteractiveMessage | ButtonMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | GroupMessage;
1093
+ interface StatusWebhook {
1094
+ id: string;
1095
+ status: 'sent' | 'delivered' | 'read' | 'failed';
1096
+ timestamp: string;
1097
+ recipient_id: string;
1098
+ recipient_type?: 'group';
1099
+ recipient_participant_id?: string;
1100
+ recipient_identity_key_hash?: string;
1101
+ biz_opaque_callback_data?: string;
1102
+ conversation?: {
1103
+ id: string;
1104
+ expiration_timestamp?: string;
1105
+ origin: {
1106
+ type: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1107
+ };
1108
+ };
1109
+ pricing?: {
1110
+ billable: boolean;
1111
+ pricing_model: 'CBP' | 'PMP';
1112
+ type: 'regular' | 'free_customer_service' | 'free_entry_point';
1113
+ category: 'authentication' | 'authentication_international' | 'marketing' | 'marketing_lite' | 'referral_conversion' | 'service' | 'utility';
1114
+ };
1115
+ errors?: Array<WebhookError>;
1116
+ }
1330
1117
  /**
1331
- * Button message interface
1118
+ * Webhook value for incoming messages
1332
1119
  */
1333
- interface ButtonMessage extends BaseMessage {
1334
- type: MessageTypesEnum.Button;
1335
- button: {
1336
- /**
1337
- * The payload for the button
1338
- */
1339
- payload: string;
1340
- /**
1341
- * Button text
1342
- */
1343
- text: string;
1344
- };
1120
+ interface MessageWebhookValue {
1121
+ messaging_product: 'whatsapp';
1122
+ metadata: WebhookMetadata;
1123
+ contacts: Array<WebhookContact>;
1124
+ messages: Array<WhatsAppMessage>;
1125
+ }
1126
+ /**
1127
+ * Webhook value for status updates
1128
+ */
1129
+ interface StatusWebhookValue {
1130
+ messaging_product: 'whatsapp';
1131
+ metadata: WebhookMetadata;
1132
+ statuses: Array<StatusWebhook>;
1133
+ }
1134
+ /**
1135
+ * Webhook value for errors (no contacts or messages)
1136
+ */
1137
+ interface ErrorWebhookValue {
1138
+ messaging_product: 'whatsapp';
1139
+ metadata: WebhookMetadata;
1140
+ errors: Array<WebhookError>;
1141
+ }
1142
+ /**
1143
+ * Union type for all webhook value types
1144
+ */
1145
+ type WebhookValue = MessageWebhookValue | StatusWebhookValue | ErrorWebhookValue;
1146
+ interface WebhookPayload {
1147
+ object: 'whatsapp_business_account';
1148
+ entry: Array<{
1149
+ id: string;
1150
+ changes: Array<{
1151
+ value: WebhookValue;
1152
+ field: 'messages';
1153
+ }>;
1154
+ }>;
1345
1155
  }
1346
1156
  /**
1157
+ * @deprecated Use specific message types instead
1347
1158
  * Represents a message received through the webhook
1348
- * Based on Meta's documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
1349
1159
  */
1350
1160
  interface WebhookMessage {
1351
- /**
1352
- * The WhatsApp Business Account ID
1353
- */
1354
1161
  wabaId: string;
1355
- /**
1356
- * The message ID
1357
- */
1358
1162
  id: string;
1359
- /**
1360
- * The sender's phone number
1361
- */
1362
1163
  from: string;
1363
- /**
1364
- * The timestamp of the message
1365
- */
1366
1164
  timestamp: string;
1367
- /**
1368
- * The type of message (text, image, etc.)
1369
- */
1370
1165
  type: MessageTypesEnum;
1371
- /**
1372
- * The phone number ID that received the message
1373
- */
1374
1166
  phoneNumberId: string;
1375
- /**
1376
- * The display phone number that received the message
1377
- */
1378
1167
  displayPhoneNumber: string;
1379
- /**
1380
- * The profile name of the sender
1381
- */
1382
1168
  profileName: string;
1383
1169
  text?: TextMessage['text'];
1384
1170
  image?: ImageMessage['image'];
@@ -1393,129 +1179,15 @@ interface WebhookMessage {
1393
1179
  order?: OrderMessage['order'];
1394
1180
  system?: SystemMessage['system'];
1395
1181
  reaction?: ReactionMessage['reaction'];
1396
- statuses?: {
1397
- /**
1398
- * Arbitrary string included in sent message
1399
- */
1400
- biz_opaque_callback_data?: string;
1401
- /**
1402
- * Information about the conversation
1403
- */
1404
- conversation?: {
1405
- /**
1406
- * Represents the ID of the conversation the given status notification belongs to
1407
- */
1408
- id: string;
1409
- /**
1410
- * Describes conversation category
1411
- */
1412
- origin: {
1413
- /**
1414
- * Indicates conversation category. This can also be referred to as a conversation entry point
1415
- * - authentication: Conversation opened by business sending template categorized as AUTHENTICATION
1416
- * - marketing: Conversation opened by business sending template categorized as MARKETING
1417
- * - utility: Conversation opened by business sending template categorized as UTILITY
1418
- * - service: Conversation opened by business replying to customer within service window
1419
- * - referral_conversion: Free entry point conversation
1420
- */
1421
- type: 'authentication' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1422
- };
1423
- /**
1424
- * Date when the conversation expires. Only present for messages with status 'sent'
1425
- */
1426
- expiration_timestamp?: string;
1427
- };
1428
- /**
1429
- * Array of error objects describing the error
1430
- */
1431
- errors?: Array<{
1432
- /**
1433
- * Error code
1434
- */
1435
- code: number;
1436
- /**
1437
- * Error code title
1438
- */
1439
- title: string;
1440
- /**
1441
- * Error code message
1442
- */
1443
- message: string;
1444
- /**
1445
- * Error details object
1446
- */
1447
- error_data?: {
1448
- /**
1449
- * Describes the error details
1450
- */
1451
- details: string;
1452
- };
1453
- }>;
1454
- /**
1455
- * The ID for the message that the business sent to a customer
1456
- */
1457
- id: string;
1458
- /**
1459
- * Pricing information for the message/conversation
1460
- */
1461
- pricing?: {
1462
- /**
1463
- * Indicates if the given message or conversation is billable
1464
- * @deprecated This field is deprecated. Visit the WhatsApp Changelog for more information.
1465
- */
1466
- billable?: boolean;
1467
- /**
1468
- * Indicates the conversation category:
1469
- * - authentication: Authentication conversation
1470
- * - authentication_international: Authentication-international conversation
1471
- * - marketing: Marketing conversation
1472
- * - utility: Utility conversation
1473
- * - service: Service conversation
1474
- * - referral_conversion: Free entry point conversation
1475
- */
1476
- category: 'authentication' | 'authentication_international' | 'marketing' | 'utility' | 'service' | 'referral_conversion';
1477
- /**
1478
- * Type of pricing model used by the business. Current supported value is CBP
1479
- */
1480
- pricing_model: 'CBP';
1481
- };
1482
- /**
1483
- * The customer's WhatsApp ID. Business can respond to customer using this ID.
1484
- * This ID may not match the customer's phone number.
1485
- */
1486
- recipient_id: string;
1487
- /**
1488
- * Status of the message:
1489
- * - delivered: Message has been delivered
1490
- * - read: Message has been read by the customer
1491
- * - sent: Message has been sent to the customer
1492
- */
1493
- status: 'delivered' | 'read' | 'sent';
1494
- /**
1495
- * Unix timestamp for the status message
1496
- */
1497
- timestamp: string;
1498
- };
1499
- /**
1500
- * The original message data as received from the webhook
1501
- */
1182
+ statuses?: StatusWebhook;
1502
1183
  originalData: any;
1503
1184
  }
1504
1185
  /**
1505
1186
  * Webhook event received from WhatsApp
1506
1187
  */
1507
1188
  interface WebhookEvent {
1508
- /**
1509
- * The field type of the event
1510
- */
1511
1189
  field: string;
1512
- /**
1513
- * The event data
1514
- */
1515
1190
  value: any;
1516
- /**
1517
- * The timestamp when the event was received
1518
- */
1519
1191
  timestamp: number;
1520
1192
  }
1521
1193
  /**
@@ -1525,6 +1197,7 @@ declare enum MessageStatus {
1525
1197
  DELIVERED = "delivered",
1526
1198
  READ = "read",
1527
1199
  SENT = "sent",
1200
+ FAILED = "failed",
1528
1201
  }
1529
1202
  //#endregion
1530
1203
  //#region src/types/logger.d.ts
@@ -1536,6 +1209,23 @@ interface LoggerInterface {
1536
1209
  debug(...data: any[]): void;
1537
1210
  }
1538
1211
  //#endregion
1212
+ //#region src/types/httpsClient.d.ts
1213
+ type ResponseHeaderValue = string | string[] | undefined;
1214
+ type ResponseHeaders = Record<string, ResponseHeaderValue>;
1215
+ type ResponseJSONBody = Record<string, unknown>;
1216
+ declare class HttpsClientResponseClass {
1217
+ constructor(resp: Response);
1218
+ statusCode: () => number;
1219
+ headers: () => ResponseHeaders;
1220
+ rawResponse: () => Response;
1221
+ json: () => Promise<ResponseJSONBody>;
1222
+ }
1223
+ declare class HttpsClientClass {
1224
+ constructor();
1225
+ clearSockets: () => boolean;
1226
+ sendRequest: (host: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null) => Promise<HttpsClientResponseClass>;
1227
+ }
1228
+ //#endregion
1539
1229
  //#region src/api/profile/types/upload.d.ts
1540
1230
  /**
1541
1231
  * Upload session information for creating upload sessions.
@@ -1820,11 +1510,49 @@ type VerifyCodeRequest = {
1820
1510
  type TwoStepVerificationParams = {
1821
1511
  pin: string;
1822
1512
  };
1513
+ /**
1514
+ * Conversational Components - Commands
1515
+ */
1516
+ type ConversationalCommand = {
1517
+ command_name: string;
1518
+ command_description: string;
1519
+ };
1520
+ /**
1521
+ * Conversational Components - Ice Breakers (Prompts)
1522
+ */
1523
+ type ConversationalPrompt = string;
1524
+ /**
1525
+ * Request payload for configuring conversational automation
1526
+ */
1527
+ type ConversationalAutomationRequest = {
1528
+ enable_welcome_message?: boolean;
1529
+ commands?: ConversationalCommand[];
1530
+ prompts?: ConversationalPrompt[];
1531
+ };
1532
+ /**
1533
+ * Response from conversational automation GET endpoint
1534
+ */
1535
+ type ConversationalAutomationResponse = {
1536
+ enable_welcome_message?: boolean;
1537
+ commands?: ConversationalCommand[];
1538
+ prompts?: ConversationalPrompt[];
1539
+ id: string;
1540
+ };
1541
+ /**
1542
+ * Response from throughput GET endpoint
1543
+ */
1544
+ type ThroughputResponse = {
1545
+ throughput: Throughput;
1546
+ id: string;
1547
+ };
1823
1548
  interface PhoneNumberClass {
1824
1549
  getPhoneNumberById(fields?: string): Promise<PhoneNumberResponse>;
1825
1550
  getPhoneNumbers(): Promise<PhoneNumbersResponse>;
1826
1551
  requestVerificationCode(params: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
1827
1552
  verifyCode(params: VerifyCodeRequest): Promise<ResponseSuccess>;
1553
+ setConversationalAutomation(params: ConversationalAutomationRequest): Promise<ResponseSuccess>;
1554
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
1555
+ getThroughput(): Promise<ThroughputResponse>;
1828
1556
  }
1829
1557
  //#endregion
1830
1558
  //#region src/api/template/types/common.d.ts
@@ -2780,6 +2508,127 @@ interface TwoStepVerificationClass {
2780
2508
  setTwoStepVerificationCode(pin: string): Promise<ResponseSuccess>;
2781
2509
  }
2782
2510
  //#endregion
2511
+ //#region src/api/encryption/types/publicKey.d.ts
2512
+ type EncryptionPublicKeyResponse = ResponseData<{
2513
+ business_public_key: string;
2514
+ business_public_key_signature_status: 'VALID' | 'MISMATCH';
2515
+ }>;
2516
+ //#endregion
2517
+ //#region src/api/encryption/types/common.d.ts
2518
+ interface EncryptionClass {
2519
+ getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
2520
+ setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
2521
+ }
2522
+ //#endregion
2523
+ //#region src/api/blockUsers/types/blockUsers.d.ts
2524
+ /**
2525
+ * Block Users API Types
2526
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
2527
+ */
2528
+ /**
2529
+ * User object for blocking/unblocking operations
2530
+ */
2531
+ type BlockUserObject = {
2532
+ user: string;
2533
+ };
2534
+ /**
2535
+ * Blocked user information in response
2536
+ */
2537
+ type BlockedUserInfo = {
2538
+ input: string;
2539
+ wa_id: string;
2540
+ };
2541
+ /**
2542
+ * Failed user information with error details
2543
+ * Uses common MetaErrorDetail type for consistency across APIs
2544
+ */
2545
+ type FailedUserInfo = BlockedUserInfo & {
2546
+ errors?: MetaErrorDetail[];
2547
+ };
2548
+ /**
2549
+ * Request body for blocking users
2550
+ */
2551
+ type BlockUsersRequest = {
2552
+ messaging_product: 'whatsapp';
2553
+ block_users: BlockUserObject[];
2554
+ };
2555
+ /**
2556
+ * Request body for unblocking users
2557
+ */
2558
+ type UnblockUsersRequest = {
2559
+ messaging_product: 'whatsapp';
2560
+ block_users: BlockUserObject[];
2561
+ };
2562
+ /**
2563
+ * Response for block/unblock operations
2564
+ */
2565
+ type BlockUsersResponse = {
2566
+ messaging_product: 'whatsapp';
2567
+ block_users: {
2568
+ added_users?: BlockedUserInfo[];
2569
+ failed_users?: FailedUserInfo[];
2570
+ };
2571
+ };
2572
+ /**
2573
+ * Pagination cursors for list operations
2574
+ */
2575
+ type PagingCursors = {
2576
+ after?: string;
2577
+ before?: string;
2578
+ };
2579
+ /**
2580
+ * Pagination information
2581
+ */
2582
+ type PagingInfo = {
2583
+ cursors?: PagingCursors;
2584
+ previous?: string;
2585
+ next?: string;
2586
+ };
2587
+ /**
2588
+ * List blocked users response
2589
+ */
2590
+ type ListBlockedUsersResponse = {
2591
+ data: Array<{
2592
+ block_users: BlockedUserInfo[];
2593
+ }>;
2594
+ paging?: PagingInfo;
2595
+ };
2596
+ /**
2597
+ * Query parameters for listing blocked users
2598
+ */
2599
+ type ListBlockedUsersParams = {
2600
+ limit?: number;
2601
+ after?: string;
2602
+ before?: string;
2603
+ };
2604
+ /**
2605
+ * Block Users API Interface
2606
+ */
2607
+ interface BlockUsersClass {
2608
+ /**
2609
+ * Block one or more WhatsApp users
2610
+ * @param users - Array of phone numbers or WhatsApp IDs to block
2611
+ * @returns Response with successfully blocked and failed users
2612
+ * @throws Error if users have not messaged in last 24 hours
2613
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
2614
+ */
2615
+ block(users: string[]): Promise<BlockUsersResponse>;
2616
+ /**
2617
+ * Unblock one or more WhatsApp users
2618
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
2619
+ * @returns Response with successfully unblocked and failed users
2620
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
2621
+ */
2622
+ unblock(users: string[]): Promise<BlockUsersResponse>;
2623
+ /**
2624
+ * Get list of blocked WhatsApp users with pagination
2625
+ * @param params - Optional pagination parameters
2626
+ * @returns List of blocked users with pagination info
2627
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
2628
+ */
2629
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
2630
+ }
2631
+ //#endregion
2783
2632
  //#region src/utils/isMetaError.d.ts
2784
2633
  interface MetaError extends Error {
2785
2634
  error: {
@@ -2794,6 +2643,12 @@ interface MetaError extends Error {
2794
2643
  fbtrace_id: string;
2795
2644
  };
2796
2645
  }
2646
+ /**
2647
+ * Determines if the error is a Meta API error response
2648
+ * @param error Any error object to check
2649
+ * @returns Type guard indicating if error is a Meta API error
2650
+ */
2651
+ declare function isMetaError(error: any): error is MetaError;
2797
2652
  //#endregion
2798
2653
  //#region src/api/flow/types/common.d.ts
2799
2654
  /**
@@ -3326,6 +3181,164 @@ declare class FlowApi extends BaseAPI implements FlowClass {
3326
3181
  }): Promise<FlowMigrationResponse>;
3327
3182
  }
3328
3183
  //#endregion
3184
+ //#region src/utils/flowEncryptionUtils.d.ts
3185
+ /**
3186
+ * Environment model for encryption keys
3187
+ */
3188
+ type EncryptionKeyPair = {
3189
+ passphrase: string;
3190
+ privateKey: string;
3191
+ publicKey: string;
3192
+ };
3193
+ /**
3194
+ * Generates RSA key pair for WhatsApp Business Flow API encryption
3195
+ *
3196
+ * This function generates a 2048-bit RSA key pair with:
3197
+ * - Public key in SPKI format (PEM)
3198
+ * - Private key in PKCS#8 format (PEM) encrypted with AES-256-CBC
3199
+ *
3200
+ * @param passphrase - Passphrase to encrypt the private key. If not provided, uses FLOW_API_PASSPHRASE from environment
3201
+ * @returns Object containing passphrase, privateKey, and publicKey
3202
+ * @throws {Error} If passphrase is empty or key generation fails
3203
+ * @throws {Error} If not running in Node.js environment
3204
+ *
3205
+ * @example
3206
+ * ```typescript
3207
+ * import { WhatsApp } from 'meta-cloud-api';
3208
+ *
3209
+ * const wa = new WhatsApp();
3210
+ *
3211
+ * try {
3212
+ * // Uses FLOW_API_PASSPHRASE from environment
3213
+ * const keys = wa.generateEncryption();
3214
+ * console.log('Public Key:', keys.publicKey);
3215
+ * console.log('Private Key:', keys.privateKey);
3216
+ *
3217
+ * // Or provide custom passphrase
3218
+ * const customKeys = wa.generateEncryption('my-secret-passphrase');
3219
+ * } catch (error) {
3220
+ * console.error('Failed to generate keys:', error.message);
3221
+ * }
3222
+ * ```
3223
+ */
3224
+ declare function generateEncryption(passphrase?: string): EncryptionKeyPair;
3225
+ //#endregion
3226
+ //#region src/utils/http/httpsClient.d.ts
3227
+ declare class HttpsClient implements HttpsClientClass {
3228
+ agent: Agent;
3229
+ constructor();
3230
+ clearSockets(): boolean;
3231
+ sendRequest(hostname: string, path: string, method: HttpMethodsEnum, headers: HeadersInit, timeout: number, body?: BodyInit | null): Promise<HttpsClientResponseClass>;
3232
+ }
3233
+ //#endregion
3234
+ //#region src/utils/http/request.d.ts
3235
+ declare class Requester implements RequesterClass {
3236
+ client: Readonly<HttpsClient>;
3237
+ accessToken: Readonly<string>;
3238
+ phoneNumberId: Readonly<number>;
3239
+ businessAcctId: Readonly<string>;
3240
+ apiVersion: Readonly<string>;
3241
+ userAgent: Readonly<string>;
3242
+ host: Readonly<string>;
3243
+ protocol: Readonly<string>;
3244
+ constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
3245
+ buildHeader(contentType: string, additionalHeaders?: Record<string, string>): HeadersInit;
3246
+ buildCAPIPath(endpoint: string): string;
3247
+ sendRequest(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, contentType?: string, additionalHeaders?: Record<string, string>): Promise<HttpsClientResponseClass>;
3248
+ getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any, additionalHeaders?: Record<string, string>): Promise<T>;
3249
+ sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
3250
+ sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: Record<string, string>, additionalHeaders?: Record<string, string>): Promise<T>;
3251
+ }
3252
+ //#endregion
3253
+ //#region src/api/blockUsers/BlockUsersApi.d.ts
3254
+ /**
3255
+ * Block Users API
3256
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
3257
+ *
3258
+ * Limitations:
3259
+ * - Can only block users that have messaged your business in the last 24 hours
3260
+ * - 64k blocklist limit
3261
+ */
3262
+ declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
3263
+ private readonly endpoint;
3264
+ constructor(config: WabaConfigType, client: RequesterClass);
3265
+ /**
3266
+ * Build request body for block/unblock operations
3267
+ */
3268
+ private buildBlockUsersBody;
3269
+ /**
3270
+ * Block one or more WhatsApp users
3271
+ * @param users - Array of phone numbers or WhatsApp IDs to block
3272
+ * @returns Response with successfully blocked and failed users
3273
+ * @throws Error if users have not messaged in last 24 hours
3274
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
3275
+ *
3276
+ * @example
3277
+ * ```typescript
3278
+ * // Block single user
3279
+ * const result = await client.blockUsers.block(['1234567890']);
3280
+ *
3281
+ * // Block multiple users
3282
+ * const result = await client.blockUsers.block(['1234567890', '0987654321']);
3283
+ *
3284
+ * // Check results
3285
+ * console.log('Blocked:', result.block_users.added_users);
3286
+ * console.log('Failed:', result.block_users.failed_users);
3287
+ * ```
3288
+ */
3289
+ block(users: string[]): Promise<BlockUsersResponse>;
3290
+ /**
3291
+ * Unblock one or more WhatsApp users
3292
+ * @param users - Array of phone numbers or WhatsApp IDs to unblock
3293
+ * @returns Response with successfully unblocked and failed users
3294
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
3295
+ *
3296
+ * @example
3297
+ * ```typescript
3298
+ * // Unblock single user
3299
+ * const result = await client.blockUsers.unblock(['1234567890']);
3300
+ *
3301
+ * // Unblock multiple users
3302
+ * const result = await client.blockUsers.unblock(['1234567890', '0987654321']);
3303
+ *
3304
+ * // Check results
3305
+ * console.log('Unblocked:', result.block_users.added_users);
3306
+ * console.log('Failed:', result.block_users.failed_users);
3307
+ * ```
3308
+ */
3309
+ unblock(users: string[]): Promise<BlockUsersResponse>;
3310
+ /**
3311
+ * Get list of blocked WhatsApp users with pagination
3312
+ * @param params - Optional pagination parameters
3313
+ * @returns List of blocked users with pagination info
3314
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
3315
+ *
3316
+ * @example
3317
+ * ```typescript
3318
+ * // Get first 10 blocked users
3319
+ * const result = await client.blockUsers.listBlockedUsers({ limit: 10 });
3320
+ *
3321
+ * // Pagination with cursor
3322
+ * const nextPage = await client.blockUsers.listBlockedUsers({
3323
+ * limit: 10,
3324
+ * after: result.paging?.cursors?.after
3325
+ * });
3326
+ *
3327
+ * // Get all blocked users
3328
+ * const allBlocked = await client.blockUsers.listBlockedUsers();
3329
+ * ```
3330
+ */
3331
+ listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
3332
+ }
3333
+ //#endregion
3334
+ //#region src/api/encryption/EncryptionApi.d.ts
3335
+ declare class EncryptionApi extends BaseAPI implements EncryptionClass {
3336
+ private readonly endpoint;
3337
+ constructor(config: WabaConfigType, client: RequesterClass);
3338
+ getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
3339
+ setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
3340
+ }
3341
+ //#endregion
3329
3342
  //#region src/api/media/MediaApi.d.ts
3330
3343
  /**
3331
3344
  * API for managing WhatsApp Media.
@@ -3550,542 +3563,7 @@ declare class MessagesApi extends BaseAPI implements MessagesClass {
3550
3563
  reaction(params: ReactionParams): Promise<MessagesResponse>;
3551
3564
  }
3552
3565
  //#endregion
3553
- //#region src/api/messages/builders/ContactMessageBuilder.d.ts
3554
- /**
3555
- * Builder class for creating contact messages with a fluent API
3556
- */
3557
- declare class ContactMessageBuilder {
3558
- private contact;
3559
- /**
3560
- * Set the contact name (required)
3561
- */
3562
- setName(name: NameObject): this;
3563
- /**
3564
- * Set simple name with first name only
3565
- */
3566
- setSimpleName(firstName: string, lastName?: string): this;
3567
- /**
3568
- * Set full name details
3569
- */
3570
- setFullName(firstName: string, lastName?: string, middleName?: string, suffix?: string, prefix?: string): this;
3571
- /**
3572
- * Add phone numbers
3573
- */
3574
- addPhone(phone: string, type?: string, waId?: string): this;
3575
- /**
3576
- * Add email addresses
3577
- */
3578
- addEmail(email: string, type?: string): this;
3579
- /**
3580
- * Add address
3581
- */
3582
- addAddress(address: AddressesObject): this;
3583
- /**
3584
- * Add simple address
3585
- */
3586
- addSimpleAddress(street: string, city: string, country: string, type?: string): this;
3587
- /**
3588
- * Set organization details
3589
- */
3590
- setOrganization(company: string, department?: string, title?: string): this;
3591
- /**
3592
- * Add URL
3593
- */
3594
- addUrl(url: string, type?: string): this;
3595
- /**
3596
- * Set birthday (format: YYYY-MM-DD)
3597
- */
3598
- setBirthday(year: number, month: number, day: number): this;
3599
- /**
3600
- * Build the final contact object
3601
- */
3602
- build(): ContactObject;
3603
- /**
3604
- * Reset the builder for reuse
3605
- */
3606
- reset(): this;
3607
- }
3608
- /**
3609
- * Factory class for common contact patterns
3610
- */
3611
- declare class ContactMessageFactory {
3612
- /**
3613
- * Create a simple contact with name and phone
3614
- */
3615
- static createSimpleContact(firstName: string, phone: string): ContactObject;
3616
- /**
3617
- * Create a business contact
3618
- */
3619
- static createBusinessContact(firstName: string, lastName: string, company: string, title: string, phone: string, email: string): ContactObject;
3620
- /**
3621
- * Create a personal contact with full details
3622
- */
3623
- static createPersonalContact(firstName: string, lastName: string, mobilePhone: string, email?: string, birthday?: {
3624
- year: number;
3625
- month: number;
3626
- day: number;
3627
- }): ContactObject;
3628
- }
3629
- //#endregion
3630
- //#region src/api/messages/builders/InteractiveMessageBuilder.d.ts
3631
- /**
3632
- * Builder class for creating interactive messages with a fluent API
3633
- */
3634
- declare class InteractiveMessageBuilder {
3635
- private message;
3636
- /**
3637
- * Set the interactive message type
3638
- */
3639
- setType(type: InteractiveTypesEnum): this;
3640
- /**
3641
- * Set the body text of the message
3642
- */
3643
- setBody(text: string): this;
3644
- /**
3645
- * Set the footer text of the message
3646
- */
3647
- setFooter(text: string): this;
3648
- /**
3649
- * Set a text header
3650
- */
3651
- setTextHeader(text: string): this;
3652
- /**
3653
- * Set an image header
3654
- */
3655
- setImageHeader(imageUrl: string): this;
3656
- /**
3657
- * Add reply buttons (for button type messages)
3658
- */
3659
- addReplyButtons(buttons: Array<{
3660
- id: string;
3661
- title: string;
3662
- }>): this;
3663
- /**
3664
- * Add list sections (for list type messages)
3665
- * Note: This creates a single section with multiple rows
3666
- */
3667
- addListSections(sections: Array<{
3668
- title?: string;
3669
- rows: Array<{
3670
- id: string;
3671
- title: string;
3672
- description?: string;
3673
- }>;
3674
- }>): this;
3675
- /**
3676
- * Set the button text for list messages
3677
- */
3678
- setListButtonText(buttonText: string): this;
3679
- /**
3680
- * Set CTA URL action
3681
- */
3682
- setCTAUrl(displayText: string, url: string): this;
3683
- /**
3684
- * Build the final interactive object
3685
- */
3686
- build(): InteractiveObject;
3687
- /**
3688
- * Reset the builder for reuse
3689
- */
3690
- reset(): this;
3691
- }
3692
- /**
3693
- * Convenience factory functions for common interactive message types
3694
- */
3695
- declare class InteractiveMessageFactory {
3696
- /**
3697
- * Create a button message with reply buttons
3698
- */
3699
- static createButtonMessage(bodyText: string, buttons: Array<{
3700
- id: string;
3701
- title: string;
3702
- }>, options?: {
3703
- headerText?: string;
3704
- footerText?: string;
3705
- }): InteractiveObject;
3706
- /**
3707
- * Create a list message with sections
3708
- */
3709
- static createListMessage(bodyText: string, buttonText: string, sections: Array<{
3710
- title?: string;
3711
- rows: Array<{
3712
- id: string;
3713
- title: string;
3714
- description?: string;
3715
- }>;
3716
- }>, options?: {
3717
- headerText?: string;
3718
- footerText?: string;
3719
- }): InteractiveObject;
3720
- /**
3721
- * Create a CTA URL message
3722
- */
3723
- static createCTAUrlMessage(bodyText: string, displayText: string, url: string, options?: {
3724
- headerText?: string;
3725
- footerText?: string;
3726
- }): InteractiveObject;
3727
- }
3728
- //#endregion
3729
- //#region src/api/messages/builders/LocationMessageBuilder.d.ts
3730
- /**
3731
- * Builder class for creating location messages with a fluent API
3732
- */
3733
- declare class LocationMessageBuilder {
3734
- private location;
3735
- /**
3736
- * Set the latitude coordinate
3737
- */
3738
- setLatitude(latitude: number): this;
3739
- /**
3740
- * Set the longitude coordinate
3741
- */
3742
- setLongitude(longitude: number): this;
3743
- /**
3744
- * Set coordinates using latitude and longitude
3745
- */
3746
- setCoordinates(latitude: number, longitude: number): this;
3747
- /**
3748
- * Set the location name
3749
- */
3750
- setName(name: string): this;
3751
- /**
3752
- * Set the location address
3753
- */
3754
- setAddress(address: string): this;
3755
- /**
3756
- * Build the final location object
3757
- */
3758
- build(): LocationObject;
3759
- /**
3760
- * Reset the builder for reuse
3761
- */
3762
- reset(): this;
3763
- }
3764
- /**
3765
- * Factory class for common location patterns
3766
- */
3767
- declare class LocationMessageFactory {
3768
- /**
3769
- * Create a simple location with just coordinates
3770
- */
3771
- static createSimpleLocation(latitude: number, longitude: number): LocationObject;
3772
- /**
3773
- * Create a location with name and address
3774
- */
3775
- static createNamedLocation(latitude: number, longitude: number, name: string, address: string): LocationObject;
3776
- /**
3777
- * Create a business location
3778
- */
3779
- static createBusinessLocation(latitude: number, longitude: number, businessName: string, fullAddress: string): LocationObject;
3780
- }
3781
- //#endregion
3782
- //#region src/api/messages/builders/MediaMessageBuilder.d.ts
3783
- /**
3784
- * Base builder for media messages
3785
- */
3786
- declare abstract class BaseMediaBuilder<T> {
3787
- protected media: Partial<T>;
3788
- /**
3789
- * Set media ID (for uploaded media)
3790
- */
3791
- setId(id: string): this;
3792
- /**
3793
- * Set media URL
3794
- */
3795
- setLink(url: string): this;
3796
- /**
3797
- * Set media caption
3798
- */
3799
- setCaption(caption: string): this;
3800
- /**
3801
- * Build the media object
3802
- */
3803
- build(): T;
3804
- /**
3805
- * Reset the builder
3806
- */
3807
- reset(): this;
3808
- }
3809
- /**
3810
- * Builder for image messages
3811
- */
3812
- declare class ImageMessageBuilder extends BaseMediaBuilder<ImageMediaObject> {}
3813
- /**
3814
- * Builder for video messages
3815
- */
3816
- declare class VideoMessageBuilder extends BaseMediaBuilder<VideoMediaObject> {}
3817
- /**
3818
- * Builder for audio messages
3819
- */
3820
- declare class AudioMessageBuilder extends BaseMediaBuilder<AudioMediaObject> {
3821
- setCaption(caption: string): this;
3822
- }
3823
- /**
3824
- * Builder for document messages
3825
- */
3826
- declare class DocumentMessageBuilder extends BaseMediaBuilder<DocumentMediaObject> {
3827
- /**
3828
- * Set document filename
3829
- */
3830
- setFilename(filename: string): this;
3831
- }
3832
- /**
3833
- * Builder for sticker messages
3834
- */
3835
- declare class StickerMessageBuilder extends BaseMediaBuilder<StickerMediaObject> {
3836
- setCaption(caption: string): this;
3837
- }
3838
- /**
3839
- * Factory class for common media patterns
3840
- */
3841
- declare class MediaMessageFactory {
3842
- /**
3843
- * Create an image with caption
3844
- */
3845
- static createImageWithCaption(linkOrId: string, caption: string, isId?: boolean): ImageMediaObject;
3846
- /**
3847
- * Create a video with caption
3848
- */
3849
- static createVideoWithCaption(linkOrId: string, caption: string, isId?: boolean): VideoMediaObject;
3850
- /**
3851
- * Create a document with filename
3852
- */
3853
- static createDocument(linkOrId: string, filename: string, caption?: string, isId?: boolean): DocumentMediaObject;
3854
- /**
3855
- * Create an audio message
3856
- */
3857
- static createAudio(linkOrId: string, isId?: boolean): AudioMediaObject;
3858
- /**
3859
- * Create a sticker message
3860
- */
3861
- static createSticker(linkOrId: string, isId?: boolean): StickerMediaObject;
3862
- }
3863
- //#endregion
3864
- //#region src/api/messages/builders/ReactionMessageBuilder.d.ts
3865
- /**
3866
- * Builder class for creating reaction messages with a fluent API
3867
- */
3868
- declare class ReactionMessageBuilder {
3869
- private reaction;
3870
- /**
3871
- * Set the message ID to react to
3872
- */
3873
- setMessageId(messageId: string): this;
3874
- /**
3875
- * Set the emoji for the reaction
3876
- */
3877
- setEmoji(emoji: string): this;
3878
- /**
3879
- * Remove a reaction (by sending empty emoji)
3880
- */
3881
- removeReaction(): this;
3882
- /**
3883
- * Build the final reaction object
3884
- */
3885
- build(): {
3886
- message_id: string;
3887
- emoji: string;
3888
- };
3889
- /**
3890
- * Reset the builder for reuse
3891
- */
3892
- reset(): this;
3893
- }
3894
- /**
3895
- * Factory class for common reaction patterns
3896
- */
3897
- declare class ReactionMessageFactory {
3898
- /**
3899
- * Create a like reaction
3900
- */
3901
- static createLike(messageId: string): {
3902
- message_id: string;
3903
- emoji: string;
3904
- };
3905
- /**
3906
- * Create a heart reaction
3907
- */
3908
- static createHeart(messageId: string): {
3909
- message_id: string;
3910
- emoji: string;
3911
- };
3912
- /**
3913
- * Create a laughing reaction
3914
- */
3915
- static createLaugh(messageId: string): {
3916
- message_id: string;
3917
- emoji: string;
3918
- };
3919
- /**
3920
- * Create a wow reaction
3921
- */
3922
- static createWow(messageId: string): {
3923
- message_id: string;
3924
- emoji: string;
3925
- };
3926
- /**
3927
- * Create a sad reaction
3928
- */
3929
- static createSad(messageId: string): {
3930
- message_id: string;
3931
- emoji: string;
3932
- };
3933
- /**
3934
- * Create an angry reaction
3935
- */
3936
- static createAngry(messageId: string): {
3937
- message_id: string;
3938
- emoji: string;
3939
- };
3940
- /**
3941
- * Remove a reaction
3942
- */
3943
- static removeReaction(messageId: string): {
3944
- message_id: string;
3945
- emoji: string;
3946
- };
3947
- }
3948
- //#endregion
3949
- //#region src/api/messages/builders/TemplateMessageBuilder.d.ts
3950
- type CurrencyParameterHelper = {
3951
- type: ParametersTypesEnum.Currency;
3952
- currency: {
3953
- fallback_value: string;
3954
- code: CurrencyCodesEnum;
3955
- amount_1000: number;
3956
- };
3957
- };
3958
- type DateTimeParameterHelper = {
3959
- type: ParametersTypesEnum.DateTime;
3960
- date_time: {
3961
- fallback_value: string;
3962
- timestamp: number;
3963
- };
3964
- };
3965
- type ParameterObject = CurrencyParameterHelper | DateTimeParameterHelper;
3966
- /**
3967
- * Builder class for creating template messages with a fluent API
3968
- */
3969
- declare class TemplateMessageBuilder {
3970
- private template;
3971
- /**
3972
- * Set the template name
3973
- */
3974
- setName(name: string): this;
3975
- /**
3976
- * Set the template language
3977
- */
3978
- setLanguage(code: string): this;
3979
- /**
3980
- * Add a header component with text parameters
3981
- */
3982
- addTextHeader(parameters: string[]): this;
3983
- /**
3984
- * Add a header component with image
3985
- */
3986
- addImageHeader(imageUrl: string): this;
3987
- /**
3988
- * Add a body component with text parameters
3989
- */
3990
- addBody(parameters: string[]): this;
3991
- /**
3992
- * Add a footer component (usually no parameters needed)
3993
- */
3994
- addFooter(): this;
3995
- /**
3996
- * Add button components (for quick replies, URLs, etc.)
3997
- */
3998
- addButtons(buttons: Array<{
3999
- index: number;
4000
- type: 'quick_reply' | 'url';
4001
- parameters?: string[];
4002
- }>): this;
4003
- /**
4004
- * Add a currency parameter for header/body
4005
- */
4006
- addCurrencyParameter(fallbackValue: string, currencyCode: string, amount: number): CurrencyParameterHelper;
4007
- /**
4008
- * Add a date time parameter
4009
- */
4010
- addDateTimeParameter(fallbackValue: string, timestamp: number): DateTimeParameterHelper;
4011
- /**
4012
- * Build the final template object
4013
- */
4014
- build(): MessageTemplateObject<ComponentTypesEnum>;
4015
- /**
4016
- * Reset the builder for reuse
4017
- */
4018
- reset(): this;
4019
- }
4020
- /**
4021
- * Factory class for common template patterns
4022
- */
4023
- declare class TemplateMessageFactory {
4024
- /**
4025
- * Create a simple text-only template
4026
- */
4027
- static createSimpleTextTemplate(name: string, language: string, bodyParameters: string[]): MessageTemplateObject<ComponentTypesEnum>;
4028
- /**
4029
- * Create a template with header, body and buttons
4030
- */
4031
- static createCompleteTemplate(name: string, language: string, options: {
4032
- headerParameters?: string[];
4033
- headerImage?: string;
4034
- bodyParameters: string[];
4035
- buttons?: Array<{
4036
- index: number;
4037
- type: 'quick_reply' | 'url';
4038
- parameters?: string[];
4039
- }>;
4040
- }): MessageTemplateObject<ComponentTypesEnum>;
4041
- /**
4042
- * Create an order confirmation template
4043
- */
4044
- static createOrderConfirmationTemplate(language: string, customerName: string, orderNumber: string, amount: number, currencyCode: string): MessageTemplateObject<ComponentTypesEnum>;
4045
- }
4046
- //#endregion
4047
- //#region src/api/messages/builders/TextMessageBuilder.d.ts
4048
- /**
4049
- * Builder class for creating text messages with a fluent API
4050
- */
4051
- declare class TextMessageBuilder {
4052
- private textMessage;
4053
- /**
4054
- * Set the message body text
4055
- */
4056
- setBody(text: string): this;
4057
- /**
4058
- * Enable or disable URL preview
4059
- */
4060
- setPreviewUrl(enable?: boolean): this;
4061
- /**
4062
- * Build the final text object
4063
- */
4064
- build(): TextObject;
4065
- /**
4066
- * Reset the builder for reuse
4067
- */
4068
- reset(): this;
4069
- }
4070
- /**
4071
- * Factory class for common text message patterns
4072
- */
4073
- declare class TextMessageFactory {
4074
- /**
4075
- * Create a simple text message
4076
- */
4077
- static createSimpleText(body: string): TextObject;
4078
- /**
4079
- * Create a text message with URL preview
4080
- */
4081
- static createTextWithPreview(body: string): TextObject;
4082
- /**
4083
- * Create a notification message
4084
- */
4085
- static createNotification(title: string, message: string): TextObject;
4086
- }
4087
- //#endregion
4088
- //#region src/api/phone/PhoneNumberApi.d.ts
3566
+ //#region src/api/phone/PhoneNumberApi.d.ts
4089
3567
  /**
4090
3568
  * API for managing WhatsApp Phone Numb ers.
4091
3569
  *
@@ -4143,6 +3621,71 @@ declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
4143
3621
  * });
4144
3622
  */
4145
3623
  verifyCode(request: VerifyCodeRequest): Promise<ResponseSuccess>;
3624
+ /**
3625
+ * Configure conversational automation features (Welcome Messages, Ice Breakers, Commands).
3626
+ *
3627
+ * @param request Configuration for conversational components
3628
+ * @returns Response indicating success or failure
3629
+ *
3630
+ * @example
3631
+ * // Enable welcome message
3632
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3633
+ * enable_welcome_message: true
3634
+ * });
3635
+ *
3636
+ * @example
3637
+ * // Configure commands
3638
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3639
+ * commands: [
3640
+ * { command_name: 'tickets', command_description: 'Book flight tickets' },
3641
+ * { command_name: 'hotel', command_description: 'Book hotel' }
3642
+ * ]
3643
+ * });
3644
+ *
3645
+ * @example
3646
+ * // Configure ice breakers (prompts)
3647
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3648
+ * prompts: ['Book a flight', 'Plan a vacation']
3649
+ * });
3650
+ *
3651
+ * @example
3652
+ * // Configure all features
3653
+ * await whatsappClient.phoneNumber.setConversationalAutomation({
3654
+ * enable_welcome_message: true,
3655
+ * commands: [
3656
+ * { command_name: 'tickets', command_description: 'Book flight tickets' }
3657
+ * ],
3658
+ * prompts: ['Book a flight']
3659
+ * });
3660
+ */
3661
+ setConversationalAutomation(request: ConversationalAutomationRequest): Promise<ResponseSuccess>;
3662
+ /**
3663
+ * Get the current configuration of conversational automation features.
3664
+ *
3665
+ * @returns Current configuration including welcome message status, commands, and prompts
3666
+ *
3667
+ * @example
3668
+ * const config = await whatsappClient.phoneNumber.getConversationalAutomation();
3669
+ * console.log(config.enable_welcome_message); // true/false
3670
+ * console.log(config.commands); // Array of commands
3671
+ * console.log(config.prompts); // Array of ice breakers
3672
+ */
3673
+ getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
3674
+ /**
3675
+ * Get the current throughput level for the phone number.
3676
+ *
3677
+ * Throughput represents the maximum messages per second (mps) that can be sent/received.
3678
+ * - Default: 80 mps
3679
+ * - Automatic upgrade to 1,000 mps available for eligible numbers
3680
+ * - WhatsApp Business app coexistence numbers: fixed at 5 mps
3681
+ *
3682
+ * @returns Current throughput information including the level (STANDARD, HIGH, or NOT_APPLICABLE)
3683
+ *
3684
+ * @example
3685
+ * const throughput = await whatsappClient.phoneNumber.getThroughput();
3686
+ * console.log(throughput.throughput.level); // 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE'
3687
+ */
3688
+ getThroughput(): Promise<ThroughputResponse>;
4146
3689
  }
4147
3690
  //#endregion
4148
3691
  //#region src/api/profile/BusinessProfileApi.d.ts
@@ -4497,6 +4040,7 @@ declare class WabaApi extends BaseAPI implements WABAClass {
4497
4040
  declare class WhatsApp {
4498
4041
  config: WabaConfigType;
4499
4042
  requester: Readonly<Requester>;
4043
+ blockUsers: BlockUsersApi;
4500
4044
  messages: MessagesApi;
4501
4045
  media: MediaApi;
4502
4046
  phoneNumbers: PhoneNumberApi;
@@ -4527,38 +4071,69 @@ declare class WhatsApp {
4527
4071
  * Get User-Agent string
4528
4072
  */
4529
4073
  getUserAgent(): string;
4074
+ /**
4075
+ * Generate RSA encryption key pair for WhatsApp Business Flow API
4076
+ *
4077
+ * This method generates a 2048-bit RSA key pair with:
4078
+ * - Public key in SPKI format (PEM)
4079
+ * - Private key in PKCS#8 format (PEM) encrypted with AES-256-CBC
4080
+ *
4081
+ * @param passphrase - Optional passphrase to encrypt the private key. If not provided, uses FLOW_API_PASSPHRASE from config
4082
+ * @returns Object containing passphrase, privateKey, and publicKey
4083
+ * @throws {Error} If passphrase is empty or key generation fails
4084
+ * @throws {Error} If not running in Node.js environment
4085
+ *
4086
+ * @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
4087
+ *
4088
+ * @example
4089
+ * ```typescript
4090
+ * const wa = new WhatsApp();
4091
+ *
4092
+ * // Uses FLOW_API_PASSPHRASE from environment/config
4093
+ * const keys = wa.generateEncryption();
4094
+ *
4095
+ * // Or provide custom passphrase
4096
+ * const customKeys = wa.generateEncryption('my-secret-passphrase');
4097
+ *
4098
+ * console.log('Public Key:', keys.publicKey);
4099
+ * console.log('Private Key:', keys.privateKey);
4100
+ * ```
4101
+ */
4102
+ generateEncryption(passphrase?: string): EncryptionKeyPair;
4530
4103
  }
4531
4104
  //#endregion
4532
4105
  //#region src/core/webhook/utils/webhookUtils.d.ts
4533
- type MessageHandler = (whatsapp: WhatsApp, message: WebhookMessage) => void | Promise<void>;
4106
+ /**
4107
+ * Processed message with metadata for handlers
4108
+ */
4109
+ type ProcessedMessage = {
4110
+ wabaId: string;
4111
+ phoneNumberId: string;
4112
+ displayPhoneNumber: string;
4113
+ profileName: string;
4114
+ message: WhatsAppMessage;
4115
+ };
4116
+ /**
4117
+ * Processed status with metadata for handlers
4118
+ */
4119
+ type ProcessedStatus = {
4120
+ wabaId: string;
4121
+ phoneNumberId: string;
4122
+ displayPhoneNumber: string;
4123
+ status: StatusWebhook;
4124
+ };
4125
+ type MessageHandler = (whatsapp: WhatsApp, processed: ProcessedMessage) => void | Promise<void>;
4126
+ type StatusHandler = (whatsapp: WhatsApp, processed: ProcessedStatus) => void | Promise<void>;
4534
4127
  type FlowHandler = (whatsapp: WhatsApp, request: FlowEndpointRequest) => any | Promise<any>;
4535
4128
  /**
4536
4129
  * Process webhook messages
4537
4130
  */
4538
4131
  declare function processWebhookMessages(request: Request, whatsapp: WhatsApp, handlers: {
4539
4132
  messageHandlers: Map<MessageTypesEnum, MessageHandler>;
4133
+ statusHandler?: StatusHandler;
4540
4134
  preProcessHandler?: MessageHandler;
4541
4135
  postProcessHandler?: MessageHandler;
4542
4136
  }): Promise<Response>;
4543
- /**
4544
- * Create a standard ping response for WhatsApp Flow health checks
4545
- * @returns Flow ping response object
4546
- */
4547
- declare function createFlowPingResponse(): {
4548
- version: string;
4549
- data: {
4550
- status: string;
4551
- };
4552
- };
4553
- /**
4554
- * Create a standard error response for WhatsApp Flow error notifications
4555
- * @returns Acknowledgement response for error notification
4556
- */
4557
- declare function createFlowErrorResponse(): {
4558
- data: {
4559
- acknowledged: boolean;
4560
- };
4561
- };
4562
4137
  /**
4563
4138
  * Handle flow requests
4564
4139
  */
@@ -4581,6 +4156,7 @@ declare class WebhookProcessor {
4581
4156
  private config;
4582
4157
  private client;
4583
4158
  private messageHandlers;
4159
+ private statusHandler;
4584
4160
  private preProcessHandler;
4585
4161
  private postProcessHandler;
4586
4162
  private flowHandlers;
@@ -4589,6 +4165,7 @@ declare class WebhookProcessor {
4589
4165
  processWebhook(request: Request): Promise<WebhookResponse>;
4590
4166
  processFlow(request: Request): Promise<WebhookResponse>;
4591
4167
  onMessage(type: MessageTypesEnum, handler: MessageHandler): void;
4168
+ onStatus(handler: StatusHandler): void;
4592
4169
  onMessagePreProcess(handler: MessageHandler): void;
4593
4170
  onMessagePostProcess(handler: MessageHandler): void;
4594
4171
  onFlow(type: FlowTypeEnum, handler: FlowHandler): void;
@@ -4690,5 +4267,73 @@ declare function nextjsAppWebhookHandler(config: NextJsAppWebhookConfig): {
4690
4267
  //#region src/core/webhook/utils/generateXHub256Sig.d.ts
4691
4268
  declare const generateXHub256Sig: (body: string, appSecret: string) => string;
4692
4269
  //#endregion
4693
- export { AccountMode, AudioMediaObject, AudioMediaTypesEnum, AudioMessageBuilder, AuthenticationTemplateOptions, BaseClass, BodyOptions, BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, BusinessVerticalEnum, ButtonOptions, ButtonPositionEnum, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, CategoryEnum, CodeVerificationStatus, ComponentTypes, ComponentTypesEnum, ContactMessageBuilder, ContactMessageFactory, ContactObject, ConversationTypesEnum, CopyCodeButton, CouponTemplateOptions, CreateFlowResponse, CreateQrCodeRequest, CreateUploadSessionParams, CurrencyCodesEnum, CurrencyParameter, CurrencyParameterHelper, Cursors, DataLocalizationRegionEnum, DateTimeParameter, DateTimeParameterHelper, DocumentMediaObject, DocumentMediaTypesEnum, DocumentMessageBuilder, EncryptionApi, EncryptionClass, EncryptionPublicKeyResponse, ExpressRequest, ExpressResponse, ExpressWebhookConfig, Flow, FlowActionEnum, FlowApi, FlowAsset, FlowAssetsResponse, FlowButton, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHandler, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, FooterOptions, GeneralHeaderInterface, GeneralMessageBody, GeneralRequestBody, GetUploadHandleParams, HeaderOptions, HealthStatus, HealthStatusEntity, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaObject, ImageMediaTypesEnum, ImageMessageBuilder, InteractiveMessageBuilder, InteractiveMessageFactory, InteractiveObject, InteractiveTypesEnum, LanguagesEnum, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, LocationMessageBuilder, LocationMessageFactory, LocationObject, LocationParameter, LoggerInterface, MPMButton, MPMTemplateOptions, MediaApi, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, MediaMessageFactory, MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageHandler, MessageRequestBody, MessageRequestParams, MessageStatus, MessageTemplateObject, MessageTypesEnum, MessagesClass, MessagesResponse, MessagingLimitTier, MetaError, NextFunction, NextJsAppWebhookConfig, NextJsWebhookConfig, OTPButton, OTPTemplateOptions, Pagination, PaginationCursors, Paging, ParameterObject, ParametersTypesEnum, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, ReactionMessageBuilder, ReactionMessageFactory, ReactionParams, ReferralSourceTypesEnum, RegistrationApi, RegistrationClass, RegistrationRequest, RequestCodeMethodsEnum, RequestVerificationCodeRequest, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, SPMButton, SPMTemplateOptions, StatusEnum, StatusParams, StickerMediaObject, StickerMediaTypesEnum, StickerMessageBuilder, SubTypeEnum, SystemChangeTypesEnum, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateMessageBuilder, TemplateMessageFactory, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatusEnum, TextMessageBuilder, TextMessageFactory, TextMessageParams, TextObject, TextParameter, Throughput, ThroughputLevel, TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationParams, TwoStepVerificationRequest, URLButton, UpdateBusinessProfileRequest, UpdateFlowResponse, UpdateQrCodeRequest, UpdateWabaSubscription, UploadBusinessProfileResponse, UploadHandle, UploadMediaParams, UploadMediaResponse, UploadSession, UploadSessionResponse, ValidateFlowJsonResponse, VerifyCodeRequest, VideoMediaObject, VideoMediaTypesEnum, VideoMessageBuilder, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, WabaConfigType, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions, WebhookContact, WebhookEvent, WebhookMessage, WebhookProcessor, WebhookResponse, WebhookTypesEnum, WhatsApp, WhatsAppConfig, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createFlowErrorResponse, createFlowPingResponse, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, expressWebhookHandler, generateXHub256Sig, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, processFlowRequest, processWebhookMessages };
4270
+ //#region src/utils/buildFieldsQueryString.d.ts
4271
+ declare function buildFieldsQueryString(fields?: string[] | string): string;
4272
+ //#endregion
4273
+ //#region src/utils/configTable.d.ts
4274
+ /**
4275
+ * Formats configuration as a terminal table
4276
+ * @param config - The WABA configuration object
4277
+ * @param apiName - The name of the API being initialized
4278
+ * @returns Formatted table string
4279
+ */
4280
+ declare function formatConfigTable(config: WabaConfigType): string;
4281
+ //#endregion
4282
+ //#region src/utils/logger.d.ts
4283
+ declare class Logger implements LoggerInterface {
4284
+ private name;
4285
+ private debug;
4286
+ constructor(name: string, debug?: boolean);
4287
+ private formatData;
4288
+ log(...data: any[]): void;
4289
+ error(...data: any[]): void;
4290
+ warn(...data: any[]): void;
4291
+ info(...data: any[]): void;
4292
+ }
4293
+ //#endregion
4294
+ //#region src/utils/objectToQueryString.d.ts
4295
+ declare const objectToQueryString: (params: Record<string, any>) => string;
4296
+ //#endregion
4297
+ //#region src/utils/flowTypeGuards.d.ts
4298
+ declare const DATA_EXCHANGE_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT, FlowActionEnum.BACK];
4299
+ declare const ERROR_ACTIONS: readonly [FlowActionEnum.DATA_EXCHANGE, FlowActionEnum.INIT];
4300
+ /**
4301
+ * Type guard to check if a request is a Data Exchange request
4302
+ * Validates the request structure according to the Flow API specifications
4303
+ *
4304
+ * @param request The Flow endpoint request to check
4305
+ * @returns True if the request is a valid Data Exchange request, false otherwise
4306
+ */
4307
+ declare function isFlowDataExchangeRequest(request: FlowEndpointRequest): request is FlowDataExchangeRequest & {
4308
+ action: (typeof DATA_EXCHANGE_ACTIONS)[number];
4309
+ screen?: string;
4310
+ flow_token: string;
4311
+ data?: Record<string, any>;
4312
+ };
4313
+ /**
4314
+ * Type guard to check if a request is an Error Notification request
4315
+ * Validates the request structure according to the Flow API error specifications
4316
+ *
4317
+ * @param request The Flow endpoint request to check
4318
+ * @returns True if the request is a valid Error Notification request, false otherwise
4319
+ */
4320
+ declare function isFlowErrorRequest(request: FlowEndpointRequest): request is FlowErrorNotificationRequest & {
4321
+ action: (typeof ERROR_ACTIONS)[number];
4322
+ screen: string;
4323
+ flow_token: string;
4324
+ data: {
4325
+ error: string;
4326
+ error_message: string;
4327
+ };
4328
+ };
4329
+ /**
4330
+ * Type guard to check if a request is a Ping (health check) request
4331
+ * Simple validation for health check endpoints in the Flow API
4332
+ *
4333
+ * @param request The Flow endpoint request to check
4334
+ * @returns True if the request is a Ping request, false otherwise
4335
+ */
4336
+ declare function isFlowPingRequest(request: FlowEndpointRequest): request is FlowHealthCheckRequest;
4337
+ //#endregion
4338
+ export { AccountMode, AudioMediaObject, AudioMediaTypesEnum, AudioMessage, AuthenticationTemplateOptions, BaseClass, BlockUserObject, BlockUsersApi, BlockUsersClass, BlockUsersRequest, BlockUsersResponse, BlockedUserInfo, BodyOptions, BusinessProfileApi, BusinessProfileClass, BusinessProfileData, BusinessProfileField, BusinessProfileFieldsParam, BusinessProfileResponse, BusinessVerticalEnum, ButtonMessage, ButtonOptions, ButtonPositionEnum, CarouselCard, CarouselOptions, CatalogButton, CatalogTemplateOptions, CategoryEnum, CodeVerificationStatus, ComponentTypes, ComponentTypesEnum, ContactObject, ContactsMessage, ConversationTypesEnum, CopyCodeButton, CouponTemplateOptions, CreateFlowResponse, CreateQrCodeRequest, CreateUploadSessionParams, CurrencyCodesEnum, CurrencyParameter, Cursors, DataLocalizationRegionEnum, DateTimeParameter, DocumentMediaObject, DocumentMediaTypesEnum, DocumentMessage, EncryptionApi, EncryptionClass, EncryptionKeyPair, EncryptionPublicKeyResponse, ErrorWebhookValue, ExpressRequest, ExpressResponse, ExpressWebhookConfig, FailedUserInfo, Flow, FlowActionEnum, FlowApi, FlowAsset, FlowAssetsResponse, FlowButton, FlowCategoryEnum, FlowClass, FlowDataExchangeRequest, FlowDataExchangeResponse, FlowDecryptedRequestResponse, FlowEncryptedRequestPayload, FlowEndpointRequest, FlowEndpointResponse, FlowErrorNotificationRequest, FlowErrorNotificationResponse, FlowHandler, FlowHealthCheckRequest, FlowHealthCheckResponse, FlowHttpRequest, FlowMigrationFailure, FlowMigrationResponse, FlowMigrationResult, FlowPreview, FlowPreviewResponse, FlowStatusEnum, FlowSuccessScreenResponse, FlowType, FlowTypeEnum, FlowValidationError, FlowValidationErrorPointer, FlowsListResponse, FooterOptions, GeneralHeaderInterface, GeneralMessageBody, GeneralRequestBody, GetUploadHandleParams, GroupMessage, HeaderOptions, HealthStatus, HealthStatusEntity, HttpMethodsEnum, HttpsClientClass, HttpsClientResponseClass, ImageMediaObject, ImageMediaTypesEnum, ImageMessage, InteractiveButtonReplyMessage, InteractiveListReplyMessage, InteractiveMessage, InteractiveObject, InteractiveTypesEnum, LanguagesEnum, LimitedTimeOfferOptions, LimitedTimeOfferTemplateOptions, ListBlockedUsersParams, ListBlockedUsersResponse, LocationMessage, LocationObject, LocationParameter, Logger, LoggerInterface, MPMButton, MPMTemplateOptions, MediaApi, MediaCardCarouselTemplateOptions, MediaCarouselCard, MediaClass, MediaParameter, MediaResponse, MediasResponse, MessagesApi as MessageApi, MessagesApi, MessageHandler, MessageRequestBody, MessageRequestParams, MessageStatus, MessageTemplateObject, MessageTypesEnum, MessageWebhookValue, MessagesClass, MessagesResponse, MessagingLimitTier, MetaError, MetaErrorDetail, NextFunction, NextJsAppWebhookConfig, NextJsWebhookConfig, OTPButton, OTPTemplateOptions, OrderMessage, Pagination, PaginationCursors, Paging, PagingCursors, PagingInfo, ParametersTypesEnum, PhoneNumberApi, PhoneNumberButton, PhoneNumberClass, PhoneNumberResponse, PhoneNumbersResponse, PlatformType, ProcessedMessage, ProcessedStatus, ProductCardCarouselTemplateOptions, ProductCarouselCard, ProductParameter, ProductSection, QrCodeApi, QrCodeClass, QrCodeResponse, QrCodesResponse, QualityRating, QualityScore, QuickReplyButton, ReactionMessage, ReactionParams, ReferralSourceTypesEnum, RegistrationApi, RegistrationClass, RegistrationRequest, RequestCodeMethodsEnum, RequestVerificationCodeRequest, RequesterClass, RequesterResponseInterface, ResponseData, ResponseHeaderValue, ResponseHeaders, ResponseJSONBody, ResponsePagination, ResponseSuccess, SPMButton, SPMTemplateOptions, StatusEnum, StatusHandler, StatusParams, StatusWebhook, StatusWebhookValue, StickerMediaObject, StickerMediaTypesEnum, StickerMessage, SubTypeEnum, SystemChangeTypesEnum, SystemMessage, TemplateApi, TemplateBody, TemplateButton, TemplateButtons, TemplateCarousel, TemplateClass, TemplateDeleteParams, TemplateFooter, TemplateFormat, TemplateGetParams, TemplateHeader, TemplateHeaderExample, TemplateLimitedTimeOffer, TemplateOptions, TemplateParameter, TemplateRequestBody, TemplateResponse, TemplateStatusEnum, TextMessage, TextMessageParams, TextObject, TextParameter, Throughput, ThroughputLevel, TwoStepVerificationApi, TwoStepVerificationClass, TwoStepVerificationParams, TwoStepVerificationRequest, URLButton, UnblockUsersRequest, UnsupportedMessage, UpdateBusinessProfileRequest, UpdateFlowResponse, UpdateQrCodeRequest, UpdateWabaSubscription, UploadBusinessProfileResponse, UploadHandle, UploadMediaParams, UploadMediaResponse, UploadSession, UploadSessionResponse, ValidateFlowJsonResponse, VerifyCodeRequest, VideoMediaObject, VideoMediaTypesEnum, VideoMessage, WABAClass, WabaAccount, WabaAccountFields, WabaAccountFieldsParam, WabaAccountReviewStatus, WabaAccountStatus, WabaApi, WabaBusinessVerificationStatus, WabaConfigEnum, WabaConfigType, WabaHealthStatus, WabaHealthStatusCanSendMessage, WabaHealthStatusEntity, WabaHealthStatusError, WabaSubscription, WabaSubscriptions, WebhookContact, WebhookEvent, WebhookMessage, WebhookPayload, WebhookProcessor, WebhookResponse, WebhookTypesEnum, WebhookValue, WhatsApp, WhatsAppConfig, WhatsAppMessage, buildFieldsQueryString, constructFullUrl, createAuthenticationTemplate, createCatalogTemplate, createCouponTemplate, createLimitedTimeOfferTemplate, createMPMTemplate, createMediaCardCarouselTemplate, createOTPTemplate, createProductCardCarouselTemplate, createSPMTemplate, createTemplate, expressWebhookHandler, formatConfigTable, generateEncryption, generateXHub256Sig, isFlowDataExchangeRequest, isFlowErrorRequest, isFlowPingRequest, isMetaError, nextjsAppWebhookHandler, nextjsPagesWebhookHandler, objectToQueryString, processFlowRequest, processWebhookMessages };
4694
4339
  //# sourceMappingURL=index.d.ts.map