meta-cloud-api 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1729 -314
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -934,17 +934,29 @@ interface BlockUsersClass {
|
|
|
934
934
|
//#endregion
|
|
935
935
|
//#region src/api/blockUsers/BlockUsersApi.d.ts
|
|
936
936
|
/**
|
|
937
|
-
*
|
|
938
|
-
*
|
|
937
|
+
* API for blocking and unblocking WhatsApp users.
|
|
938
|
+
*
|
|
939
|
+
* Provides methods to block, unblock, and list blocked users for your
|
|
940
|
+
* WhatsApp Business phone number.
|
|
939
941
|
*
|
|
940
942
|
* Limitations:
|
|
941
943
|
* - Can only block users that have messaged your business in the last 24 hours
|
|
942
944
|
* - 64k blocklist limit
|
|
945
|
+
*
|
|
946
|
+
* Endpoints covered:
|
|
947
|
+
* - `POST /{PHONE_NUMBER_ID}/block_users` - Block one or more users
|
|
948
|
+
* - `DELETE /{PHONE_NUMBER_ID}/block_users` - Unblock one or more users
|
|
949
|
+
* - `GET /{PHONE_NUMBER_ID}/block_users` - List blocked users with pagination
|
|
950
|
+
*
|
|
951
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
|
|
943
952
|
*/
|
|
944
953
|
declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
945
954
|
private readonly endpoint;
|
|
946
955
|
/**
|
|
947
|
-
* Build request body for block/unblock operations
|
|
956
|
+
* Build the request body for block/unblock operations.
|
|
957
|
+
*
|
|
958
|
+
* @param users - Array of phone numbers or WhatsApp IDs.
|
|
959
|
+
* @returns The formatted request body.
|
|
948
960
|
*/
|
|
949
961
|
private buildBlockUsersBody;
|
|
950
962
|
/**
|
|
@@ -952,7 +964,7 @@ declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
|
952
964
|
* @param users - Array of phone numbers or WhatsApp IDs to block
|
|
953
965
|
* @returns Response with successfully blocked and failed users
|
|
954
966
|
* @throws Error if users have not messaged in last 24 hours
|
|
955
|
-
* @see https://developers.facebook.com/
|
|
967
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
|
|
956
968
|
*
|
|
957
969
|
* @example
|
|
958
970
|
* ```typescript
|
|
@@ -972,7 +984,7 @@ declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
|
972
984
|
* Unblock one or more WhatsApp users
|
|
973
985
|
* @param users - Array of phone numbers or WhatsApp IDs to unblock
|
|
974
986
|
* @returns Response with successfully unblocked and failed users
|
|
975
|
-
* @see https://developers.facebook.com/
|
|
987
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
|
|
976
988
|
*
|
|
977
989
|
* @example
|
|
978
990
|
* ```typescript
|
|
@@ -992,7 +1004,7 @@ declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
|
|
|
992
1004
|
* Get list of blocked WhatsApp users with pagination
|
|
993
1005
|
* @param params - Optional pagination parameters
|
|
994
1006
|
* @returns List of blocked users with pagination info
|
|
995
|
-
* @see https://developers.facebook.com/
|
|
1007
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
|
|
996
1008
|
*
|
|
997
1009
|
* @example
|
|
998
1010
|
* ```typescript
|
|
@@ -1138,21 +1150,102 @@ interface CallingClass {
|
|
|
1138
1150
|
//#region src/api/calling/CallingApi.d.ts
|
|
1139
1151
|
/**
|
|
1140
1152
|
* API for WhatsApp Calling features.
|
|
1153
|
+
*
|
|
1154
|
+
* Provides methods to manage calling settings, permissions, and call lifecycle
|
|
1155
|
+
* (initiate, pre-accept, accept, reject, terminate).
|
|
1156
|
+
*
|
|
1157
|
+
* Endpoints covered:
|
|
1158
|
+
* - `POST /{PHONE_NUMBER_ID}/settings` - Update calling settings
|
|
1159
|
+
* - `GET /{PHONE_NUMBER_ID}/settings` - Get calling settings
|
|
1160
|
+
* - `GET /{PHONE_NUMBER_ID}/call_permissions` - Get call permissions for a user
|
|
1161
|
+
* - `POST /{PHONE_NUMBER_ID}/calls` - Initiate, pre-accept, accept, reject, or terminate a call
|
|
1162
|
+
*
|
|
1163
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1141
1164
|
*/
|
|
1142
1165
|
declare class CallingApi extends BaseAPI implements CallingClass {
|
|
1143
1166
|
private readonly endpoint;
|
|
1167
|
+
/**
|
|
1168
|
+
* Update calling settings for the phone number, such as enabling/disabling calling
|
|
1169
|
+
* or configuring SIP credentials.
|
|
1170
|
+
*
|
|
1171
|
+
* @param params - The calling settings to update.
|
|
1172
|
+
* @returns A success response confirming the settings were updated.
|
|
1173
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1174
|
+
*/
|
|
1144
1175
|
updateCallingSettings(params: UpdateCallingSettingsRequest): Promise<ResponseSuccess>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Retrieve the current calling settings for the phone number.
|
|
1178
|
+
*
|
|
1179
|
+
* @param params - Optional query parameters to filter the response.
|
|
1180
|
+
* @param params.fields - Specific fields to include in the response.
|
|
1181
|
+
* @param params.include_sip_credentials - Whether to include SIP credentials in the response.
|
|
1182
|
+
* @returns The current calling settings configuration.
|
|
1183
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1184
|
+
*/
|
|
1145
1185
|
getCallingSettings(params?: {
|
|
1146
1186
|
fields?: string[] | string;
|
|
1147
1187
|
include_sip_credentials?: boolean;
|
|
1148
1188
|
}): Promise<CallingSettingsResponse>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Get calling permissions for a specific WhatsApp user.
|
|
1191
|
+
*
|
|
1192
|
+
* @param params - The request parameters.
|
|
1193
|
+
* @param params.userWaId - The WhatsApp ID of the user to check permissions for.
|
|
1194
|
+
* @returns The call permissions for the specified user.
|
|
1195
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1196
|
+
*/
|
|
1149
1197
|
getCallPermissions(params: {
|
|
1150
1198
|
userWaId: string;
|
|
1151
1199
|
}): Promise<CallPermissionsResponse>;
|
|
1200
|
+
/**
|
|
1201
|
+
* Initiate an outbound call to a WhatsApp user.
|
|
1202
|
+
*
|
|
1203
|
+
* @param params - The call initiation parameters.
|
|
1204
|
+
* @param params.to - The recipient's WhatsApp phone number.
|
|
1205
|
+
* @param params.session - The call session configuration.
|
|
1206
|
+
* @param params.biz_opaque_callback_data - Optional opaque data passed back in webhooks.
|
|
1207
|
+
* @returns The initiated call response with call ID and status.
|
|
1208
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1209
|
+
*/
|
|
1152
1210
|
initiateCall(params: InitiateCallRequest): Promise<InitiateCallResponse>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Pre-accept an incoming call, signaling readiness to connect before full acceptance.
|
|
1213
|
+
*
|
|
1214
|
+
* @param params - The pre-accept request parameters.
|
|
1215
|
+
* @param params.call_id - The ID of the call to pre-accept.
|
|
1216
|
+
* @param params.session - Optional session configuration for the call.
|
|
1217
|
+
* @returns The call action response confirming the pre-accept.
|
|
1218
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1219
|
+
*/
|
|
1153
1220
|
preAcceptCall(params: PreAcceptCallRequest): Promise<CallActionResponse>;
|
|
1221
|
+
/**
|
|
1222
|
+
* Accept an incoming call and establish the connection.
|
|
1223
|
+
*
|
|
1224
|
+
* @param params - The accept request parameters.
|
|
1225
|
+
* @param params.call_id - The ID of the call to accept.
|
|
1226
|
+
* @param params.session - Optional session configuration for the call.
|
|
1227
|
+
* @param params.biz_opaque_callback_data - Optional opaque data passed back in webhooks.
|
|
1228
|
+
* @returns The call action response confirming acceptance.
|
|
1229
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1230
|
+
*/
|
|
1154
1231
|
acceptCall(params: AcceptCallRequest): Promise<CallActionResponse>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Reject an incoming call.
|
|
1234
|
+
*
|
|
1235
|
+
* @param params - The reject request parameters.
|
|
1236
|
+
* @param params.call_id - The ID of the call to reject.
|
|
1237
|
+
* @returns The call action response confirming rejection.
|
|
1238
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1239
|
+
*/
|
|
1155
1240
|
rejectCall(params: RejectCallRequest): Promise<CallActionResponse>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Terminate an active call.
|
|
1243
|
+
*
|
|
1244
|
+
* @param params - The terminate request parameters.
|
|
1245
|
+
* @param params.call_id - The ID of the call to terminate.
|
|
1246
|
+
* @returns The call action response confirming termination.
|
|
1247
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
|
|
1248
|
+
*/
|
|
1156
1249
|
terminateCall(params: TerminateCallRequest): Promise<CallActionResponse>;
|
|
1157
1250
|
}
|
|
1158
1251
|
//#endregion
|
|
@@ -1181,10 +1274,32 @@ interface CommerceClass {
|
|
|
1181
1274
|
//#region src/api/commerce/CommerceApi.d.ts
|
|
1182
1275
|
/**
|
|
1183
1276
|
* API for WhatsApp Commerce Settings.
|
|
1277
|
+
*
|
|
1278
|
+
* Provides methods to retrieve and update commerce settings such as cart
|
|
1279
|
+
* and catalog visibility for your WhatsApp Business phone number.
|
|
1280
|
+
*
|
|
1281
|
+
* Endpoints covered:
|
|
1282
|
+
* - `GET /{PHONE_NUMBER_ID}/whatsapp_commerce_settings` - Get commerce settings
|
|
1283
|
+
* - `POST /{PHONE_NUMBER_ID}/whatsapp_commerce_settings` - Update commerce settings
|
|
1284
|
+
*
|
|
1285
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
|
|
1184
1286
|
*/
|
|
1185
1287
|
declare class CommerceApi extends BaseAPI implements CommerceClass {
|
|
1186
1288
|
private readonly endpoint;
|
|
1289
|
+
/**
|
|
1290
|
+
* Retrieve the current commerce settings for the phone number.
|
|
1291
|
+
*
|
|
1292
|
+
* @returns The current commerce settings including cart and catalog visibility state.
|
|
1293
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
|
|
1294
|
+
*/
|
|
1187
1295
|
getCommerceSettings(): Promise<CommerceSettingsResponse>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Update commerce settings for the phone number (e.g., enable/disable cart or catalog).
|
|
1298
|
+
*
|
|
1299
|
+
* @param params - The commerce settings to update (e.g., is_cart_enabled, is_catalog_visible).
|
|
1300
|
+
* @returns A success response confirming the settings were updated.
|
|
1301
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
|
|
1302
|
+
*/
|
|
1188
1303
|
updateCommerceSettings(params: UpdateCommerceSettingsRequest): Promise<ResponseSuccess>;
|
|
1189
1304
|
}
|
|
1190
1305
|
//#endregion
|
|
@@ -1201,9 +1316,34 @@ interface EncryptionClass {
|
|
|
1201
1316
|
}
|
|
1202
1317
|
//#endregion
|
|
1203
1318
|
//#region src/api/encryption/EncryptionApi.d.ts
|
|
1319
|
+
/**
|
|
1320
|
+
* API for managing WhatsApp Business Encryption keys.
|
|
1321
|
+
*
|
|
1322
|
+
* Provides methods to get and set the public encryption key used for
|
|
1323
|
+
* end-to-end encrypted messaging with WhatsApp Business.
|
|
1324
|
+
*
|
|
1325
|
+
* Endpoints covered:
|
|
1326
|
+
* - `GET /{PHONE_NUMBER_ID}/whatsapp_business_encryption` - Get the current public encryption key
|
|
1327
|
+
* - `POST /{PHONE_NUMBER_ID}/whatsapp_business_encryption` - Set a new public encryption key
|
|
1328
|
+
*
|
|
1329
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
|
|
1330
|
+
*/
|
|
1204
1331
|
declare class EncryptionApi extends BaseAPI implements EncryptionClass {
|
|
1205
1332
|
private readonly endpoint;
|
|
1333
|
+
/**
|
|
1334
|
+
* Retrieve the current public encryption key for the phone number.
|
|
1335
|
+
*
|
|
1336
|
+
* @returns The current public encryption key.
|
|
1337
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
|
|
1338
|
+
*/
|
|
1206
1339
|
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
|
|
1340
|
+
/**
|
|
1341
|
+
* Set a new public encryption key for the phone number.
|
|
1342
|
+
*
|
|
1343
|
+
* @param businessPublicKey - The PEM-encoded public key string to set.
|
|
1344
|
+
* @returns A success response confirming the key was set.
|
|
1345
|
+
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
|
|
1346
|
+
*/
|
|
1207
1347
|
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
|
|
1208
1348
|
}
|
|
1209
1349
|
//#endregion
|
|
@@ -2710,11 +2850,21 @@ interface WabaAccount {
|
|
|
2710
2850
|
timezone_id?: string;
|
|
2711
2851
|
primary_business_location?: Record<string, unknown> | string;
|
|
2712
2852
|
currency?: string;
|
|
2853
|
+
country?: string;
|
|
2854
|
+
analytics?: Record<string, unknown>;
|
|
2855
|
+
is_enabled_for_insights?: boolean;
|
|
2856
|
+
is_shared_with_partners?: boolean;
|
|
2857
|
+
marketing_messages_lite_api_status?: string;
|
|
2858
|
+
marketing_messages_onboarding_status?: string;
|
|
2859
|
+
on_behalf_of_business_info?: Record<string, unknown>;
|
|
2860
|
+
primary_funding_id?: string;
|
|
2861
|
+
purchase_order_number?: string;
|
|
2862
|
+
whatsapp_business_manager_messaging_limit?: string;
|
|
2713
2863
|
}
|
|
2714
2864
|
/**
|
|
2715
2865
|
* Available fields for WABA account queries
|
|
2716
2866
|
*/
|
|
2717
|
-
type WabaAccountFields = 'id' | 'name' | 'timezone_id' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace' | 'primary_business_location';
|
|
2867
|
+
type WabaAccountFields = 'id' | 'name' | 'timezone_id' | 'account_review_status' | 'auth_international_rate_eligibility' | 'business_verification_status' | 'country' | 'currency' | 'health_status' | 'status' | 'ownership_type' | 'message_template_namespace' | 'primary_business_location' | 'analytics' | 'is_enabled_for_insights' | 'is_shared_with_partners' | 'marketing_messages_lite_api_status' | 'marketing_messages_onboarding_status' | 'on_behalf_of_business_info' | 'primary_funding_id' | 'purchase_order_number' | 'whatsapp_business_manager_messaging_limit';
|
|
2718
2868
|
/**
|
|
2719
2869
|
* Parameter type for specifying which WABA account fields to retrieve
|
|
2720
2870
|
*/
|
|
@@ -4099,30 +4249,73 @@ interface FlowClass {
|
|
|
4099
4249
|
/**
|
|
4100
4250
|
* API for managing WhatsApp Flows.
|
|
4101
4251
|
*
|
|
4252
|
+
* WhatsApp Flows allow businesses to build structured, interactive experiences
|
|
4253
|
+
* within WhatsApp conversations. Flows can be used for appointment booking,
|
|
4254
|
+
* lead generation, customer support, surveys, and more.
|
|
4255
|
+
*
|
|
4102
4256
|
* This API allows you to:
|
|
4103
|
-
* - List flows
|
|
4104
|
-
* - Create flows
|
|
4105
|
-
* - Get flow details and previews
|
|
4106
|
-
* - Update flow metadata
|
|
4107
|
-
* - Delete flows
|
|
4108
|
-
* -
|
|
4109
|
-
* -
|
|
4110
|
-
* -
|
|
4257
|
+
* - List flows for a WhatsApp Business Account (`GET /{WABA_ID}/flows`)
|
|
4258
|
+
* - Create new flows (`POST /{WABA_ID}/flows`)
|
|
4259
|
+
* - Get flow details and previews (`GET /{FLOW_ID}`)
|
|
4260
|
+
* - Update flow metadata (`POST /{FLOW_ID}`)
|
|
4261
|
+
* - Delete draft flows (`DELETE /{FLOW_ID}`)
|
|
4262
|
+
* - List flow assets / download Flow JSON (`GET /{FLOW_ID}/assets`)
|
|
4263
|
+
* - Upload or update Flow JSON (`POST /{FLOW_ID}/assets`)
|
|
4264
|
+
* - Publish flows (`POST /{FLOW_ID}/publish`)
|
|
4265
|
+
* - Deprecate flows (`POST /{FLOW_ID}/deprecate`)
|
|
4266
|
+
* - Migrate flows between WABAs (`POST /{DESTINATION_WABA_ID}/migrate_flows`)
|
|
4267
|
+
*
|
|
4268
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi | Flows API Reference}
|
|
4269
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/flows/ | WhatsApp Flows Documentation}
|
|
4111
4270
|
*/
|
|
4112
4271
|
declare class FlowApi extends BaseAPI implements FlowClass {
|
|
4113
4272
|
/**
|
|
4114
|
-
* List
|
|
4273
|
+
* List all flows belonging to a WhatsApp Business Account.
|
|
4115
4274
|
*
|
|
4116
|
-
*
|
|
4117
|
-
*
|
|
4275
|
+
* Retrieves a paginated list of all flows associated with the given WABA ID,
|
|
4276
|
+
* including their IDs, names, statuses, and categories.
|
|
4277
|
+
*
|
|
4278
|
+
* @param wabaId - The WhatsApp Business Account ID to list flows for.
|
|
4279
|
+
* @returns A promise that resolves with the list of flows and pagination info.
|
|
4280
|
+
*
|
|
4281
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#list | List Flows}
|
|
4282
|
+
*
|
|
4283
|
+
* @example
|
|
4284
|
+
* ```ts
|
|
4285
|
+
* const response = await whatsappClient.flow.listFlows('WABA_ID');
|
|
4286
|
+
* for (const flow of response.data) {
|
|
4287
|
+
* console.log(flow.id, flow.name, flow.status);
|
|
4288
|
+
* }
|
|
4289
|
+
* ```
|
|
4118
4290
|
*/
|
|
4119
4291
|
listFlows(wabaId: string): Promise<FlowsListResponse>;
|
|
4120
4292
|
/**
|
|
4121
|
-
* Create
|
|
4293
|
+
* Create a new flow for a WhatsApp Business Account.
|
|
4122
4294
|
*
|
|
4123
|
-
*
|
|
4124
|
-
*
|
|
4125
|
-
*
|
|
4295
|
+
* Creates a new flow in DRAFT status. You can optionally clone an existing flow,
|
|
4296
|
+
* provide initial Flow JSON, and even publish the flow immediately upon creation.
|
|
4297
|
+
*
|
|
4298
|
+
* @param wabaId - The WhatsApp Business Account ID to create the flow under.
|
|
4299
|
+
* @param data - The flow creation parameters.
|
|
4300
|
+
* @param data.name - The name of the flow.
|
|
4301
|
+
* @param data.categories - Optional array of flow categories (e.g., LEAD_GENERATION, APPOINTMENT_BOOKING).
|
|
4302
|
+
* @param data.endpoint_uri - Optional URI for the flow endpoint that will receive flow action payloads.
|
|
4303
|
+
* @param data.clone_flow_id - Optional ID of an existing flow to clone.
|
|
4304
|
+
* @param data.flow_json - Optional Flow JSON definition as a string.
|
|
4305
|
+
* @param data.publish - Optional flag to publish the flow immediately after creation.
|
|
4306
|
+
* @returns A promise that resolves with the created flow ID and any validation errors.
|
|
4307
|
+
*
|
|
4308
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#create | Create Flow}
|
|
4309
|
+
*
|
|
4310
|
+
* @example
|
|
4311
|
+
* ```ts
|
|
4312
|
+
* const result = await whatsappClient.flow.createFlow('WABA_ID', {
|
|
4313
|
+
* name: 'Appointment Booking',
|
|
4314
|
+
* categories: ['APPOINTMENT_BOOKING'],
|
|
4315
|
+
* endpoint_uri: 'https://example.com/flow-endpoint',
|
|
4316
|
+
* });
|
|
4317
|
+
* console.log(result.id); // New flow ID
|
|
4318
|
+
* ```
|
|
4126
4319
|
*/
|
|
4127
4320
|
createFlow(wabaId: string, data: {
|
|
4128
4321
|
name: string;
|
|
@@ -4133,28 +4326,76 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
4133
4326
|
publish?: boolean;
|
|
4134
4327
|
}): Promise<CreateFlowResponse>;
|
|
4135
4328
|
/**
|
|
4136
|
-
* Get
|
|
4329
|
+
* Get details of a specific flow.
|
|
4137
4330
|
*
|
|
4138
|
-
*
|
|
4139
|
-
*
|
|
4140
|
-
*
|
|
4141
|
-
*
|
|
4331
|
+
* Retrieves flow information such as name, status, categories, JSON validation errors,
|
|
4332
|
+
* and optionally a preview URL. Use the `fields` parameter to request specific fields
|
|
4333
|
+
* or the preview endpoint.
|
|
4334
|
+
*
|
|
4335
|
+
* @param flowId - The ID of the flow to retrieve.
|
|
4336
|
+
* @param fields - Optional comma-separated list of fields to return (e.g., `'name,status,preview.invalidate(false)'`).
|
|
4337
|
+
* @param dateFormat - Optional date format string for date fields in the response.
|
|
4338
|
+
* @returns A promise that resolves with the flow details or preview response.
|
|
4339
|
+
*
|
|
4340
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#details | Get Flow Details}
|
|
4341
|
+
*
|
|
4342
|
+
* @example
|
|
4343
|
+
* ```ts
|
|
4344
|
+
* // Get all flow details
|
|
4345
|
+
* const flow = await whatsappClient.flow.getFlow('FLOW_ID');
|
|
4346
|
+
* console.log(flow.name, flow.status);
|
|
4347
|
+
*
|
|
4348
|
+
* // Get specific fields only
|
|
4349
|
+
* const flow = await whatsappClient.flow.getFlow('FLOW_ID', 'name,status,categories');
|
|
4350
|
+
* ```
|
|
4142
4351
|
*/
|
|
4143
4352
|
getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
|
|
4144
4353
|
/**
|
|
4145
|
-
* Get
|
|
4354
|
+
* Get a preview URL for a flow.
|
|
4146
4355
|
*
|
|
4147
|
-
*
|
|
4148
|
-
*
|
|
4149
|
-
*
|
|
4356
|
+
* Generates a shareable preview URL that allows viewing the flow without publishing it.
|
|
4357
|
+
* The preview can optionally be invalidated to force generation of a fresh URL.
|
|
4358
|
+
*
|
|
4359
|
+
* @param flowId - The ID of the flow to preview.
|
|
4360
|
+
* @param invalidate - If `true`, invalidates the existing preview and generates a new one. Defaults to `false`.
|
|
4361
|
+
* @returns A promise that resolves with the flow preview details including the preview URL.
|
|
4362
|
+
*
|
|
4363
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#details | Get Flow Preview}
|
|
4364
|
+
*
|
|
4365
|
+
* @example
|
|
4366
|
+
* ```ts
|
|
4367
|
+
* // Get existing preview URL
|
|
4368
|
+
* const preview = await whatsappClient.flow.getFlowPreview('FLOW_ID');
|
|
4369
|
+
* console.log(preview.preview.preview_url);
|
|
4370
|
+
*
|
|
4371
|
+
* // Force a new preview URL
|
|
4372
|
+
* const freshPreview = await whatsappClient.flow.getFlowPreview('FLOW_ID', true);
|
|
4373
|
+
* ```
|
|
4150
4374
|
*/
|
|
4151
4375
|
getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
|
|
4152
4376
|
/**
|
|
4153
|
-
* Update
|
|
4377
|
+
* Update the metadata of an existing flow.
|
|
4154
4378
|
*
|
|
4155
|
-
*
|
|
4156
|
-
*
|
|
4157
|
-
*
|
|
4379
|
+
* Allows updating a flow's name, categories, endpoint URI, or associated application ID.
|
|
4380
|
+
* The flow must be in DRAFT status to update certain fields.
|
|
4381
|
+
*
|
|
4382
|
+
* @param flowId - The ID of the flow to update.
|
|
4383
|
+
* @param data - The metadata fields to update.
|
|
4384
|
+
* @param data.name - Optional new name for the flow.
|
|
4385
|
+
* @param data.categories - Optional new categories for the flow.
|
|
4386
|
+
* @param data.endpoint_uri - Optional new endpoint URI for flow action payloads.
|
|
4387
|
+
* @param data.application_id - Optional application ID to associate with the flow.
|
|
4388
|
+
* @returns A promise that resolves with a success indicator.
|
|
4389
|
+
*
|
|
4390
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#update | Update Flow}
|
|
4391
|
+
*
|
|
4392
|
+
* @example
|
|
4393
|
+
* ```ts
|
|
4394
|
+
* await whatsappClient.flow.updateFlowMetadata('FLOW_ID', {
|
|
4395
|
+
* name: 'Updated Flow Name',
|
|
4396
|
+
* endpoint_uri: 'https://example.com/new-endpoint',
|
|
4397
|
+
* });
|
|
4398
|
+
* ```
|
|
4158
4399
|
*/
|
|
4159
4400
|
updateFlowMetadata(flowId: string, data: {
|
|
4160
4401
|
name?: string;
|
|
@@ -4163,61 +4404,168 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
4163
4404
|
application_id?: string;
|
|
4164
4405
|
}): Promise<ResponseSuccess>;
|
|
4165
4406
|
/**
|
|
4166
|
-
* Delete
|
|
4407
|
+
* Delete a flow.
|
|
4167
4408
|
*
|
|
4168
|
-
*
|
|
4169
|
-
*
|
|
4409
|
+
* Permanently deletes a flow. Only flows in DRAFT status can be deleted.
|
|
4410
|
+
* Published or deprecated flows cannot be deleted.
|
|
4411
|
+
*
|
|
4412
|
+
* @param flowId - The ID of the flow to delete.
|
|
4413
|
+
* @returns A promise that resolves with a success indicator.
|
|
4414
|
+
*
|
|
4415
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#delete | Delete Flow}
|
|
4416
|
+
*
|
|
4417
|
+
* @example
|
|
4418
|
+
* ```ts
|
|
4419
|
+
* await whatsappClient.flow.deleteFlow('FLOW_ID');
|
|
4420
|
+
* ```
|
|
4170
4421
|
*/
|
|
4171
4422
|
deleteFlow(flowId: string): Promise<ResponseSuccess>;
|
|
4172
4423
|
/**
|
|
4173
|
-
* List
|
|
4424
|
+
* List assets associated with a flow.
|
|
4174
4425
|
*
|
|
4175
|
-
*
|
|
4176
|
-
*
|
|
4426
|
+
* Retrieves the list of assets (e.g., Flow JSON) associated with the flow.
|
|
4427
|
+
* The response includes download URLs for each asset.
|
|
4428
|
+
*
|
|
4429
|
+
* @param flowId - The ID of the flow to list assets for.
|
|
4430
|
+
* @returns A promise that resolves with the list of assets including download URLs.
|
|
4431
|
+
*
|
|
4432
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#asset-list | List Flow Assets}
|
|
4433
|
+
*
|
|
4434
|
+
* @example
|
|
4435
|
+
* ```ts
|
|
4436
|
+
* const assets = await whatsappClient.flow.listAssets('FLOW_ID');
|
|
4437
|
+
* for (const asset of assets.data) {
|
|
4438
|
+
* console.log(asset.name, asset.download_url);
|
|
4439
|
+
* }
|
|
4440
|
+
* ```
|
|
4177
4441
|
*/
|
|
4178
4442
|
listAssets(flowId: string): Promise<FlowAssetsResponse>;
|
|
4179
4443
|
/**
|
|
4180
|
-
*
|
|
4444
|
+
* Upload or update the Flow JSON for a flow.
|
|
4181
4445
|
*
|
|
4182
|
-
*
|
|
4446
|
+
* Uploads a Flow JSON definition to the flow's assets. The JSON defines the screens,
|
|
4447
|
+
* layout, and logic of the flow. Accepts a Buffer, plain JSON object, or Blob.
|
|
4448
|
+
*
|
|
4449
|
+
* @param flowId - The ID of the flow to update.
|
|
4183
4450
|
* @param data - Object containing the file data and optional name.
|
|
4184
4451
|
* @param data.file - The Flow JSON content as a Buffer, JSON object, or Blob.
|
|
4185
|
-
* @param data.name - Optional name for the asset
|
|
4186
|
-
* @returns
|
|
4452
|
+
* @param data.name - Optional name for the asset. Defaults to `'flow.json'`.
|
|
4453
|
+
* @returns A promise that resolves with the upload status and any validation errors.
|
|
4454
|
+
*
|
|
4455
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#asset-upload | Upload Flow JSON}
|
|
4456
|
+
*
|
|
4457
|
+
* @example
|
|
4458
|
+
* ```ts
|
|
4459
|
+
* // Upload from a JSON object
|
|
4460
|
+
* const result = await whatsappClient.flow.updateFlowJson('FLOW_ID', {
|
|
4461
|
+
* file: {
|
|
4462
|
+
* version: '5.0',
|
|
4463
|
+
* screens: [{ id: 'WELCOME', layout: { type: 'SingleColumnLayout', children: [] } }],
|
|
4464
|
+
* },
|
|
4465
|
+
* });
|
|
4466
|
+
*
|
|
4467
|
+
* // Upload from a Buffer
|
|
4468
|
+
* const jsonBuffer = Buffer.from(JSON.stringify(flowDefinition));
|
|
4469
|
+
* await whatsappClient.flow.updateFlowJson('FLOW_ID', { file: jsonBuffer });
|
|
4470
|
+
* ```
|
|
4187
4471
|
*/
|
|
4188
4472
|
updateFlowJson(flowId: string, data: {
|
|
4189
4473
|
file: Blob | Buffer | object;
|
|
4190
4474
|
name?: string;
|
|
4191
4475
|
}): Promise<UpdateFlowResponse>;
|
|
4192
4476
|
/**
|
|
4193
|
-
* Validate Flow JSON
|
|
4194
|
-
* This is a convenience method; the API doesn't have a dedicated validation endpoint.
|
|
4477
|
+
* Validate Flow JSON without publishing.
|
|
4195
4478
|
*
|
|
4196
|
-
*
|
|
4197
|
-
*
|
|
4198
|
-
*
|
|
4479
|
+
* This is a convenience method that uploads the Flow JSON and checks for validation
|
|
4480
|
+
* errors. The API does not have a dedicated validation endpoint, so this method
|
|
4481
|
+
* performs an update and inspects the response for errors.
|
|
4482
|
+
*
|
|
4483
|
+
* @param flowId - The ID of the flow to validate against (must exist, can be in DRAFT status).
|
|
4484
|
+
* @param flowJsonData - The Flow JSON content as a Buffer, JSON object, or Blob.
|
|
4485
|
+
* @returns A promise that resolves with validation results, including a `valid` boolean
|
|
4486
|
+
* and any `validation_errors` found.
|
|
4487
|
+
*
|
|
4488
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#asset-upload | Upload Flow JSON (validation)}
|
|
4489
|
+
*
|
|
4490
|
+
* @example
|
|
4491
|
+
* ```ts
|
|
4492
|
+
* const result = await whatsappClient.flow.validateFlowJson('FLOW_ID', {
|
|
4493
|
+
* version: '5.0',
|
|
4494
|
+
* screens: [{ id: 'WELCOME', layout: { type: 'SingleColumnLayout', children: [] } }],
|
|
4495
|
+
* });
|
|
4496
|
+
* if (result.valid) {
|
|
4497
|
+
* console.log('Flow JSON is valid');
|
|
4498
|
+
* } else {
|
|
4499
|
+
* console.error('Validation errors:', result.validation_errors);
|
|
4500
|
+
* }
|
|
4501
|
+
* ```
|
|
4199
4502
|
*/
|
|
4200
4503
|
validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
|
|
4201
4504
|
/**
|
|
4202
|
-
* Publish
|
|
4505
|
+
* Publish a flow.
|
|
4203
4506
|
*
|
|
4204
|
-
*
|
|
4205
|
-
*
|
|
4507
|
+
* Transitions a flow from DRAFT status to PUBLISHED. Once published, the flow
|
|
4508
|
+
* can be sent to users in WhatsApp messages. A published flow's JSON can no longer
|
|
4509
|
+
* be updated.
|
|
4510
|
+
*
|
|
4511
|
+
* @param flowId - The ID of the flow to publish.
|
|
4512
|
+
* @returns A promise that resolves with a success indicator.
|
|
4513
|
+
*
|
|
4514
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#publish | Publish Flow}
|
|
4515
|
+
*
|
|
4516
|
+
* @example
|
|
4517
|
+
* ```ts
|
|
4518
|
+
* await whatsappClient.flow.publishFlow('FLOW_ID');
|
|
4519
|
+
* ```
|
|
4206
4520
|
*/
|
|
4207
4521
|
publishFlow(flowId: string): Promise<ResponseSuccess>;
|
|
4208
4522
|
/**
|
|
4209
|
-
* Deprecate
|
|
4523
|
+
* Deprecate a flow.
|
|
4210
4524
|
*
|
|
4211
|
-
*
|
|
4212
|
-
*
|
|
4525
|
+
* Transitions a flow from PUBLISHED status to DEPRECATED. A deprecated flow
|
|
4526
|
+
* can no longer be sent to users but existing sessions will continue to work.
|
|
4527
|
+
* This action cannot be undone.
|
|
4528
|
+
*
|
|
4529
|
+
* @param flowId - The ID of the flow to deprecate.
|
|
4530
|
+
* @returns A promise that resolves with a success indicator.
|
|
4531
|
+
*
|
|
4532
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#deprecate | Deprecate Flow}
|
|
4533
|
+
*
|
|
4534
|
+
* @example
|
|
4535
|
+
* ```ts
|
|
4536
|
+
* await whatsappClient.flow.deprecateFlow('FLOW_ID');
|
|
4537
|
+
* ```
|
|
4213
4538
|
*/
|
|
4214
4539
|
deprecateFlow(flowId: string): Promise<ResponseSuccess>;
|
|
4215
4540
|
/**
|
|
4216
|
-
* Migrate
|
|
4541
|
+
* Migrate flows between WhatsApp Business Accounts.
|
|
4217
4542
|
*
|
|
4218
|
-
*
|
|
4219
|
-
*
|
|
4220
|
-
*
|
|
4543
|
+
* Copies flows from a source WABA to a destination WABA. You can optionally
|
|
4544
|
+
* specify which flows to migrate by name. Migrated flows are created in DRAFT
|
|
4545
|
+
* status in the destination WABA.
|
|
4546
|
+
*
|
|
4547
|
+
* @param destinationWabaId - The ID of the destination WhatsApp Business Account.
|
|
4548
|
+
* @param data - The migration parameters.
|
|
4549
|
+
* @param data.source_waba_id - The ID of the source WhatsApp Business Account to migrate flows from.
|
|
4550
|
+
* @param data.source_flow_names - Optional array of flow names to migrate. If omitted, all flows are migrated.
|
|
4551
|
+
* @returns A promise that resolves with migration results including successes and failures.
|
|
4552
|
+
*
|
|
4553
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows/reference/flowsapi#migrate | Migrate Flows}
|
|
4554
|
+
*
|
|
4555
|
+
* @example
|
|
4556
|
+
* ```ts
|
|
4557
|
+
* // Migrate all flows from one WABA to another
|
|
4558
|
+
* const result = await whatsappClient.flow.migrateFlows('DEST_WABA_ID', {
|
|
4559
|
+
* source_waba_id: 'SOURCE_WABA_ID',
|
|
4560
|
+
* });
|
|
4561
|
+
*
|
|
4562
|
+
* // Migrate specific flows by name
|
|
4563
|
+
* const result = await whatsappClient.flow.migrateFlows('DEST_WABA_ID', {
|
|
4564
|
+
* source_waba_id: 'SOURCE_WABA_ID',
|
|
4565
|
+
* source_flow_names: ['Appointment Booking', 'Lead Gen Form'],
|
|
4566
|
+
* });
|
|
4567
|
+
* console.log(result.migrated_flows, result.failed_flows);
|
|
4568
|
+
* ```
|
|
4221
4569
|
*/
|
|
4222
4570
|
migrateFlows(destinationWabaId: string, data: {
|
|
4223
4571
|
source_waba_id: string;
|
|
@@ -4236,256 +4584,963 @@ declare class FlowApi extends BaseAPI implements FlowClass {
|
|
|
4236
4584
|
* - Remove participants
|
|
4237
4585
|
* - Update group settings
|
|
4238
4586
|
* - Fetch group metadata and active groups
|
|
4587
|
+
*
|
|
4588
|
+
* Endpoints covered:
|
|
4589
|
+
* - `POST /{PHONE_NUMBER_ID}/groups` - Create a new group
|
|
4590
|
+
* - `DELETE /{GROUP_ID}` - Delete a group
|
|
4591
|
+
* - `GET /{GROUP_ID}` - Get group info
|
|
4592
|
+
* - `GET /{PHONE_NUMBER_ID}/groups` - List active groups
|
|
4593
|
+
* - `GET /{GROUP_ID}/invite_link` - Get group invite link
|
|
4594
|
+
* - `POST /{GROUP_ID}/invite_link` - Reset group invite link
|
|
4595
|
+
* - `GET /{GROUP_ID}/join_requests` - Get pending join requests
|
|
4596
|
+
* - `POST /{GROUP_ID}/join_requests` - Approve join requests
|
|
4597
|
+
* - `DELETE /{GROUP_ID}/join_requests` - Reject join requests
|
|
4598
|
+
* - `DELETE /{GROUP_ID}/participants` - Remove participants
|
|
4599
|
+
* - `POST /{GROUP_ID}` - Update group settings
|
|
4600
|
+
*
|
|
4601
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4239
4602
|
*/
|
|
4240
4603
|
declare class GroupsApi extends BaseAPI implements GroupsClass {
|
|
4604
|
+
/**
|
|
4605
|
+
* Create a new WhatsApp group.
|
|
4606
|
+
*
|
|
4607
|
+
* @param params - The group creation parameters.
|
|
4608
|
+
* @param params.subject - The name/subject of the group.
|
|
4609
|
+
* @param params.description - Optional description for the group.
|
|
4610
|
+
* @param params.join_approval_mode - Optional join approval mode setting.
|
|
4611
|
+
* @returns The created group response with group ID.
|
|
4612
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4613
|
+
*/
|
|
4241
4614
|
createGroup(params: GroupCreateRequest): Promise<GroupCreateResponse>;
|
|
4615
|
+
/**
|
|
4616
|
+
* Delete a WhatsApp group.
|
|
4617
|
+
*
|
|
4618
|
+
* @param groupId - The ID of the group to delete.
|
|
4619
|
+
* @returns A success response confirming deletion.
|
|
4620
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4621
|
+
*/
|
|
4242
4622
|
deleteGroup(groupId: string): Promise<ResponseSuccess>;
|
|
4623
|
+
/**
|
|
4624
|
+
* Retrieve metadata and information about a specific group.
|
|
4625
|
+
*
|
|
4626
|
+
* @param groupId - The ID of the group to retrieve.
|
|
4627
|
+
* @param fields - Optional fields to include in the response (e.g., subject, description, participants).
|
|
4628
|
+
* @returns The group information including metadata and requested fields.
|
|
4629
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4630
|
+
*/
|
|
4243
4631
|
getGroupInfo(groupId: string, fields?: GroupInfoFieldsParam): Promise<GroupInfoResponse>;
|
|
4632
|
+
/**
|
|
4633
|
+
* List all active groups for the phone number with optional pagination.
|
|
4634
|
+
*
|
|
4635
|
+
* @param params - Optional pagination parameters.
|
|
4636
|
+
* @param params.limit - Maximum number of groups to return.
|
|
4637
|
+
* @param params.after - Cursor for forward pagination.
|
|
4638
|
+
* @param params.before - Cursor for backward pagination.
|
|
4639
|
+
* @returns A paginated list of active groups.
|
|
4640
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4641
|
+
*/
|
|
4244
4642
|
getActiveGroups(params?: GroupListParams): Promise<GroupListResponse>;
|
|
4643
|
+
/**
|
|
4644
|
+
* Get the current invite link for a group.
|
|
4645
|
+
*
|
|
4646
|
+
* @param groupId - The ID of the group.
|
|
4647
|
+
* @returns The group invite link.
|
|
4648
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4649
|
+
*/
|
|
4245
4650
|
getGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
|
|
4651
|
+
/**
|
|
4652
|
+
* Reset and regenerate the invite link for a group, invalidating the previous link.
|
|
4653
|
+
*
|
|
4654
|
+
* @param groupId - The ID of the group.
|
|
4655
|
+
* @returns The new group invite link.
|
|
4656
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4657
|
+
*/
|
|
4246
4658
|
resetGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
|
|
4659
|
+
/**
|
|
4660
|
+
* Get pending join requests for a group.
|
|
4661
|
+
*
|
|
4662
|
+
* @param groupId - The ID of the group.
|
|
4663
|
+
* @returns A list of pending join requests.
|
|
4664
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4665
|
+
*/
|
|
4247
4666
|
getJoinRequests(groupId: string): Promise<GroupJoinRequestsResponse>;
|
|
4667
|
+
/**
|
|
4668
|
+
* Approve one or more pending join requests for a group.
|
|
4669
|
+
*
|
|
4670
|
+
* @param groupId - The ID of the group.
|
|
4671
|
+
* @param joinRequestIds - Array of join request IDs to approve.
|
|
4672
|
+
* @returns The result of the approval action.
|
|
4673
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4674
|
+
*/
|
|
4248
4675
|
approveJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
|
|
4676
|
+
/**
|
|
4677
|
+
* Reject one or more pending join requests for a group.
|
|
4678
|
+
*
|
|
4679
|
+
* @param groupId - The ID of the group.
|
|
4680
|
+
* @param joinRequestIds - Array of join request IDs to reject.
|
|
4681
|
+
* @returns The result of the rejection action.
|
|
4682
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4683
|
+
*/
|
|
4249
4684
|
rejectJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
|
|
4685
|
+
/**
|
|
4686
|
+
* Remove one or more participants from a group.
|
|
4687
|
+
*
|
|
4688
|
+
* @param groupId - The ID of the group.
|
|
4689
|
+
* @param participants - Array of user WhatsApp IDs to remove from the group.
|
|
4690
|
+
* @returns A success response confirming removal.
|
|
4691
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4692
|
+
*/
|
|
4250
4693
|
removeParticipants(groupId: string, participants: string[]): Promise<ResponseSuccess>;
|
|
4694
|
+
/**
|
|
4695
|
+
* Update group settings such as subject, description, or profile picture.
|
|
4696
|
+
*
|
|
4697
|
+
* @param groupId - The ID of the group to update.
|
|
4698
|
+
* @param params - The settings to update.
|
|
4699
|
+
* @param params.subject - Optional new group subject/name.
|
|
4700
|
+
* @param params.description - Optional new group description.
|
|
4701
|
+
* @param params.profilePictureFile - Optional profile picture as a Buffer or Blob.
|
|
4702
|
+
* @returns The updated group settings response.
|
|
4703
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
|
|
4704
|
+
*/
|
|
4251
4705
|
updateGroupSettings(groupId: string, params: UpdateGroupSettingsRequest): Promise<GroupSettingsResponse>;
|
|
4252
4706
|
}
|
|
4253
4707
|
//#endregion
|
|
4254
4708
|
//#region src/api/marketingMessages/MarketingMessagesApi.d.ts
|
|
4255
4709
|
/**
|
|
4256
4710
|
* API for WhatsApp Marketing Messages.
|
|
4711
|
+
*
|
|
4712
|
+
* Provides methods to send marketing template messages to WhatsApp users,
|
|
4713
|
+
* with support for message activity sharing opt-in.
|
|
4714
|
+
*
|
|
4715
|
+
* Endpoints covered:
|
|
4716
|
+
* - `POST /{PHONE_NUMBER_ID}/marketing_messages` - Send a marketing template message
|
|
4717
|
+
*
|
|
4718
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages/
|
|
4257
4719
|
*/
|
|
4258
4720
|
declare class MarketingMessagesApi extends BaseAPI implements MarketingMessagesClass {
|
|
4259
4721
|
private readonly endpoint;
|
|
4722
|
+
/**
|
|
4723
|
+
* Send a marketing template message to a WhatsApp user.
|
|
4724
|
+
*
|
|
4725
|
+
* @param params - The marketing message request parameters.
|
|
4726
|
+
* @param params.to - The recipient's WhatsApp phone number.
|
|
4727
|
+
* @param params.template - The template configuration (name, language, components).
|
|
4728
|
+
* @param params.message_activity_sharing - Optional flag to enable message activity sharing.
|
|
4729
|
+
* @returns The messages response with message ID and status.
|
|
4730
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/marketing-messages/send-marketing-messages/
|
|
4731
|
+
*/
|
|
4260
4732
|
sendTemplateMessage(params: MarketingMessageRequest): Promise<MessagesResponse>;
|
|
4261
4733
|
}
|
|
4262
4734
|
//#endregion
|
|
4263
4735
|
//#region src/api/media/MediaApi.d.ts
|
|
4264
4736
|
/**
|
|
4265
|
-
* API for
|
|
4737
|
+
* WhatsApp Media API client for uploading, retrieving, downloading, and deleting media.
|
|
4266
4738
|
*
|
|
4267
|
-
*
|
|
4268
|
-
*
|
|
4269
|
-
*
|
|
4270
|
-
*
|
|
4271
|
-
* -
|
|
4739
|
+
* Media uploaded to the WhatsApp API can be used in messages (images, audio, video,
|
|
4740
|
+
* documents, stickers). Each media object is identified by a unique media ID.
|
|
4741
|
+
*
|
|
4742
|
+
* **Covered endpoints:**
|
|
4743
|
+
* - `GET /{MEDIA_ID}` - Retrieve media info ({@link MediaApi.getMediaById})
|
|
4744
|
+
* - `POST /{PHONE_NUMBER_ID}/media` - Upload media ({@link MediaApi.uploadMedia})
|
|
4745
|
+
* - `DELETE /{MEDIA_ID}` - Delete media ({@link MediaApi.deleteMedia})
|
|
4746
|
+
* - `GET {MEDIA_URL}` - Download media content ({@link MediaApi.downloadMedia})
|
|
4747
|
+
*
|
|
4748
|
+
* **Supported media types and size limits:**
|
|
4749
|
+
* | Type | MIME Types | Max Size |
|
|
4750
|
+
* |------|-----------|----------|
|
|
4751
|
+
* | Audio | audio/aac, audio/mp4, audio/mpeg, audio/amr, audio/ogg | 16 MB |
|
|
4752
|
+
* | Document | Various (PDF, DOC, DOCX, PPT, XLS, etc.) | 100 MB |
|
|
4753
|
+
* | Image | image/jpeg, image/png | 5 MB |
|
|
4754
|
+
* | Sticker | image/webp | 100 KB (animated), 500 KB (static) |
|
|
4755
|
+
* | Video | video/mp4, video/3gp | 16 MB |
|
|
4756
|
+
*
|
|
4757
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media | WhatsApp Media API Reference}
|
|
4758
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/media/ | WhatsApp Media Documentation}
|
|
4759
|
+
*
|
|
4760
|
+
* @example
|
|
4761
|
+
* ```ts
|
|
4762
|
+
* const client = new WhatsApp({ accessToken: '...', phoneNumberId: '...' });
|
|
4763
|
+
*
|
|
4764
|
+
* // Upload, send, then clean up
|
|
4765
|
+
* const { id } = await client.media.uploadMedia(file);
|
|
4766
|
+
* await client.messages.image({ body: { id }, to: '1234567890' });
|
|
4767
|
+
* await client.media.deleteMedia(id);
|
|
4768
|
+
* ```
|
|
4272
4769
|
*/
|
|
4273
4770
|
declare class MediaApi extends BaseAPI implements MediaClass {
|
|
4274
4771
|
private readonly endpoint;
|
|
4275
4772
|
/**
|
|
4276
|
-
*
|
|
4773
|
+
* Retrieves media information by media ID.
|
|
4277
4774
|
*
|
|
4278
|
-
*
|
|
4279
|
-
*
|
|
4280
|
-
*
|
|
4775
|
+
* Returns metadata about the media object including its URL, MIME type, file size,
|
|
4776
|
+
* and SHA-256 hash. The returned URL can be used with {@link MediaApi.downloadMedia}
|
|
4777
|
+
* to fetch the actual media content.
|
|
4778
|
+
*
|
|
4779
|
+
* **Endpoint:** `GET /{MEDIA_ID}`
|
|
4780
|
+
*
|
|
4781
|
+
* @param mediaId - The unique identifier of the media to retrieve
|
|
4782
|
+
* @returns A promise resolving to the media metadata including `url`, `mime_type`, `sha256`, and `file_size`
|
|
4783
|
+
*
|
|
4784
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#get-media-id | Get Media ID Reference}
|
|
4281
4785
|
*
|
|
4282
4786
|
* @example
|
|
4283
|
-
*
|
|
4787
|
+
* ```ts
|
|
4788
|
+
* const mediaInfo = await client.media.getMediaById('media_id_123');
|
|
4789
|
+
* console.log(mediaInfo.url); // URL to download the media
|
|
4790
|
+
* console.log(mediaInfo.mime_type); // e.g., "image/jpeg"
|
|
4791
|
+
* console.log(mediaInfo.file_size); // size in bytes
|
|
4792
|
+
* ```
|
|
4284
4793
|
*/
|
|
4285
4794
|
getMediaById(mediaId: string): Promise<MediaResponse>;
|
|
4286
4795
|
/**
|
|
4287
|
-
*
|
|
4796
|
+
* Uploads a media file to the WhatsApp Cloud API.
|
|
4288
4797
|
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4291
|
-
*
|
|
4798
|
+
* The uploaded media is assigned a unique media ID that can be used to send
|
|
4799
|
+
* messages containing that media. Media is automatically encrypted and stored
|
|
4800
|
+
* on Meta's servers.
|
|
4801
|
+
*
|
|
4802
|
+
* **Endpoint:** `POST /{PHONE_NUMBER_ID}/media`
|
|
4803
|
+
*
|
|
4804
|
+
* @param file - The `File` object to upload. The `type` property must match a supported MIME type.
|
|
4805
|
+
* @param messagingProduct - The messaging product identifier (defaults to `'whatsapp'`)
|
|
4806
|
+
* @returns A promise resolving to the upload response containing the assigned `id` (media ID)
|
|
4807
|
+
*
|
|
4808
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#upload-media | Upload Media Reference}
|
|
4292
4809
|
*
|
|
4293
4810
|
* @example
|
|
4811
|
+
* ```ts
|
|
4294
4812
|
* const file = new File([buffer], 'image.jpg', { type: 'image/jpeg' });
|
|
4295
|
-
* const
|
|
4813
|
+
* const { id } = await client.media.uploadMedia(file);
|
|
4814
|
+
* // Use the media ID to send an image message
|
|
4815
|
+
* await client.messages.image({ body: { id }, to: '1234567890' });
|
|
4816
|
+
* ```
|
|
4296
4817
|
*/
|
|
4297
4818
|
uploadMedia(file: File, messagingProduct?: string): Promise<UploadMediaResponse>;
|
|
4298
4819
|
/**
|
|
4299
|
-
*
|
|
4820
|
+
* Deletes a media file from WhatsApp servers.
|
|
4300
4821
|
*
|
|
4301
|
-
*
|
|
4302
|
-
*
|
|
4303
|
-
*
|
|
4822
|
+
* Once deleted, the media ID can no longer be used in messages. Any messages
|
|
4823
|
+
* already sent with this media will continue to display the media.
|
|
4824
|
+
*
|
|
4825
|
+
* **Endpoint:** `DELETE /{MEDIA_ID}`
|
|
4826
|
+
*
|
|
4827
|
+
* @param mediaId - The unique identifier of the media to delete
|
|
4828
|
+
* @returns A promise resolving to a success response (`{ success: true }`)
|
|
4829
|
+
*
|
|
4830
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#delete-media | Delete Media Reference}
|
|
4304
4831
|
*
|
|
4305
4832
|
* @example
|
|
4306
|
-
*
|
|
4833
|
+
* ```ts
|
|
4834
|
+
* const result = await client.media.deleteMedia('media_id_123');
|
|
4835
|
+
* console.log(result.success); // true
|
|
4836
|
+
* ```
|
|
4307
4837
|
*/
|
|
4308
4838
|
deleteMedia(mediaId: string): Promise<ResponseSuccess>;
|
|
4309
4839
|
/**
|
|
4310
|
-
*
|
|
4840
|
+
* Downloads media content from a WhatsApp media URL.
|
|
4311
4841
|
*
|
|
4312
|
-
* @
|
|
4313
|
-
*
|
|
4842
|
+
* Use {@link MediaApi.getMediaById} first to obtain the media URL, then pass it
|
|
4843
|
+
* to this method to download the actual file content. The returned URL from
|
|
4844
|
+
* `getMediaById` is only valid for a limited time.
|
|
4845
|
+
*
|
|
4846
|
+
* **Endpoint:** `GET {MEDIA_URL}`
|
|
4847
|
+
*
|
|
4848
|
+
* @param mediaUrl - The media download URL obtained from {@link MediaApi.getMediaById}
|
|
4849
|
+
* @returns A promise resolving to a `Blob` containing the raw media data
|
|
4850
|
+
*
|
|
4851
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#download-media | Download Media Reference}
|
|
4314
4852
|
*
|
|
4315
4853
|
* @example
|
|
4316
|
-
*
|
|
4854
|
+
* ```ts
|
|
4855
|
+
* // First get the media URL, then download it
|
|
4856
|
+
* const mediaInfo = await client.media.getMediaById('media_id_123');
|
|
4857
|
+
* const blob = await client.media.downloadMedia(mediaInfo.url);
|
|
4858
|
+
* ```
|
|
4317
4859
|
*/
|
|
4318
4860
|
downloadMedia(mediaUrl: string): Promise<Blob>;
|
|
4319
4861
|
}
|
|
4320
4862
|
//#endregion
|
|
4321
4863
|
//#region src/api/messages/MessageApi.d.ts
|
|
4322
4864
|
/**
|
|
4323
|
-
* Maps each message type to its appropriate payload type
|
|
4865
|
+
* Maps each message type to its appropriate payload type.
|
|
4866
|
+
*
|
|
4867
|
+
* This conditional type resolves the correct payload interface based on the {@link MessageTypesEnum} value,
|
|
4868
|
+
* ensuring type-safe message construction at compile time.
|
|
4324
4869
|
*/
|
|
4325
4870
|
type MessagePayloadType<T extends MessageTypesEnum> = T extends MessageTypesEnum.Audio ? AudioMediaObject : T extends MessageTypesEnum.Contacts ? [ContactObject] : T extends MessageTypesEnum.Document ? DocumentMediaObject : T extends MessageTypesEnum.Image ? ImageMediaObject : T extends MessageTypesEnum.Interactive ? InteractiveObject : T extends MessageTypesEnum.Location ? LocationObject : T extends MessageTypesEnum.Template ? MessageTemplateObject<ComponentTypesEnum> : T extends MessageTypesEnum.Sticker ? StickerMediaObject : T extends MessageTypesEnum.Text ? TextObject : T extends MessageTypesEnum.Video ? VideoMediaObject : T extends MessageTypesEnum.Reaction ? {
|
|
4326
4871
|
message_id: string;
|
|
4327
4872
|
emoji: string;
|
|
4328
4873
|
} : never;
|
|
4874
|
+
/**
|
|
4875
|
+
* WhatsApp Messages API client for sending various message types.
|
|
4876
|
+
*
|
|
4877
|
+
* Provides methods to send text, media, interactive, template, location, contact,
|
|
4878
|
+
* reaction, and status messages through the WhatsApp Cloud API.
|
|
4879
|
+
*
|
|
4880
|
+
* **Endpoint:** `POST /{PHONE_NUMBER_ID}/messages`
|
|
4881
|
+
*
|
|
4882
|
+
* **Covered operations:**
|
|
4883
|
+
* - {@link MessagesApi.text | text} - Send plain text messages
|
|
4884
|
+
* - {@link MessagesApi.audio | audio} - Send audio messages
|
|
4885
|
+
* - {@link MessagesApi.image | image} - Send image messages
|
|
4886
|
+
* - {@link MessagesApi.video | video} - Send video messages
|
|
4887
|
+
* - {@link MessagesApi.document | document} - Send document messages
|
|
4888
|
+
* - {@link MessagesApi.sticker | sticker} - Send sticker messages
|
|
4889
|
+
* - {@link MessagesApi.location | location} - Send location messages
|
|
4890
|
+
* - {@link MessagesApi.contacts | contacts} - Send contact card(s)
|
|
4891
|
+
* - {@link MessagesApi.template | template} - Send template messages
|
|
4892
|
+
* - {@link MessagesApi.interactive | interactive} - Send interactive messages (generic)
|
|
4893
|
+
* - {@link MessagesApi.interactiveList | interactiveList} - Send list interactive messages
|
|
4894
|
+
* - {@link MessagesApi.interactiveCtaUrl | interactiveCtaUrl} - Send CTA URL interactive messages
|
|
4895
|
+
* - {@link MessagesApi.interactiveLocationRequest | interactiveLocationRequest} - Send location request messages
|
|
4896
|
+
* - {@link MessagesApi.interactiveAddressMessage | interactiveAddressMessage} - Send address message interactive messages
|
|
4897
|
+
* - {@link MessagesApi.interactiveReplyButtons | interactiveReplyButtons} - Send reply button interactive messages
|
|
4898
|
+
* - {@link MessagesApi.interactiveFlow | interactiveFlow} - Send flow interactive messages
|
|
4899
|
+
* - {@link MessagesApi.interactiveCarousel | interactiveCarousel} - Send carousel interactive messages
|
|
4900
|
+
* - {@link MessagesApi.reaction | reaction} - Send reaction emoji to a message
|
|
4901
|
+
* - {@link MessagesApi.status | status} - Update message status (read, typing)
|
|
4902
|
+
* - {@link MessagesApi.markAsRead | markAsRead} - Mark a message as read
|
|
4903
|
+
* - {@link MessagesApi.showTypingIndicator | showTypingIndicator} - Show typing indicator
|
|
4904
|
+
*
|
|
4905
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages | WhatsApp Messages API Reference}
|
|
4906
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/ | WhatsApp Messages Documentation}
|
|
4907
|
+
*
|
|
4908
|
+
* @example
|
|
4909
|
+
* ```ts
|
|
4910
|
+
* const client = new WhatsApp({ accessToken: '...', phoneNumberId: '...' });
|
|
4911
|
+
*
|
|
4912
|
+
* // Send a text message
|
|
4913
|
+
* await client.messages.text({ body: 'Hello!', to: '1234567890' });
|
|
4914
|
+
*
|
|
4915
|
+
* // Send an image
|
|
4916
|
+
* await client.messages.image({ body: { link: 'https://example.com/image.jpg' }, to: '1234567890' });
|
|
4917
|
+
* ```
|
|
4918
|
+
*/
|
|
4329
4919
|
declare class MessagesApi extends BaseAPI implements MessagesClass {
|
|
4330
4920
|
private readonly commonMethod;
|
|
4331
4921
|
private readonly commonEndpoint;
|
|
4332
4922
|
/**
|
|
4333
|
-
* Builds the request body for WhatsApp API messages
|
|
4334
|
-
*
|
|
4335
|
-
*
|
|
4336
|
-
*
|
|
4337
|
-
*
|
|
4338
|
-
* @
|
|
4923
|
+
* Builds the request body for WhatsApp API messages.
|
|
4924
|
+
*
|
|
4925
|
+
* Constructs a properly formatted message payload including the messaging product,
|
|
4926
|
+
* recipient type, recipient phone number, message type, and optional reply context.
|
|
4927
|
+
*
|
|
4928
|
+
* @param type - The type of message to send (e.g., text, image, template)
|
|
4929
|
+
* @param payload - The message payload object matching the specified type
|
|
4930
|
+
* @param to - The recipient's phone number in international format (e.g., "1234567890")
|
|
4931
|
+
* @param replyMessageId - Optional message ID to reply to, setting the message context
|
|
4932
|
+
* @returns The formatted request body ready to be serialized and sent
|
|
4933
|
+
*
|
|
4934
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages | Messages API Reference}
|
|
4935
|
+
*
|
|
4936
|
+
* @example
|
|
4937
|
+
* ```ts
|
|
4938
|
+
* const body = messagesApi.bodyBuilder(
|
|
4939
|
+
* MessageTypesEnum.Text,
|
|
4940
|
+
* { body: 'Hello!' },
|
|
4941
|
+
* '1234567890',
|
|
4942
|
+
* );
|
|
4943
|
+
* ```
|
|
4339
4944
|
*/
|
|
4340
4945
|
bodyBuilder<T extends MessageTypesEnum>(type: T, payload: MessagePayloadType<T>, to: string, replyMessageId?: string): MessageRequestBody<T>;
|
|
4341
4946
|
/**
|
|
4342
|
-
* Sends a request to the WhatsApp API
|
|
4343
|
-
*
|
|
4344
|
-
*
|
|
4947
|
+
* Sends a request to the WhatsApp Cloud API messages endpoint.
|
|
4948
|
+
*
|
|
4949
|
+
* Internal method that dispatches the serialized JSON body to
|
|
4950
|
+
* `POST /{PHONE_NUMBER_ID}/messages`.
|
|
4951
|
+
*
|
|
4952
|
+
* @param body - The serialized JSON request body to send
|
|
4953
|
+
* @returns A promise resolving to the WhatsApp messages API response containing the message ID
|
|
4954
|
+
*
|
|
4955
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages | Messages API Reference}
|
|
4345
4956
|
*/
|
|
4346
4957
|
private send;
|
|
4347
4958
|
/**
|
|
4348
|
-
* Sends an audio message via WhatsApp
|
|
4349
|
-
*
|
|
4350
|
-
*
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
*
|
|
4355
|
-
* @param params
|
|
4356
|
-
* @
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
*
|
|
4361
|
-
*
|
|
4362
|
-
* @
|
|
4959
|
+
* Sends an audio message via the WhatsApp Cloud API.
|
|
4960
|
+
*
|
|
4961
|
+
* The audio can be specified by a media ID (previously uploaded) or a public URL link.
|
|
4962
|
+
* Supported formats: audio/aac, audio/mp4, audio/mpeg, audio/amr, audio/ogg (with opus codec).
|
|
4963
|
+
* Maximum file size: 16 MB.
|
|
4964
|
+
*
|
|
4965
|
+
* @param params - The audio message parameters
|
|
4966
|
+
* @param params.body - Audio media object containing either `id` (media ID) or `link` (URL)
|
|
4967
|
+
* @param params.to - Recipient phone number in international format
|
|
4968
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
4969
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
4970
|
+
*
|
|
4971
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#audio-object | Audio Object Reference}
|
|
4972
|
+
*
|
|
4973
|
+
* @example
|
|
4974
|
+
* ```ts
|
|
4975
|
+
* // Send audio by URL
|
|
4976
|
+
* await client.messages.audio({
|
|
4977
|
+
* body: { link: 'https://example.com/audio.mp3' },
|
|
4978
|
+
* to: '1234567890',
|
|
4979
|
+
* });
|
|
4980
|
+
*
|
|
4981
|
+
* // Send audio by media ID
|
|
4982
|
+
* await client.messages.audio({
|
|
4983
|
+
* body: { id: 'media_id_123' },
|
|
4984
|
+
* to: '1234567890',
|
|
4985
|
+
* });
|
|
4986
|
+
* ```
|
|
4987
|
+
*/
|
|
4988
|
+
audio(params: MessageRequestParams<AudioMediaObject>): Promise<MessagesResponse>;
|
|
4989
|
+
/**
|
|
4990
|
+
* Sends one or more contact cards via the WhatsApp Cloud API.
|
|
4991
|
+
*
|
|
4992
|
+
* Contact messages allow sharing structured contact information including names,
|
|
4993
|
+
* phone numbers, email addresses, and more.
|
|
4994
|
+
*
|
|
4995
|
+
* @param params - The contact message parameters
|
|
4996
|
+
* @param params.body - Array of {@link m.ContactObject} containing contact details (name, phones, emails, etc.)
|
|
4997
|
+
* @param params.to - Recipient phone number in international format
|
|
4998
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
4999
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5000
|
+
*
|
|
5001
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#contacts-object | Contacts Object Reference}
|
|
5002
|
+
*
|
|
5003
|
+
* @example
|
|
5004
|
+
* ```ts
|
|
5005
|
+
* await client.messages.contacts({
|
|
5006
|
+
* body: [{
|
|
5007
|
+
* name: { formatted_name: 'John Doe', first_name: 'John', last_name: 'Doe' },
|
|
5008
|
+
* phones: [{ phone: '+1234567890', type: 'MOBILE' }],
|
|
5009
|
+
* }],
|
|
5010
|
+
* to: '1234567890',
|
|
5011
|
+
* });
|
|
5012
|
+
* ```
|
|
5013
|
+
*/
|
|
5014
|
+
contacts(params: MessageRequestParams<[ContactObject]>): Promise<MessagesResponse>;
|
|
5015
|
+
/**
|
|
5016
|
+
* Sends a document message via the WhatsApp Cloud API.
|
|
5017
|
+
*
|
|
5018
|
+
* Documents can be specified by media ID or public URL. Supports various formats
|
|
5019
|
+
* including PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, and more.
|
|
5020
|
+
* Maximum file size: 100 MB.
|
|
5021
|
+
*
|
|
5022
|
+
* @param params - The document message parameters
|
|
5023
|
+
* @param params.body - Document media object containing `id` or `link`, and optional `caption` and `filename`
|
|
5024
|
+
* @param params.to - Recipient phone number in international format
|
|
5025
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5026
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5027
|
+
*
|
|
5028
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#document-object | Document Object Reference}
|
|
5029
|
+
*
|
|
5030
|
+
* @example
|
|
5031
|
+
* ```ts
|
|
5032
|
+
* await client.messages.document({
|
|
5033
|
+
* body: {
|
|
5034
|
+
* link: 'https://example.com/report.pdf',
|
|
5035
|
+
* caption: 'Monthly Report',
|
|
5036
|
+
* filename: 'report.pdf',
|
|
5037
|
+
* },
|
|
5038
|
+
* to: '1234567890',
|
|
5039
|
+
* });
|
|
5040
|
+
* ```
|
|
4363
5041
|
*/
|
|
4364
5042
|
document(params: MessageRequestParams<DocumentMediaObject>): Promise<MessagesResponse>;
|
|
4365
5043
|
/**
|
|
4366
|
-
* Sends an image via WhatsApp
|
|
4367
|
-
*
|
|
4368
|
-
*
|
|
5044
|
+
* Sends an image message via the WhatsApp Cloud API.
|
|
5045
|
+
*
|
|
5046
|
+
* Images can be specified by media ID or public URL.
|
|
5047
|
+
* Supported formats: image/jpeg, image/png. Maximum file size: 5 MB.
|
|
5048
|
+
*
|
|
5049
|
+
* @param params - The image message parameters
|
|
5050
|
+
* @param params.body - Image media object containing `id` or `link`, and optional `caption`
|
|
5051
|
+
* @param params.to - Recipient phone number in international format
|
|
5052
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5053
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5054
|
+
*
|
|
5055
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#image-object | Image Object Reference}
|
|
5056
|
+
*
|
|
5057
|
+
* @example
|
|
5058
|
+
* ```ts
|
|
5059
|
+
* await client.messages.image({
|
|
5060
|
+
* body: { link: 'https://example.com/photo.jpg', caption: 'Check this out!' },
|
|
5061
|
+
* to: '1234567890',
|
|
5062
|
+
* });
|
|
5063
|
+
* ```
|
|
4369
5064
|
*/
|
|
4370
5065
|
image(params: MessageRequestParams<ImageMediaObject>): Promise<MessagesResponse>;
|
|
4371
5066
|
/**
|
|
4372
|
-
* Sends an interactive message via WhatsApp
|
|
4373
|
-
*
|
|
4374
|
-
*
|
|
5067
|
+
* Sends an interactive message via the WhatsApp Cloud API.
|
|
5068
|
+
*
|
|
5069
|
+
* Interactive messages allow rich user interactions such as lists, buttons, CTAs,
|
|
5070
|
+
* flows, location requests, address messages, and carousels. For type-specific
|
|
5071
|
+
* convenience methods, see {@link MessagesApi.interactiveList}, {@link MessagesApi.interactiveReplyButtons}, etc.
|
|
5072
|
+
*
|
|
5073
|
+
* @param params - The interactive message parameters
|
|
5074
|
+
* @param params.body - Interactive object containing the `type` and type-specific action/body/header/footer
|
|
5075
|
+
* @param params.to - Recipient phone number in international format
|
|
5076
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5077
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5078
|
+
*
|
|
5079
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5080
|
+
*
|
|
5081
|
+
* @example
|
|
5082
|
+
* ```ts
|
|
5083
|
+
* await client.messages.interactive({
|
|
5084
|
+
* body: {
|
|
5085
|
+
* type: 'button',
|
|
5086
|
+
* body: { text: 'Choose an option' },
|
|
5087
|
+
* action: {
|
|
5088
|
+
* buttons: [
|
|
5089
|
+
* { type: 'reply', reply: { id: 'btn1', title: 'Option 1' } },
|
|
5090
|
+
* { type: 'reply', reply: { id: 'btn2', title: 'Option 2' } },
|
|
5091
|
+
* ],
|
|
5092
|
+
* },
|
|
5093
|
+
* },
|
|
5094
|
+
* to: '1234567890',
|
|
5095
|
+
* });
|
|
5096
|
+
* ```
|
|
4375
5097
|
*/
|
|
4376
5098
|
interactive(params: MessageRequestParams<InteractiveObject>): Promise<MessagesResponse>;
|
|
4377
5099
|
/**
|
|
4378
|
-
* Sends a location via WhatsApp
|
|
4379
|
-
*
|
|
4380
|
-
*
|
|
5100
|
+
* Sends a location message via the WhatsApp Cloud API.
|
|
5101
|
+
*
|
|
5102
|
+
* Shares a geographic location with the recipient, displayed as a map pin.
|
|
5103
|
+
*
|
|
5104
|
+
* @param params - The location message parameters
|
|
5105
|
+
* @param params.body - Location object containing `latitude`, `longitude`, and optional `name` and `address`
|
|
5106
|
+
* @param params.to - Recipient phone number in international format
|
|
5107
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5108
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5109
|
+
*
|
|
5110
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#location-object | Location Object Reference}
|
|
5111
|
+
*
|
|
5112
|
+
* @example
|
|
5113
|
+
* ```ts
|
|
5114
|
+
* await client.messages.location({
|
|
5115
|
+
* body: {
|
|
5116
|
+
* latitude: 37.4220936,
|
|
5117
|
+
* longitude: -122.083922,
|
|
5118
|
+
* name: 'Googleplex',
|
|
5119
|
+
* address: '1600 Amphitheatre Parkway, Mountain View, CA',
|
|
5120
|
+
* },
|
|
5121
|
+
* to: '1234567890',
|
|
5122
|
+
* });
|
|
5123
|
+
* ```
|
|
4381
5124
|
*/
|
|
4382
5125
|
location(params: MessageRequestParams<LocationObject>): Promise<MessagesResponse>;
|
|
4383
5126
|
/**
|
|
4384
|
-
* Sends a sticker via WhatsApp
|
|
4385
|
-
*
|
|
4386
|
-
*
|
|
5127
|
+
* Sends a sticker message via the WhatsApp Cloud API.
|
|
5128
|
+
*
|
|
5129
|
+
* Stickers can be specified by media ID or public URL.
|
|
5130
|
+
* Supported format: image/webp. Maximum file size: 100 KB (animated), 500 KB (static).
|
|
5131
|
+
*
|
|
5132
|
+
* @param params - The sticker message parameters
|
|
5133
|
+
* @param params.body - Sticker media object containing `id` or `link`
|
|
5134
|
+
* @param params.to - Recipient phone number in international format
|
|
5135
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5136
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5137
|
+
*
|
|
5138
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#sticker-object | Sticker Object Reference}
|
|
5139
|
+
*
|
|
5140
|
+
* @example
|
|
5141
|
+
* ```ts
|
|
5142
|
+
* await client.messages.sticker({
|
|
5143
|
+
* body: { link: 'https://example.com/sticker.webp' },
|
|
5144
|
+
* to: '1234567890',
|
|
5145
|
+
* });
|
|
5146
|
+
* ```
|
|
4387
5147
|
*/
|
|
4388
5148
|
sticker(params: MessageRequestParams<StickerMediaObject>): Promise<MessagesResponse>;
|
|
4389
5149
|
/**
|
|
4390
|
-
* Sends a template message via WhatsApp
|
|
4391
|
-
*
|
|
4392
|
-
*
|
|
5150
|
+
* Sends a template message via the WhatsApp Cloud API.
|
|
5151
|
+
*
|
|
5152
|
+
* Template messages use pre-approved message templates and can include header,
|
|
5153
|
+
* body, and button components with dynamic parameters. Templates must be
|
|
5154
|
+
* approved before use.
|
|
5155
|
+
*
|
|
5156
|
+
* @param params - The template message parameters
|
|
5157
|
+
* @param params.body - Template object containing `name`, `language`, and optional `components`
|
|
5158
|
+
* @param params.to - Recipient phone number in international format
|
|
5159
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5160
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5161
|
+
*
|
|
5162
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#template-object | Template Object Reference}
|
|
5163
|
+
*
|
|
5164
|
+
* @example
|
|
5165
|
+
* ```ts
|
|
5166
|
+
* await client.messages.template({
|
|
5167
|
+
* body: {
|
|
5168
|
+
* name: 'hello_world',
|
|
5169
|
+
* language: { code: 'en_US' },
|
|
5170
|
+
* components: [
|
|
5171
|
+
* { type: 'body', parameters: [{ type: 'text', text: 'John' }] },
|
|
5172
|
+
* ],
|
|
5173
|
+
* },
|
|
5174
|
+
* to: '1234567890',
|
|
5175
|
+
* });
|
|
5176
|
+
* ```
|
|
4393
5177
|
*/
|
|
4394
5178
|
template(params: MessageRequestParams<MessageTemplateObject<ComponentTypesEnum>>): Promise<MessagesResponse>;
|
|
4395
5179
|
/**
|
|
4396
|
-
* Sends a text message via WhatsApp
|
|
4397
|
-
*
|
|
4398
|
-
*
|
|
5180
|
+
* Sends a text message via the WhatsApp Cloud API.
|
|
5181
|
+
*
|
|
5182
|
+
* Sends a plain text message. The `body` can be a string or a {@link m.TextObject}.
|
|
5183
|
+
* URL preview is enabled by default.
|
|
5184
|
+
*
|
|
5185
|
+
* @param params - The text message parameters
|
|
5186
|
+
* @param params.body - Message text as a string, or a {@link m.TextObject} with `body` and optional `preview_url`
|
|
5187
|
+
* @param params.to - Recipient phone number in international format
|
|
5188
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5189
|
+
* @param params.previewUrl - Whether to show a URL preview (defaults to `true`)
|
|
5190
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5191
|
+
*
|
|
5192
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#text-object | Text Object Reference}
|
|
5193
|
+
*
|
|
5194
|
+
* @example
|
|
5195
|
+
* ```ts
|
|
5196
|
+
* // Simple text
|
|
5197
|
+
* await client.messages.text({ body: 'Hello, World!', to: '1234567890' });
|
|
5198
|
+
*
|
|
5199
|
+
* // With URL preview disabled
|
|
5200
|
+
* await client.messages.text({
|
|
5201
|
+
* body: { body: 'Visit https://example.com', preview_url: false },
|
|
5202
|
+
* to: '1234567890',
|
|
5203
|
+
* });
|
|
5204
|
+
* ```
|
|
4399
5205
|
*/
|
|
4400
5206
|
text(params: TextMessageParams): Promise<MessagesResponse>;
|
|
4401
5207
|
/**
|
|
4402
|
-
* Sends a video message via WhatsApp
|
|
4403
|
-
*
|
|
4404
|
-
*
|
|
5208
|
+
* Sends a video message via the WhatsApp Cloud API.
|
|
5209
|
+
*
|
|
5210
|
+
* Videos can be specified by media ID or public URL.
|
|
5211
|
+
* Supported formats: video/mp4, video/3gp. Maximum file size: 16 MB.
|
|
5212
|
+
* Only H.264 video codec and AAC audio codec are supported.
|
|
5213
|
+
*
|
|
5214
|
+
* @param params - The video message parameters
|
|
5215
|
+
* @param params.body - Video media object containing `id` or `link`, and optional `caption`
|
|
5216
|
+
* @param params.to - Recipient phone number in international format
|
|
5217
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5218
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5219
|
+
*
|
|
5220
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#video-object | Video Object Reference}
|
|
5221
|
+
*
|
|
5222
|
+
* @example
|
|
5223
|
+
* ```ts
|
|
5224
|
+
* await client.messages.video({
|
|
5225
|
+
* body: { link: 'https://example.com/video.mp4', caption: 'Watch this!' },
|
|
5226
|
+
* to: '1234567890',
|
|
5227
|
+
* });
|
|
5228
|
+
* ```
|
|
4405
5229
|
*/
|
|
4406
5230
|
video(params: MessageRequestParams<VideoMediaObject>): Promise<MessagesResponse>;
|
|
4407
5231
|
/**
|
|
4408
|
-
* Updates
|
|
4409
|
-
*
|
|
4410
|
-
*
|
|
5232
|
+
* Updates the status of a message (e.g., mark as read or show typing indicator).
|
|
5233
|
+
*
|
|
5234
|
+
* This is the low-level status method. For convenience, use {@link MessagesApi.markAsRead}
|
|
5235
|
+
* or {@link MessagesApi.showTypingIndicator} instead.
|
|
5236
|
+
*
|
|
5237
|
+
* @param params - The status update parameters
|
|
5238
|
+
* @param params.status - The status to set (e.g., `'read'`, `'typing'`)
|
|
5239
|
+
* @param params.messageId - The ID of the message to update
|
|
5240
|
+
* @param params.typingIndicator - Optional typing indicator configuration
|
|
5241
|
+
* @returns A promise resolving to the API response
|
|
5242
|
+
*
|
|
5243
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#status-object | Status Object Reference}
|
|
5244
|
+
*
|
|
5245
|
+
* @example
|
|
5246
|
+
* ```ts
|
|
5247
|
+
* await client.messages.status({
|
|
5248
|
+
* status: 'read',
|
|
5249
|
+
* messageId: 'wamid.ABC123',
|
|
5250
|
+
* });
|
|
5251
|
+
* ```
|
|
4411
5252
|
*/
|
|
4412
5253
|
status(params: StatusParams): Promise<MessagesResponse>;
|
|
4413
5254
|
/**
|
|
4414
|
-
* Marks a message as read
|
|
4415
|
-
*
|
|
4416
|
-
* @
|
|
5255
|
+
* Marks a message as read, sending a read receipt to the sender.
|
|
5256
|
+
*
|
|
5257
|
+
* This is a convenience wrapper around {@link MessagesApi.status} that sets the status to `'read'`.
|
|
5258
|
+
* When a message is marked as read, all previous messages in the conversation are also marked as read.
|
|
5259
|
+
*
|
|
5260
|
+
* @param params - The parameters
|
|
5261
|
+
* @param params.messageId - The ID of the incoming message to mark as read (the `wamid` value)
|
|
5262
|
+
* @returns A promise resolving to the API response
|
|
5263
|
+
*
|
|
5264
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#status-object | Status Object Reference}
|
|
5265
|
+
*
|
|
5266
|
+
* @example
|
|
5267
|
+
* ```ts
|
|
5268
|
+
* await client.messages.markAsRead({ messageId: 'wamid.ABC123' });
|
|
5269
|
+
* ```
|
|
4417
5270
|
*/
|
|
4418
5271
|
markAsRead(params: {
|
|
4419
5272
|
messageId: string;
|
|
4420
5273
|
}): Promise<MessagesResponse>;
|
|
4421
5274
|
/**
|
|
4422
|
-
* Shows typing indicator
|
|
4423
|
-
*
|
|
4424
|
-
*
|
|
5275
|
+
* Shows a typing indicator to the user, indicating that a response is being composed.
|
|
5276
|
+
*
|
|
5277
|
+
* The typing indicator is displayed for approximately 25 seconds or until a message
|
|
5278
|
+
* is sent, whichever comes first.
|
|
5279
|
+
*
|
|
5280
|
+
* @param params - The parameters
|
|
5281
|
+
* @param params.messageId - The ID of the incoming message to associate the typing indicator with
|
|
5282
|
+
* @returns A promise resolving to the API response
|
|
5283
|
+
*
|
|
5284
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#status-object | Status Object Reference}
|
|
5285
|
+
*
|
|
5286
|
+
* @example
|
|
5287
|
+
* ```ts
|
|
5288
|
+
* await client.messages.showTypingIndicator({ messageId: 'wamid.ABC123' });
|
|
5289
|
+
* ```
|
|
4425
5290
|
*/
|
|
4426
5291
|
showTypingIndicator(params: {
|
|
4427
5292
|
messageId: string;
|
|
4428
5293
|
}): Promise<MessagesResponse>;
|
|
4429
5294
|
/**
|
|
4430
|
-
* Sends a list interactive message
|
|
4431
|
-
*
|
|
4432
|
-
*
|
|
5295
|
+
* Sends a list interactive message via the WhatsApp Cloud API.
|
|
5296
|
+
*
|
|
5297
|
+
* List messages present up to 10 selectable options in a menu-style list.
|
|
5298
|
+
* Each section can have a title and multiple rows with title, description, and ID.
|
|
5299
|
+
*
|
|
5300
|
+
* @param params - The list interactive message parameters
|
|
5301
|
+
* @param params.body - Interactive object with `type: 'list'` and action containing sections
|
|
5302
|
+
* @param params.to - Recipient phone number in international format
|
|
5303
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5304
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5305
|
+
*
|
|
5306
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#list-messages | List Messages Reference}
|
|
5307
|
+
*
|
|
5308
|
+
* @example
|
|
5309
|
+
* ```ts
|
|
5310
|
+
* await client.messages.interactiveList({
|
|
5311
|
+
* body: {
|
|
5312
|
+
* type: 'list',
|
|
5313
|
+
* body: { text: 'Choose an option' },
|
|
5314
|
+
* action: {
|
|
5315
|
+
* button: 'View Options',
|
|
5316
|
+
* sections: [{ title: 'Section 1', rows: [{ id: '1', title: 'Option 1' }] }],
|
|
5317
|
+
* },
|
|
5318
|
+
* },
|
|
5319
|
+
* to: '1234567890',
|
|
5320
|
+
* });
|
|
5321
|
+
* ```
|
|
4433
5322
|
*/
|
|
4434
5323
|
interactiveList(params: MessageRequestParams<InteractiveObject & {
|
|
4435
5324
|
type: InteractiveTypesEnum.List;
|
|
4436
5325
|
}>): Promise<MessagesResponse>;
|
|
4437
5326
|
/**
|
|
4438
|
-
* Sends a CTA URL interactive message
|
|
4439
|
-
*
|
|
4440
|
-
*
|
|
5327
|
+
* Sends a Call-to-Action (CTA) URL button interactive message via the WhatsApp Cloud API.
|
|
5328
|
+
*
|
|
5329
|
+
* CTA URL messages display a button that opens a URL when tapped.
|
|
5330
|
+
*
|
|
5331
|
+
* @param params - The CTA URL interactive message parameters
|
|
5332
|
+
* @param params.body - Interactive object with `type: 'cta_url'` and action containing the URL and display text
|
|
5333
|
+
* @param params.to - Recipient phone number in international format
|
|
5334
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5335
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5336
|
+
*
|
|
5337
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5338
|
+
*
|
|
5339
|
+
* @example
|
|
5340
|
+
* ```ts
|
|
5341
|
+
* await client.messages.interactiveCtaUrl({
|
|
5342
|
+
* body: {
|
|
5343
|
+
* type: 'cta_url',
|
|
5344
|
+
* body: { text: 'Visit our website' },
|
|
5345
|
+
* action: { name: 'cta_url', parameters: { display_text: 'Open', url: 'https://example.com' } },
|
|
5346
|
+
* },
|
|
5347
|
+
* to: '1234567890',
|
|
5348
|
+
* });
|
|
5349
|
+
* ```
|
|
4441
5350
|
*/
|
|
4442
5351
|
interactiveCtaUrl(params: MessageRequestParams<InteractiveObject & {
|
|
4443
5352
|
type: InteractiveTypesEnum.CtaUrl;
|
|
4444
5353
|
}>): Promise<MessagesResponse>;
|
|
4445
5354
|
/**
|
|
4446
|
-
* Sends a location request interactive message
|
|
4447
|
-
*
|
|
4448
|
-
*
|
|
5355
|
+
* Sends a location request interactive message via the WhatsApp Cloud API.
|
|
5356
|
+
*
|
|
5357
|
+
* Prompts the recipient to share their current location.
|
|
5358
|
+
*
|
|
5359
|
+
* @param params - The location request interactive message parameters
|
|
5360
|
+
* @param params.body - Interactive object with `type: 'location_request_message'`
|
|
5361
|
+
* @param params.to - Recipient phone number in international format
|
|
5362
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5363
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5364
|
+
*
|
|
5365
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5366
|
+
*
|
|
5367
|
+
* @example
|
|
5368
|
+
* ```ts
|
|
5369
|
+
* await client.messages.interactiveLocationRequest({
|
|
5370
|
+
* body: {
|
|
5371
|
+
* type: 'location_request_message',
|
|
5372
|
+
* body: { text: 'Please share your location' },
|
|
5373
|
+
* action: { name: 'send_location' },
|
|
5374
|
+
* },
|
|
5375
|
+
* to: '1234567890',
|
|
5376
|
+
* });
|
|
5377
|
+
* ```
|
|
4449
5378
|
*/
|
|
4450
5379
|
interactiveLocationRequest(params: MessageRequestParams<InteractiveObject & {
|
|
4451
5380
|
type: InteractiveTypesEnum.LocationRequest;
|
|
4452
5381
|
}>): Promise<MessagesResponse>;
|
|
4453
5382
|
/**
|
|
4454
|
-
* Sends an address message interactive message
|
|
4455
|
-
*
|
|
4456
|
-
*
|
|
5383
|
+
* Sends an address message interactive message via the WhatsApp Cloud API.
|
|
5384
|
+
*
|
|
5385
|
+
* Prompts the recipient to provide or confirm a shipping/delivery address.
|
|
5386
|
+
*
|
|
5387
|
+
* @param params - The address message interactive message parameters
|
|
5388
|
+
* @param params.body - Interactive object with `type: 'address_message'`
|
|
5389
|
+
* @param params.to - Recipient phone number in international format
|
|
5390
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5391
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5392
|
+
*
|
|
5393
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5394
|
+
*
|
|
5395
|
+
* @example
|
|
5396
|
+
* ```ts
|
|
5397
|
+
* await client.messages.interactiveAddressMessage({
|
|
5398
|
+
* body: {
|
|
5399
|
+
* type: 'address_message',
|
|
5400
|
+
* body: { text: 'Please confirm your delivery address' },
|
|
5401
|
+
* action: { name: 'address_message', parameters: { country: 'US' } },
|
|
5402
|
+
* },
|
|
5403
|
+
* to: '1234567890',
|
|
5404
|
+
* });
|
|
5405
|
+
* ```
|
|
4457
5406
|
*/
|
|
4458
5407
|
interactiveAddressMessage(params: MessageRequestParams<InteractiveObject & {
|
|
4459
5408
|
type: InteractiveTypesEnum.AddressMessage;
|
|
4460
5409
|
}>): Promise<MessagesResponse>;
|
|
4461
5410
|
/**
|
|
4462
|
-
* Sends a reply buttons interactive message
|
|
4463
|
-
*
|
|
4464
|
-
*
|
|
5411
|
+
* Sends a reply buttons interactive message via the WhatsApp Cloud API.
|
|
5412
|
+
*
|
|
5413
|
+
* Reply button messages display up to 3 quick-reply buttons. Each button has
|
|
5414
|
+
* a unique ID and title (up to 20 characters).
|
|
5415
|
+
*
|
|
5416
|
+
* @param params - The reply buttons interactive message parameters
|
|
5417
|
+
* @param params.body - Interactive object with `type: 'button'` and action containing up to 3 reply buttons
|
|
5418
|
+
* @param params.to - Recipient phone number in international format
|
|
5419
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5420
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5421
|
+
*
|
|
5422
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#reply-button | Reply Button Reference}
|
|
5423
|
+
*
|
|
5424
|
+
* @example
|
|
5425
|
+
* ```ts
|
|
5426
|
+
* await client.messages.interactiveReplyButtons({
|
|
5427
|
+
* body: {
|
|
5428
|
+
* type: 'button',
|
|
5429
|
+
* body: { text: 'Do you agree?' },
|
|
5430
|
+
* action: {
|
|
5431
|
+
* buttons: [
|
|
5432
|
+
* { type: 'reply', reply: { id: 'yes', title: 'Yes' } },
|
|
5433
|
+
* { type: 'reply', reply: { id: 'no', title: 'No' } },
|
|
5434
|
+
* ],
|
|
5435
|
+
* },
|
|
5436
|
+
* },
|
|
5437
|
+
* to: '1234567890',
|
|
5438
|
+
* });
|
|
5439
|
+
* ```
|
|
4465
5440
|
*/
|
|
4466
5441
|
interactiveReplyButtons(params: MessageRequestParams<InteractiveObject & {
|
|
4467
5442
|
type: InteractiveTypesEnum.Button;
|
|
4468
5443
|
}>): Promise<MessagesResponse>;
|
|
4469
5444
|
/**
|
|
4470
|
-
* Sends a flow interactive message
|
|
4471
|
-
*
|
|
4472
|
-
*
|
|
5445
|
+
* Sends a flow interactive message via the WhatsApp Cloud API.
|
|
5446
|
+
*
|
|
5447
|
+
* Flow messages launch a WhatsApp Flow, which provides structured multi-step interactions
|
|
5448
|
+
* (forms, surveys, appointment booking, etc.) within the chat.
|
|
5449
|
+
*
|
|
5450
|
+
* @param params - The flow interactive message parameters
|
|
5451
|
+
* @param params.body - Interactive object with `type: 'flow'` and action containing the flow token and configuration
|
|
5452
|
+
* @param params.to - Recipient phone number in international format
|
|
5453
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5454
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5455
|
+
*
|
|
5456
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5457
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/flows | WhatsApp Flows Documentation}
|
|
5458
|
+
*
|
|
5459
|
+
* @example
|
|
5460
|
+
* ```ts
|
|
5461
|
+
* await client.messages.interactiveFlow({
|
|
5462
|
+
* body: {
|
|
5463
|
+
* type: 'flow',
|
|
5464
|
+
* body: { text: 'Book an appointment' },
|
|
5465
|
+
* action: {
|
|
5466
|
+
* name: 'flow',
|
|
5467
|
+
* parameters: { flow_message_version: '3', flow_id: '123456', flow_cta: 'Book Now' },
|
|
5468
|
+
* },
|
|
5469
|
+
* },
|
|
5470
|
+
* to: '1234567890',
|
|
5471
|
+
* });
|
|
5472
|
+
* ```
|
|
4473
5473
|
*/
|
|
4474
5474
|
interactiveFlow(params: MessageRequestParams<InteractiveObject & {
|
|
4475
5475
|
type: InteractiveTypesEnum.Flow;
|
|
4476
5476
|
}>): Promise<MessagesResponse>;
|
|
4477
5477
|
/**
|
|
4478
|
-
* Sends a carousel interactive message
|
|
4479
|
-
*
|
|
4480
|
-
*
|
|
5478
|
+
* Sends a carousel interactive message via the WhatsApp Cloud API.
|
|
5479
|
+
*
|
|
5480
|
+
* Carousel messages display a horizontally scrollable set of cards, each with
|
|
5481
|
+
* an image, body text, and up to 2 quick-reply buttons.
|
|
5482
|
+
*
|
|
5483
|
+
* @param params - The carousel interactive message parameters
|
|
5484
|
+
* @param params.body - Interactive object with `type: 'carousel'` and action containing carousel cards
|
|
5485
|
+
* @param params.to - Recipient phone number in international format
|
|
5486
|
+
* @param params.replyMessageId - Optional message ID to reply to
|
|
5487
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5488
|
+
*
|
|
5489
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object | Interactive Object Reference}
|
|
5490
|
+
*
|
|
5491
|
+
* @example
|
|
5492
|
+
* ```ts
|
|
5493
|
+
* await client.messages.interactiveCarousel({
|
|
5494
|
+
* body: {
|
|
5495
|
+
* type: 'carousel',
|
|
5496
|
+
* body: { text: 'Browse our products' },
|
|
5497
|
+
* action: {
|
|
5498
|
+
* cards: [
|
|
5499
|
+
* {
|
|
5500
|
+
* header: { type: 'image', image: { link: 'https://example.com/product1.jpg' } },
|
|
5501
|
+
* body: { text: 'Product 1 - $10' },
|
|
5502
|
+
* buttons: [{ type: 'reply', reply: { id: 'buy_1', title: 'Buy' } }],
|
|
5503
|
+
* },
|
|
5504
|
+
* ],
|
|
5505
|
+
* },
|
|
5506
|
+
* },
|
|
5507
|
+
* to: '1234567890',
|
|
5508
|
+
* });
|
|
5509
|
+
* ```
|
|
4481
5510
|
*/
|
|
4482
5511
|
interactiveCarousel(params: MessageRequestParams<InteractiveObject & {
|
|
4483
5512
|
type: InteractiveTypesEnum.Carousel;
|
|
4484
5513
|
}>): Promise<MessagesResponse>;
|
|
4485
5514
|
/**
|
|
4486
|
-
* Sends a reaction to
|
|
4487
|
-
*
|
|
4488
|
-
*
|
|
5515
|
+
* Sends a reaction emoji to an existing message via the WhatsApp Cloud API.
|
|
5516
|
+
*
|
|
5517
|
+
* Reactions allow users to respond to messages with a single emoji.
|
|
5518
|
+
* To remove a reaction, send an empty string as the emoji.
|
|
5519
|
+
*
|
|
5520
|
+
* @param params - The reaction parameters
|
|
5521
|
+
* @param params.messageId - The ID of the message to react to
|
|
5522
|
+
* @param params.emoji - The emoji character to react with (e.g., "\uD83D\uDC4D"), or empty string to remove reaction
|
|
5523
|
+
* @param params.to - Recipient phone number in international format
|
|
5524
|
+
* @returns A promise resolving to the message response with the sent message ID
|
|
5525
|
+
*
|
|
5526
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#reaction-object | Reaction Object Reference}
|
|
5527
|
+
*
|
|
5528
|
+
* @example
|
|
5529
|
+
* ```ts
|
|
5530
|
+
* // Add a reaction
|
|
5531
|
+
* await client.messages.reaction({
|
|
5532
|
+
* messageId: 'wamid.ABC123',
|
|
5533
|
+
* emoji: '\uD83D\uDC4D',
|
|
5534
|
+
* to: '1234567890',
|
|
5535
|
+
* });
|
|
5536
|
+
*
|
|
5537
|
+
* // Remove a reaction
|
|
5538
|
+
* await client.messages.reaction({
|
|
5539
|
+
* messageId: 'wamid.ABC123',
|
|
5540
|
+
* emoji: '',
|
|
5541
|
+
* to: '1234567890',
|
|
5542
|
+
* });
|
|
5543
|
+
* ```
|
|
4489
5544
|
*/
|
|
4490
5545
|
reaction(params: ReactionParams): Promise<MessagesResponse>;
|
|
4491
5546
|
}
|
|
@@ -4493,136 +5548,264 @@ declare class MessagesApi extends BaseAPI implements MessagesClass {
|
|
|
4493
5548
|
//#region src/api/payments/PaymentsApi.d.ts
|
|
4494
5549
|
/**
|
|
4495
5550
|
* API for WhatsApp Payments (India payment configuration).
|
|
5551
|
+
*
|
|
5552
|
+
* Provides methods to manage payment configurations for WhatsApp Business Accounts,
|
|
5553
|
+
* including creating, reading, updating, and deleting payment configurations,
|
|
5554
|
+
* as well as generating OAuth links for payment onboarding.
|
|
5555
|
+
*
|
|
5556
|
+
* Endpoints covered:
|
|
5557
|
+
* - `GET /{WABA_ID}/payment_configurations` - List all payment configurations
|
|
5558
|
+
* - `GET /{WABA_ID}/payment_configuration/{CONFIGURATION_NAME}` - Get a specific payment configuration
|
|
5559
|
+
* - `POST /{WABA_ID}/payment_configuration` - Create a new payment configuration
|
|
5560
|
+
* - `POST /{WABA_ID}/payment_configuration/{CONFIGURATION_NAME}` - Update a payment configuration
|
|
5561
|
+
* - `POST /{WABA_ID}/generate_payment_configuration_oauth_link` - Generate an OAuth link
|
|
5562
|
+
* - `DELETE /{WABA_ID}/payment_configuration` - Delete a payment configuration
|
|
5563
|
+
*
|
|
5564
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
4496
5565
|
*/
|
|
4497
5566
|
declare class PaymentsApi extends BaseAPI implements PaymentsClass {
|
|
5567
|
+
/**
|
|
5568
|
+
* List all payment configurations for a WhatsApp Business Account.
|
|
5569
|
+
*
|
|
5570
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5571
|
+
* @returns A list of all payment configurations.
|
|
5572
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5573
|
+
*/
|
|
4498
5574
|
listPaymentConfigurations(wabaId: string): Promise<PaymentConfigurationsResponse>;
|
|
5575
|
+
/**
|
|
5576
|
+
* Get a specific payment configuration by name.
|
|
5577
|
+
*
|
|
5578
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5579
|
+
* @param configurationName - The name of the payment configuration to retrieve.
|
|
5580
|
+
* @returns The payment configuration details.
|
|
5581
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5582
|
+
*/
|
|
4499
5583
|
getPaymentConfiguration(wabaId: string, configurationName: string): Promise<PaymentConfigurationsResponse>;
|
|
5584
|
+
/**
|
|
5585
|
+
* Create a new payment configuration for a WhatsApp Business Account.
|
|
5586
|
+
*
|
|
5587
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5588
|
+
* @param params - The payment configuration details to create.
|
|
5589
|
+
* @returns The created payment configuration response.
|
|
5590
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5591
|
+
*/
|
|
4500
5592
|
createPaymentConfiguration(wabaId: string, params: PaymentConfigurationCreateRequest): Promise<PaymentConfigurationCreateResponse>;
|
|
5593
|
+
/**
|
|
5594
|
+
* Update an existing payment configuration.
|
|
5595
|
+
*
|
|
5596
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5597
|
+
* @param configurationName - The name of the payment configuration to update.
|
|
5598
|
+
* @param params - The payment configuration fields to update.
|
|
5599
|
+
* @returns The updated payment configuration response.
|
|
5600
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5601
|
+
*/
|
|
4501
5602
|
updatePaymentConfiguration(wabaId: string, configurationName: string, params: PaymentConfigurationUpdateRequest): Promise<PaymentConfigurationUpdateResponse>;
|
|
5603
|
+
/**
|
|
5604
|
+
* Generate an OAuth link for payment configuration onboarding.
|
|
5605
|
+
*
|
|
5606
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5607
|
+
* @param params - The OAuth link generation parameters.
|
|
5608
|
+
* @returns The generated OAuth link response.
|
|
5609
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5610
|
+
*/
|
|
4502
5611
|
generatePaymentConfigurationOauthLink(wabaId: string, params: PaymentConfigurationOauthLinkRequest): Promise<PaymentConfigurationOauthLinkResponse>;
|
|
5612
|
+
/**
|
|
5613
|
+
* Delete a payment configuration from a WhatsApp Business Account.
|
|
5614
|
+
*
|
|
5615
|
+
* @param wabaId - The WhatsApp Business Account ID.
|
|
5616
|
+
* @param params - The payment configuration deletion parameters (includes configuration name).
|
|
5617
|
+
* @returns A success response confirming deletion.
|
|
5618
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/payments/payments-in/onboarding-apis/
|
|
5619
|
+
*/
|
|
4503
5620
|
deletePaymentConfiguration(wabaId: string, params: PaymentConfigurationDeleteRequest): Promise<ResponseSuccess>;
|
|
4504
5621
|
}
|
|
4505
5622
|
//#endregion
|
|
4506
5623
|
//#region src/api/phone/PhoneNumberApi.d.ts
|
|
4507
5624
|
/**
|
|
4508
|
-
* API for managing WhatsApp
|
|
5625
|
+
* API for managing WhatsApp Business phone numbers.
|
|
4509
5626
|
*
|
|
4510
|
-
* This API
|
|
4511
|
-
*
|
|
4512
|
-
*
|
|
4513
|
-
*
|
|
4514
|
-
* -
|
|
5627
|
+
* This API provides methods for phone number management, verification,
|
|
5628
|
+
* and conversational automation configuration within the WhatsApp Business Platform.
|
|
5629
|
+
*
|
|
5630
|
+
* Covered endpoints:
|
|
5631
|
+
* - Get phone number info by ID (`GET /{PHONE_NUMBER_ID}`)
|
|
5632
|
+
* - List all phone numbers for a WABA (`GET /{WABA_ID}/phone_numbers`)
|
|
5633
|
+
* - Request a verification code (`POST /{PHONE_NUMBER_ID}/request_code`)
|
|
5634
|
+
* - Verify a phone number with a code (`POST /{PHONE_NUMBER_ID}/verify_code`)
|
|
5635
|
+
* - Set conversational automation config (`POST /{PHONE_NUMBER_ID}/conversational_automation`)
|
|
5636
|
+
* - Get conversational automation config (`GET /{PHONE_NUMBER_ID}?fields=conversational_automation`)
|
|
5637
|
+
* - Get throughput info (`GET /{PHONE_NUMBER_ID}?fields=throughput`)
|
|
5638
|
+
*
|
|
5639
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers | Phone Numbers API Reference}
|
|
5640
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/phone-numbers/ | Phone Numbers Documentation}
|
|
4515
5641
|
*/
|
|
4516
5642
|
declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
|
|
4517
5643
|
private readonly endpoint;
|
|
4518
5644
|
/**
|
|
4519
5645
|
* Get phone number information by ID.
|
|
4520
5646
|
*
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
5647
|
+
* Retrieves details about the configured phone number, including display phone number,
|
|
5648
|
+
* verified name, quality rating, platform type, and more. Use the `fields` parameter
|
|
5649
|
+
* to request only specific fields.
|
|
5650
|
+
*
|
|
5651
|
+
* @param fields - Optional fields to include in the response. Can be a comma-separated
|
|
5652
|
+
* string (e.g., `'display_phone_number,verified_name'`) or an array of field names.
|
|
5653
|
+
* @returns A promise that resolves with the phone number information.
|
|
5654
|
+
*
|
|
5655
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#get-single | Get Phone Number}
|
|
4523
5656
|
*
|
|
4524
5657
|
* @example
|
|
5658
|
+
* ```ts
|
|
5659
|
+
* // Get all available fields
|
|
4525
5660
|
* const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById();
|
|
4526
|
-
*
|
|
5661
|
+
*
|
|
5662
|
+
* // Get specific fields as a comma-separated string
|
|
5663
|
+
* const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById(
|
|
5664
|
+
* 'display_phone_number,verified_name,quality_rating'
|
|
5665
|
+
* );
|
|
5666
|
+
*
|
|
5667
|
+
* // Get specific fields as an array
|
|
5668
|
+
* const phoneNumber = await whatsappClient.phoneNumber.getPhoneNumberById(
|
|
5669
|
+
* ['display_phone_number', 'verified_name']
|
|
5670
|
+
* );
|
|
5671
|
+
* ```
|
|
4527
5672
|
*/
|
|
4528
5673
|
getPhoneNumberById(fields?: PhoneNumberFieldsParam): Promise<PhoneNumberResponse>;
|
|
4529
5674
|
/**
|
|
4530
|
-
* Get all phone numbers
|
|
5675
|
+
* Get all phone numbers associated with the WhatsApp Business Account.
|
|
5676
|
+
*
|
|
5677
|
+
* Returns a list of all phone numbers registered under the configured WABA,
|
|
5678
|
+
* including their verification status, quality rating, and display information.
|
|
4531
5679
|
*
|
|
4532
|
-
* @returns
|
|
5680
|
+
* @returns A promise that resolves with the list of phone numbers.
|
|
5681
|
+
*
|
|
5682
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#get-all | List Phone Numbers}
|
|
4533
5683
|
*
|
|
4534
5684
|
* @example
|
|
4535
|
-
*
|
|
5685
|
+
* ```ts
|
|
5686
|
+
* const response = await whatsappClient.phoneNumber.getPhoneNumbers();
|
|
5687
|
+
* for (const number of response.data) {
|
|
5688
|
+
* console.log(number.display_phone_number, number.verified_name);
|
|
5689
|
+
* }
|
|
5690
|
+
* ```
|
|
4536
5691
|
*/
|
|
4537
5692
|
getPhoneNumbers(): Promise<PhoneNumbersResponse>;
|
|
4538
5693
|
/**
|
|
4539
5694
|
* Request a verification code for the phone number.
|
|
4540
5695
|
*
|
|
4541
|
-
*
|
|
4542
|
-
*
|
|
5696
|
+
* Sends a verification code to the configured phone number via SMS or voice call.
|
|
5697
|
+
* This is the first step of the phone number verification process.
|
|
5698
|
+
*
|
|
5699
|
+
* @param request - The verification code request parameters.
|
|
5700
|
+
* @param request.code_method - The delivery method for the code: `'SMS'` or `'VOICE'`.
|
|
5701
|
+
* @param request.language - The language code for the verification message (e.g., `'en_US'`).
|
|
5702
|
+
* @returns A promise that resolves with a success indicator.
|
|
5703
|
+
*
|
|
5704
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#request-verification-code | Request Verification Code}
|
|
4543
5705
|
*
|
|
4544
5706
|
* @example
|
|
5707
|
+
* ```ts
|
|
4545
5708
|
* await whatsappClient.phoneNumber.requestVerificationCode({
|
|
4546
|
-
*
|
|
4547
|
-
*
|
|
5709
|
+
* code_method: 'SMS',
|
|
5710
|
+
* language: 'en_US',
|
|
4548
5711
|
* });
|
|
5712
|
+
* ```
|
|
4549
5713
|
*/
|
|
4550
5714
|
requestVerificationCode(request: RequestVerificationCodeRequest): Promise<ResponseSuccess>;
|
|
4551
5715
|
/**
|
|
4552
|
-
* Verify the phone number with
|
|
5716
|
+
* Verify the phone number with a received verification code.
|
|
4553
5717
|
*
|
|
4554
|
-
*
|
|
4555
|
-
*
|
|
5718
|
+
* Completes the phone number verification process by submitting the code
|
|
5719
|
+
* received via SMS or voice call from {@link requestVerificationCode}.
|
|
5720
|
+
*
|
|
5721
|
+
* @param request - The verification request parameters.
|
|
5722
|
+
* @param request.code - The 6-digit verification code received via SMS or voice call.
|
|
5723
|
+
* @returns A promise that resolves with a success indicator.
|
|
5724
|
+
*
|
|
5725
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#verify-code | Verify Code}
|
|
4556
5726
|
*
|
|
4557
5727
|
* @example
|
|
5728
|
+
* ```ts
|
|
4558
5729
|
* await whatsappClient.phoneNumber.verifyCode({
|
|
4559
|
-
*
|
|
5730
|
+
* code: '123456',
|
|
4560
5731
|
* });
|
|
5732
|
+
* ```
|
|
4561
5733
|
*/
|
|
4562
5734
|
verifyCode(request: VerifyCodeRequest): Promise<ResponseSuccess>;
|
|
4563
5735
|
/**
|
|
4564
|
-
* Configure conversational automation features
|
|
5736
|
+
* Configure conversational automation features for the phone number.
|
|
4565
5737
|
*
|
|
4566
|
-
*
|
|
4567
|
-
*
|
|
5738
|
+
* Sets up welcome messages, ice breakers (prompts), and commands that users
|
|
5739
|
+
* see when they open a conversation with the business phone number.
|
|
4568
5740
|
*
|
|
4569
|
-
* @
|
|
4570
|
-
*
|
|
4571
|
-
*
|
|
4572
|
-
*
|
|
4573
|
-
*
|
|
5741
|
+
* @param request - The conversational automation configuration.
|
|
5742
|
+
* @param request.enable_welcome_message - Optional. Enable or disable the welcome message.
|
|
5743
|
+
* @param request.commands - Optional. Array of command objects with `command_name` and `command_description`.
|
|
5744
|
+
* @param request.prompts - Optional. Array of ice breaker prompt strings shown to users.
|
|
5745
|
+
* @returns A promise that resolves with a success indicator.
|
|
4574
5746
|
*
|
|
4575
|
-
* @
|
|
4576
|
-
* // Configure commands
|
|
4577
|
-
* await whatsappClient.phoneNumber.setConversationalAutomation({
|
|
4578
|
-
* commands: [
|
|
4579
|
-
* { command_name: 'tickets', command_description: 'Book flight tickets' },
|
|
4580
|
-
* { command_name: 'hotel', command_description: 'Book hotel' }
|
|
4581
|
-
* ]
|
|
4582
|
-
* });
|
|
5747
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/phone-numbers/ | Conversational Automation}
|
|
4583
5748
|
*
|
|
4584
5749
|
* @example
|
|
4585
|
-
*
|
|
5750
|
+
* ```ts
|
|
5751
|
+
* // Enable welcome message
|
|
4586
5752
|
* await whatsappClient.phoneNumber.setConversationalAutomation({
|
|
4587
|
-
*
|
|
5753
|
+
* enable_welcome_message: true,
|
|
4588
5754
|
* });
|
|
4589
5755
|
*
|
|
4590
|
-
*
|
|
4591
|
-
* // Configure all features
|
|
5756
|
+
* // Configure commands and ice breakers
|
|
4592
5757
|
* await whatsappClient.phoneNumber.setConversationalAutomation({
|
|
4593
|
-
*
|
|
4594
|
-
*
|
|
4595
|
-
*
|
|
4596
|
-
*
|
|
4597
|
-
*
|
|
5758
|
+
* enable_welcome_message: true,
|
|
5759
|
+
* commands: [
|
|
5760
|
+
* { command_name: 'tickets', command_description: 'Book flight tickets' },
|
|
5761
|
+
* { command_name: 'hotel', command_description: 'Book a hotel room' },
|
|
5762
|
+
* ],
|
|
5763
|
+
* prompts: ['Book a flight', 'Plan a vacation'],
|
|
4598
5764
|
* });
|
|
5765
|
+
* ```
|
|
4599
5766
|
*/
|
|
4600
5767
|
setConversationalAutomation(request: ConversationalAutomationRequest): Promise<ResponseSuccess>;
|
|
4601
5768
|
/**
|
|
4602
|
-
* Get the current configuration
|
|
5769
|
+
* Get the current conversational automation configuration for the phone number.
|
|
5770
|
+
*
|
|
5771
|
+
* Retrieves the current settings for welcome messages, ice breakers (prompts),
|
|
5772
|
+
* and commands configured on the phone number.
|
|
4603
5773
|
*
|
|
4604
|
-
* @returns
|
|
5774
|
+
* @returns A promise that resolves with the current conversational automation settings,
|
|
5775
|
+
* including welcome message status, commands, and prompts.
|
|
5776
|
+
*
|
|
5777
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/phone-numbers/ | Conversational Automation}
|
|
4605
5778
|
*
|
|
4606
5779
|
* @example
|
|
5780
|
+
* ```ts
|
|
4607
5781
|
* const config = await whatsappClient.phoneNumber.getConversationalAutomation();
|
|
4608
|
-
* console.log(config.enable_welcome_message); // true
|
|
4609
|
-
* console.log(config.commands);
|
|
4610
|
-
* console.log(config.prompts);
|
|
5782
|
+
* console.log(config.enable_welcome_message); // true or false
|
|
5783
|
+
* console.log(config.commands); // Array of command objects
|
|
5784
|
+
* console.log(config.prompts); // Array of ice breaker strings
|
|
5785
|
+
* ```
|
|
4611
5786
|
*/
|
|
4612
5787
|
getConversationalAutomation(): Promise<ConversationalAutomationResponse>;
|
|
4613
5788
|
/**
|
|
4614
5789
|
* Get the current throughput level for the phone number.
|
|
4615
5790
|
*
|
|
4616
|
-
* Throughput represents the maximum messages per second (
|
|
4617
|
-
*
|
|
4618
|
-
*
|
|
4619
|
-
*
|
|
5791
|
+
* Throughput represents the maximum messages per second (MPS) that can be
|
|
5792
|
+
* sent or received on this phone number.
|
|
5793
|
+
*
|
|
5794
|
+
* Throughput levels:
|
|
5795
|
+
* - **STANDARD**: 80 MPS (default for most numbers)
|
|
5796
|
+
* - **HIGH**: 1,000 MPS (automatic upgrade for eligible numbers)
|
|
5797
|
+
* - **NOT_APPLICABLE**: Fixed at 5 MPS (WhatsApp Business app coexistence numbers)
|
|
4620
5798
|
*
|
|
4621
|
-
* @returns
|
|
5799
|
+
* @returns A promise that resolves with the current throughput information,
|
|
5800
|
+
* including the throughput level.
|
|
5801
|
+
*
|
|
5802
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers | Phone Numbers - Throughput}
|
|
4622
5803
|
*
|
|
4623
5804
|
* @example
|
|
5805
|
+
* ```ts
|
|
4624
5806
|
* const throughput = await whatsappClient.phoneNumber.getThroughput();
|
|
4625
5807
|
* console.log(throughput.throughput.level); // 'STANDARD' | 'HIGH' | 'NOT_APPLICABLE'
|
|
5808
|
+
* ```
|
|
4626
5809
|
*/
|
|
4627
5810
|
getThroughput(): Promise<ThroughputResponse>;
|
|
4628
5811
|
}
|
|
@@ -4631,135 +5814,161 @@ declare class PhoneNumberApi extends BaseAPI implements PhoneNumberClass {
|
|
|
4631
5814
|
/**
|
|
4632
5815
|
* API for managing WhatsApp Business Profiles and profile pictures.
|
|
4633
5816
|
*
|
|
4634
|
-
*
|
|
4635
|
-
*
|
|
4636
|
-
*
|
|
4637
|
-
*
|
|
4638
|
-
*
|
|
4639
|
-
*
|
|
4640
|
-
*
|
|
5817
|
+
* Business profiles let customers see relevant information about your business,
|
|
5818
|
+
* such as a description, email, address, website, and profile picture.
|
|
5819
|
+
*
|
|
5820
|
+
* Covered endpoints:
|
|
5821
|
+
* - Get business profile (`GET /{PHONE_NUMBER_ID}/whatsapp_business_profile`)
|
|
5822
|
+
* - Update business profile (`POST /{PHONE_NUMBER_ID}/whatsapp_business_profile`)
|
|
5823
|
+
* - Create an upload session for profile pictures (`POST /app/uploads`)
|
|
5824
|
+
* - Upload file binary data (`POST /{UPLOAD_ID}`)
|
|
5825
|
+
* - Get upload handle (`GET /{UPLOAD_ID}`)
|
|
5826
|
+
*
|
|
5827
|
+
* Profile picture upload follows a three-step process:
|
|
5828
|
+
* 1. Create an upload session ({@link createUploadSession})
|
|
5829
|
+
* 2. Upload the image binary data ({@link uploadMedia})
|
|
5830
|
+
* 3. Get the upload handle ({@link getUploadHandle}) and pass it to {@link updateBusinessProfile}
|
|
5831
|
+
*
|
|
5832
|
+
* Available business profile fields: `about`, `address`, `description`, `email`,
|
|
5833
|
+
* `profile_picture_url`, `websites`, `vertical`, `messaging_product`.
|
|
5834
|
+
*
|
|
5835
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles | Business Profiles API Reference}
|
|
5836
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/business-profiles/ | Business Profiles Documentation}
|
|
4641
5837
|
*/
|
|
4642
5838
|
declare class BusinessProfileApi extends BaseAPI implements BusinessProfileClass {
|
|
4643
5839
|
private readonly endpoint;
|
|
4644
5840
|
/**
|
|
4645
|
-
* Get your
|
|
5841
|
+
* Get your WhatsApp Business profile information.
|
|
4646
5842
|
*
|
|
4647
|
-
*
|
|
4648
|
-
*
|
|
5843
|
+
* Retrieves the business profile details for the configured phone number.
|
|
5844
|
+
* You can request all fields or specify a subset using the `fields` parameter.
|
|
4649
5845
|
*
|
|
4650
|
-
* @param fields
|
|
4651
|
-
*
|
|
4652
|
-
*
|
|
5846
|
+
* @param fields - Optional fields to return. Can be a comma-separated string
|
|
5847
|
+
* (e.g., `'about,address,email'`) or an array of field names. If omitted,
|
|
5848
|
+
* all fields are returned. Available fields: `about`, `address`, `description`,
|
|
5849
|
+
* `email`, `profile_picture_url`, `websites`, `vertical`.
|
|
5850
|
+
* @returns A promise that resolves with the business profile information.
|
|
5851
|
+
*
|
|
5852
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles#get-business-profile | Get Business Profile}
|
|
4653
5853
|
*
|
|
4654
5854
|
* @example
|
|
5855
|
+
* ```ts
|
|
4655
5856
|
* // Get all business profile fields
|
|
4656
5857
|
* const profile = await whatsappClient.businessProfile.getBusinessProfile();
|
|
4657
5858
|
*
|
|
4658
|
-
* // Get specific
|
|
5859
|
+
* // Get specific fields as a string
|
|
4659
5860
|
* const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
|
|
4660
5861
|
*
|
|
4661
|
-
* //
|
|
5862
|
+
* // Get specific fields as an array
|
|
4662
5863
|
* const profile = await whatsappClient.businessProfile.getBusinessProfile(['about', 'address', 'email']);
|
|
5864
|
+
* ```
|
|
4663
5865
|
*/
|
|
4664
5866
|
getBusinessProfile(fields?: BusinessProfileFieldsParam): Promise<BusinessProfileResponse>;
|
|
4665
5867
|
/**
|
|
4666
|
-
* Update your
|
|
5868
|
+
* Update your WhatsApp Business profile.
|
|
4667
5869
|
*
|
|
4668
|
-
*
|
|
5870
|
+
* Updates one or more fields of the business profile for the configured phone number.
|
|
5871
|
+
* Only the fields included in the request body are updated; omitted fields remain unchanged.
|
|
4669
5872
|
*
|
|
4670
|
-
* @param updateRequest The
|
|
4671
|
-
*
|
|
4672
|
-
*
|
|
4673
|
-
*
|
|
4674
|
-
*
|
|
4675
|
-
*
|
|
4676
|
-
*
|
|
4677
|
-
*
|
|
4678
|
-
*
|
|
4679
|
-
* @returns
|
|
5873
|
+
* @param updateRequest - The profile fields to update.
|
|
5874
|
+
* @param updateRequest.messaging_product - Required. Must be set to `'whatsapp'`.
|
|
5875
|
+
* @param updateRequest.about - Optional. Business About text (1-139 characters).
|
|
5876
|
+
* @param updateRequest.address - Optional. Business address (max 256 characters).
|
|
5877
|
+
* @param updateRequest.description - Optional. Business description (max 512 characters).
|
|
5878
|
+
* @param updateRequest.vertical - Optional. Business industry/category.
|
|
5879
|
+
* @param updateRequest.email - Optional. Contact email address (max 128 characters).
|
|
5880
|
+
* @param updateRequest.websites - Optional. Up to 2 website URLs (max 256 characters each).
|
|
5881
|
+
* @param updateRequest.profile_picture_handle - Optional. Handle obtained from the upload process.
|
|
5882
|
+
* @returns A promise that resolves with a success indicator.
|
|
5883
|
+
*
|
|
5884
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles#update-business-profile | Update Business Profile}
|
|
4680
5885
|
*
|
|
4681
5886
|
* @example
|
|
4682
|
-
*
|
|
5887
|
+
* ```ts
|
|
4683
5888
|
* await whatsappClient.businessProfile.updateBusinessProfile({
|
|
4684
|
-
*
|
|
4685
|
-
*
|
|
4686
|
-
*
|
|
4687
|
-
*
|
|
4688
|
-
*
|
|
5889
|
+
* messaging_product: 'whatsapp',
|
|
5890
|
+
* about: 'We provide excellent service',
|
|
5891
|
+
* description: 'Your trusted partner for quality products',
|
|
5892
|
+
* email: 'contact@example.com',
|
|
5893
|
+
* websites: ['https://example.com'],
|
|
4689
5894
|
* });
|
|
5895
|
+
* ```
|
|
4690
5896
|
*/
|
|
4691
5897
|
updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
|
|
4692
5898
|
/**
|
|
4693
5899
|
* Create an upload session for a profile picture.
|
|
4694
5900
|
*
|
|
4695
|
-
* This is
|
|
5901
|
+
* This is **step 1** of the three-step profile picture upload process.
|
|
5902
|
+
* It initializes a resumable upload session on the server and returns a session ID
|
|
5903
|
+
* to use in subsequent upload calls.
|
|
4696
5904
|
*
|
|
4697
|
-
* @param fileLength
|
|
4698
|
-
* @param fileType MIME type of the file (e.g., 'image/jpeg').
|
|
4699
|
-
* @param fileName
|
|
4700
|
-
* @returns
|
|
5905
|
+
* @param fileLength - The size of the file in bytes.
|
|
5906
|
+
* @param fileType - The MIME type of the file (e.g., `'image/jpeg'`, `'image/png'`).
|
|
5907
|
+
* @param fileName - The file name with extension (e.g., `'profile.jpg'`).
|
|
5908
|
+
* @returns A promise that resolves with the upload session ID.
|
|
5909
|
+
*
|
|
5910
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles | Business Profiles - Upload}
|
|
4701
5911
|
*
|
|
4702
5912
|
* @example
|
|
4703
|
-
*
|
|
5913
|
+
* ```ts
|
|
4704
5914
|
* const session = await whatsappClient.businessProfile.createUploadSession(
|
|
4705
|
-
*
|
|
4706
|
-
*
|
|
4707
|
-
*
|
|
5915
|
+
* fileBuffer.length,
|
|
5916
|
+
* 'image/jpeg',
|
|
5917
|
+
* 'profile.jpg',
|
|
4708
5918
|
* );
|
|
4709
|
-
*
|
|
5919
|
+
* console.log(session.upload_session_id);
|
|
5920
|
+
* ```
|
|
4710
5921
|
*/
|
|
4711
5922
|
createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
|
|
4712
5923
|
/**
|
|
4713
|
-
* Upload media file to
|
|
5924
|
+
* Upload media file binary data to an upload session.
|
|
4714
5925
|
*
|
|
4715
|
-
* This is
|
|
4716
|
-
*
|
|
5926
|
+
* This is **step 2** of the three-step profile picture upload process.
|
|
5927
|
+
* Uploads the raw binary content of the image to the previously created upload session.
|
|
4717
5928
|
*
|
|
4718
|
-
* @param uploadId The upload session ID from createUploadSession
|
|
4719
|
-
* @param file The binary data of the file
|
|
4720
|
-
* @returns
|
|
5929
|
+
* @param uploadId - The upload session ID returned from {@link createUploadSession}.
|
|
5930
|
+
* @param file - The binary data of the file as a Buffer.
|
|
5931
|
+
* @returns A promise that resolves with the upload response.
|
|
5932
|
+
*
|
|
5933
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles | Business Profiles - Upload}
|
|
4721
5934
|
*
|
|
4722
5935
|
* @example
|
|
4723
|
-
*
|
|
5936
|
+
* ```ts
|
|
5937
|
+
* const fileBuffer = fs.readFileSync('profile.jpg');
|
|
4724
5938
|
* await whatsappClient.businessProfile.uploadMedia(
|
|
4725
|
-
*
|
|
4726
|
-
*
|
|
5939
|
+
* session.upload_session_id,
|
|
5940
|
+
* fileBuffer,
|
|
4727
5941
|
* );
|
|
5942
|
+
* ```
|
|
4728
5943
|
*/
|
|
4729
5944
|
uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
|
|
4730
5945
|
/**
|
|
4731
|
-
* Get the upload handle
|
|
5946
|
+
* Get the upload handle for a completed upload.
|
|
5947
|
+
*
|
|
5948
|
+
* This is **step 3** of the three-step profile picture upload process.
|
|
5949
|
+
* After uploading the file binary, retrieve the handle to use when updating
|
|
5950
|
+
* the business profile's `profile_picture_handle` field.
|
|
4732
5951
|
*
|
|
4733
|
-
*
|
|
4734
|
-
*
|
|
5952
|
+
* @param uploadId - The upload session ID returned from {@link createUploadSession}.
|
|
5953
|
+
* @returns A promise that resolves with the upload handle information.
|
|
4735
5954
|
*
|
|
4736
|
-
* @
|
|
4737
|
-
* @returns Response containing the upload handle information.
|
|
5955
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/business-profiles | Business Profiles - Upload}
|
|
4738
5956
|
*
|
|
4739
5957
|
* @example
|
|
4740
|
-
*
|
|
4741
|
-
* //
|
|
5958
|
+
* ```ts
|
|
5959
|
+
* // Complete three-step profile picture upload
|
|
4742
5960
|
* const session = await whatsappClient.businessProfile.createUploadSession(
|
|
4743
|
-
*
|
|
4744
|
-
* );
|
|
4745
|
-
*
|
|
4746
|
-
* // 2. Upload the image data
|
|
4747
|
-
* await whatsappClient.businessProfile.uploadMedia(
|
|
4748
|
-
* session.upload_session_id, fileBuffer
|
|
4749
|
-
* );
|
|
4750
|
-
*
|
|
4751
|
-
* // 3. Get the handle for the uploaded file
|
|
4752
|
-
* const handleInfo = await whatsappClient.businessProfile.getUploadHandle(
|
|
4753
|
-
* session.upload_session_id
|
|
5961
|
+
* fileBuffer.length, 'image/jpeg', 'profile.jpg',
|
|
4754
5962
|
* );
|
|
5963
|
+
* await whatsappClient.businessProfile.uploadMedia(session.upload_session_id, fileBuffer);
|
|
5964
|
+
* const handleInfo = await whatsappClient.businessProfile.getUploadHandle(session.upload_session_id);
|
|
4755
5965
|
*
|
|
4756
|
-
* //
|
|
5966
|
+
* // Use the handle to update the profile picture
|
|
4757
5967
|
* await whatsappClient.businessProfile.updateBusinessProfile({
|
|
4758
|
-
*
|
|
4759
|
-
*
|
|
4760
|
-
* vertical: BusinessVerticalEnum.RESTAURANT,
|
|
4761
|
-
* about: 'Delicious food served daily'
|
|
5968
|
+
* messaging_product: 'whatsapp',
|
|
5969
|
+
* profile_picture_handle: handleInfo.handle,
|
|
4762
5970
|
* });
|
|
5971
|
+
* ```
|
|
4763
5972
|
*/
|
|
4764
5973
|
getUploadHandle(uploadId: string): Promise<UploadHandle>;
|
|
4765
5974
|
}
|
|
@@ -4774,14 +5983,24 @@ declare class BusinessProfileApi extends BaseAPI implements BusinessProfileClass
|
|
|
4774
5983
|
* - Get specific QR code details
|
|
4775
5984
|
* - Update QR code messages
|
|
4776
5985
|
* - Delete QR codes
|
|
5986
|
+
*
|
|
5987
|
+
* Endpoints covered:
|
|
5988
|
+
* - `POST /{PHONE_NUMBER_ID}/message_qrdls` - Create a new QR code
|
|
5989
|
+
* - `GET /{PHONE_NUMBER_ID}/message_qrdls` - Get all QR codes
|
|
5990
|
+
* - `GET /{PHONE_NUMBER_ID}/message_qrdls/{QR_CODE_ID}` - Get a specific QR code
|
|
5991
|
+
* - `POST /{PHONE_NUMBER_ID}/message_qrdls/{QR_CODE_ID}` - Update a QR code
|
|
5992
|
+
* - `DELETE /{PHONE_NUMBER_ID}/message_qrdls/{QR_CODE_ID}` - Delete a QR code
|
|
5993
|
+
*
|
|
5994
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4777
5995
|
*/
|
|
4778
5996
|
declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
4779
5997
|
private readonly endpoint;
|
|
4780
5998
|
/**
|
|
4781
5999
|
* Create a new QR code with a prefilled message.
|
|
4782
6000
|
*
|
|
4783
|
-
* @param request The QR code creation request
|
|
4784
|
-
* @returns QR code information including code, deep link URL, and optional image URL
|
|
6001
|
+
* @param request - The QR code creation request containing the prefilled message and optional image format.
|
|
6002
|
+
* @returns QR code information including code, deep link URL, and optional image URL.
|
|
6003
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4785
6004
|
*
|
|
4786
6005
|
* @example
|
|
4787
6006
|
* const qrCode = await whatsappClient.qrCode.createQrCode({
|
|
@@ -4793,7 +6012,8 @@ declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
|
4793
6012
|
/**
|
|
4794
6013
|
* Get all QR codes for the current phone number.
|
|
4795
6014
|
*
|
|
4796
|
-
* @returns List of all QR codes
|
|
6015
|
+
* @returns List of all QR codes.
|
|
6016
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4797
6017
|
*
|
|
4798
6018
|
* @example
|
|
4799
6019
|
* const qrCodes = await whatsappClient.qrCode.getQrCodes();
|
|
@@ -4802,8 +6022,9 @@ declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
|
4802
6022
|
/**
|
|
4803
6023
|
* Get a specific QR code by ID.
|
|
4804
6024
|
*
|
|
4805
|
-
* @param qrCodeId The QR code ID to retrieve
|
|
4806
|
-
* @returns QR code information
|
|
6025
|
+
* @param qrCodeId - The QR code ID to retrieve.
|
|
6026
|
+
* @returns QR code information.
|
|
6027
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4807
6028
|
*
|
|
4808
6029
|
* @example
|
|
4809
6030
|
* const qrCode = await whatsappClient.qrCode.getQrCode('qr_code_123');
|
|
@@ -4812,8 +6033,9 @@ declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
|
4812
6033
|
/**
|
|
4813
6034
|
* Update an existing QR code's prefilled message.
|
|
4814
6035
|
*
|
|
4815
|
-
* @param request The QR code update request containing code and new message
|
|
4816
|
-
* @returns Updated QR code information
|
|
6036
|
+
* @param request - The QR code update request containing code and new message.
|
|
6037
|
+
* @returns Updated QR code information.
|
|
6038
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4817
6039
|
*
|
|
4818
6040
|
* @example
|
|
4819
6041
|
* const updatedQrCode = await whatsappClient.qrCode.updateQrCode({
|
|
@@ -4825,8 +6047,9 @@ declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
|
4825
6047
|
/**
|
|
4826
6048
|
* Delete a QR code.
|
|
4827
6049
|
*
|
|
4828
|
-
* @param qrCodeId The QR code ID to delete
|
|
4829
|
-
* @returns Response indicating success or failure
|
|
6050
|
+
* @param qrCodeId - The QR code ID to delete.
|
|
6051
|
+
* @returns Response indicating success or failure.
|
|
6052
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/qr-codes/
|
|
4830
6053
|
*
|
|
4831
6054
|
* @example
|
|
4832
6055
|
* await whatsappClient.qrCode.deleteQrCode('qr_code_123');
|
|
@@ -4841,14 +6064,21 @@ declare class QrCodeApi extends BaseAPI implements QrCodeClass {
|
|
|
4841
6064
|
* This API allows you to:
|
|
4842
6065
|
* - Register a WhatsApp Business Account with a PIN
|
|
4843
6066
|
* - Deregister a WhatsApp Business Account
|
|
6067
|
+
*
|
|
6068
|
+
* Endpoints covered:
|
|
6069
|
+
* - `POST /{PHONE_NUMBER_ID}/register` - Register a phone number
|
|
6070
|
+
* - `POST /{PHONE_NUMBER_ID}/deregister` - Deregister a phone number
|
|
6071
|
+
*
|
|
6072
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/registration/
|
|
4844
6073
|
*/
|
|
4845
6074
|
declare class RegistrationApi extends BaseAPI implements RegistrationClass {
|
|
4846
6075
|
/**
|
|
4847
6076
|
* Register a WhatsApp Business Account using a PIN.
|
|
4848
6077
|
*
|
|
4849
|
-
* @param pin The registration PIN received via SMS or voice call
|
|
4850
|
-
* @param dataLocalizationRegion Optional data localization region
|
|
4851
|
-
* @returns Response indicating success or failure
|
|
6078
|
+
* @param pin - The registration PIN received via SMS or voice call.
|
|
6079
|
+
* @param dataLocalizationRegion - Optional data localization region for storage compliance.
|
|
6080
|
+
* @returns Response indicating success or failure.
|
|
6081
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/registration/
|
|
4852
6082
|
*
|
|
4853
6083
|
* @example
|
|
4854
6084
|
* await whatsappClient.registration.register('123456', DataLocalizationRegionEnum.Asia);
|
|
@@ -4857,7 +6087,8 @@ declare class RegistrationApi extends BaseAPI implements RegistrationClass {
|
|
|
4857
6087
|
/**
|
|
4858
6088
|
* Deregister a WhatsApp Business Account.
|
|
4859
6089
|
*
|
|
4860
|
-
* @returns Response indicating success or failure
|
|
6090
|
+
* @returns Response indicating success or failure.
|
|
6091
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/registration/
|
|
4861
6092
|
*
|
|
4862
6093
|
* @example
|
|
4863
6094
|
* await whatsappClient.registration.deregister();
|
|
@@ -4878,12 +6109,178 @@ declare function createProductCardCarouselTemplate(options: ProductCardCarouselT
|
|
|
4878
6109
|
declare function createSPMTemplate(options: SPMTemplateOptions): TemplateRequestBody;
|
|
4879
6110
|
//#endregion
|
|
4880
6111
|
//#region src/api/template/TemplateApi.d.ts
|
|
6112
|
+
/**
|
|
6113
|
+
* WhatsApp Message Templates API client for managing message templates.
|
|
6114
|
+
*
|
|
6115
|
+
* Message templates are pre-approved message formats that businesses can use to
|
|
6116
|
+
* send notifications and customer care messages. Templates must be approved by
|
|
6117
|
+
* Meta before they can be used to send messages.
|
|
6118
|
+
*
|
|
6119
|
+
* **Covered endpoints:**
|
|
6120
|
+
* - `GET /{TEMPLATE_ID}` - Get a single template ({@link TemplateApi.getTemplate})
|
|
6121
|
+
* - `POST /{TEMPLATE_ID}` - Update an existing template ({@link TemplateApi.updateTemplate})
|
|
6122
|
+
* - `GET /{WABA_ID}/message_templates` - List all templates ({@link TemplateApi.getTemplates})
|
|
6123
|
+
* - `POST /{WABA_ID}/message_templates` - Create a new template ({@link TemplateApi.createTemplate})
|
|
6124
|
+
* - `DELETE /{WABA_ID}/message_templates` - Delete a template ({@link TemplateApi.deleteTemplate})
|
|
6125
|
+
*
|
|
6126
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates API Reference}
|
|
6127
|
+
* @see {@link https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/ | WhatsApp Templates Documentation}
|
|
6128
|
+
*
|
|
6129
|
+
* @example
|
|
6130
|
+
* ```ts
|
|
6131
|
+
* const client = new WhatsApp({ accessToken: '...', phoneNumberId: '...', businessAcctId: '...' });
|
|
6132
|
+
*
|
|
6133
|
+
* // Create a template
|
|
6134
|
+
* const template = await client.template.createTemplate({
|
|
6135
|
+
* name: 'hello_world',
|
|
6136
|
+
* language: 'en_US',
|
|
6137
|
+
* category: 'MARKETING',
|
|
6138
|
+
* components: [{ type: 'BODY', text: 'Hello {{1}}!' }],
|
|
6139
|
+
* });
|
|
6140
|
+
*
|
|
6141
|
+
* // List all templates
|
|
6142
|
+
* const templates = await client.template.getTemplates();
|
|
6143
|
+
* ```
|
|
6144
|
+
*/
|
|
4881
6145
|
declare class TemplateApi extends BaseAPI implements TemplateClass {
|
|
4882
6146
|
private readonly endpoint;
|
|
6147
|
+
/**
|
|
6148
|
+
* Retrieves a single message template by its ID.
|
|
6149
|
+
*
|
|
6150
|
+
* Returns the full template definition including name, language, status,
|
|
6151
|
+
* category, and components.
|
|
6152
|
+
*
|
|
6153
|
+
* **Endpoint:** `GET /{TEMPLATE_ID}`
|
|
6154
|
+
*
|
|
6155
|
+
* @param templateId - The unique identifier of the template to retrieve
|
|
6156
|
+
* @returns A promise resolving to the template details
|
|
6157
|
+
*
|
|
6158
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates Reference}
|
|
6159
|
+
*
|
|
6160
|
+
* @example
|
|
6161
|
+
* ```ts
|
|
6162
|
+
* const template = await client.template.getTemplate('template_id_123');
|
|
6163
|
+
* console.log(template.name); // e.g., "hello_world"
|
|
6164
|
+
* console.log(template.status); // e.g., "APPROVED"
|
|
6165
|
+
* ```
|
|
6166
|
+
*/
|
|
4883
6167
|
getTemplate(templateId: string): Promise<TemplateResponse>;
|
|
6168
|
+
/**
|
|
6169
|
+
* Updates an existing message template.
|
|
6170
|
+
*
|
|
6171
|
+
* Allows modifying template components and other properties. Note that editing
|
|
6172
|
+
* an approved template will resubmit it for review, changing its status back
|
|
6173
|
+
* to `PENDING`.
|
|
6174
|
+
*
|
|
6175
|
+
* **Endpoint:** `POST /{TEMPLATE_ID}`
|
|
6176
|
+
*
|
|
6177
|
+
* @param templateId - The unique identifier of the template to update
|
|
6178
|
+
* @param template - Partial template body containing only the fields to update
|
|
6179
|
+
* @returns A promise resolving to a success response (`{ success: true }`)
|
|
6180
|
+
*
|
|
6181
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates Reference}
|
|
6182
|
+
*
|
|
6183
|
+
* @example
|
|
6184
|
+
* ```ts
|
|
6185
|
+
* await client.template.updateTemplate('template_id_123', {
|
|
6186
|
+
* components: [{ type: 'BODY', text: 'Updated greeting: Hello {{1}}!' }],
|
|
6187
|
+
* });
|
|
6188
|
+
* ```
|
|
6189
|
+
*/
|
|
4884
6190
|
updateTemplate(templateId: string, template: Partial<TemplateRequestBody>): Promise<ResponseSuccess>;
|
|
6191
|
+
/**
|
|
6192
|
+
* Lists message templates for the WhatsApp Business Account.
|
|
6193
|
+
*
|
|
6194
|
+
* Returns a paginated list of templates, optionally filtered by query parameters
|
|
6195
|
+
* such as category, language, name, status, or quality score.
|
|
6196
|
+
*
|
|
6197
|
+
* **Endpoint:** `GET /{WABA_ID}/message_templates`
|
|
6198
|
+
*
|
|
6199
|
+
* @param params - Optional query parameters to filter results
|
|
6200
|
+
* @param params.category - Filter by template category (e.g., `'MARKETING'`, `'UTILITY'`)
|
|
6201
|
+
* @param params.content - Filter by template content
|
|
6202
|
+
* @param params.language - Filter by language code (e.g., `'en_US'`)
|
|
6203
|
+
* @param params.name - Filter by exact template name
|
|
6204
|
+
* @param params.name_or_content - Filter by name or content (search)
|
|
6205
|
+
* @param params.quality_score - Filter by quality score
|
|
6206
|
+
* @param params.status - Filter by template status (e.g., `'APPROVED'`, `'PENDING'`, `'REJECTED'`)
|
|
6207
|
+
* @returns A promise resolving to a paginated response containing an array of templates
|
|
6208
|
+
*
|
|
6209
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates Reference}
|
|
6210
|
+
*
|
|
6211
|
+
* @example
|
|
6212
|
+
* ```ts
|
|
6213
|
+
* // List all templates
|
|
6214
|
+
* const allTemplates = await client.template.getTemplates();
|
|
6215
|
+
*
|
|
6216
|
+
* // Filter by category and status
|
|
6217
|
+
* const approved = await client.template.getTemplates({
|
|
6218
|
+
* category: 'MARKETING',
|
|
6219
|
+
* status: 'APPROVED',
|
|
6220
|
+
* });
|
|
6221
|
+
* ```
|
|
6222
|
+
*/
|
|
4885
6223
|
getTemplates(params?: TemplateGetParams): Promise<ResponsePagination<TemplateResponse>>;
|
|
6224
|
+
/**
|
|
6225
|
+
* Creates a new message template for the WhatsApp Business Account.
|
|
6226
|
+
*
|
|
6227
|
+
* The template will be submitted for review. Once approved, it can be used
|
|
6228
|
+
* to send template messages via {@link MessagesApi.template}.
|
|
6229
|
+
*
|
|
6230
|
+
* **Endpoint:** `POST /{WABA_ID}/message_templates`
|
|
6231
|
+
*
|
|
6232
|
+
* @param template - The template definition
|
|
6233
|
+
* @param template.name - Template name (lowercase alphanumeric and underscores only)
|
|
6234
|
+
* @param template.language - Language code (e.g., `'en_US'`)
|
|
6235
|
+
* @param template.category - Template category (`'MARKETING'`, `'UTILITY'`, or `'AUTHENTICATION'`)
|
|
6236
|
+
* @param template.components - Array of template components (header, body, footer, buttons)
|
|
6237
|
+
* @param template.allow_category_change - Whether Meta can auto-assign a different category
|
|
6238
|
+
* @param template.parameter_format - Parameter format (`'POSITIONAL'` or `'NAMED'`)
|
|
6239
|
+
* @param template.sub_category - Optional sub-category for the template
|
|
6240
|
+
* @param template.message_send_ttl_seconds - Optional TTL in seconds for message delivery attempts
|
|
6241
|
+
* @returns A promise resolving to the created template response with its assigned `id` and `status`
|
|
6242
|
+
*
|
|
6243
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates Reference}
|
|
6244
|
+
*
|
|
6245
|
+
* @example
|
|
6246
|
+
* ```ts
|
|
6247
|
+
* const template = await client.template.createTemplate({
|
|
6248
|
+
* name: 'order_confirmation',
|
|
6249
|
+
* language: 'en_US',
|
|
6250
|
+
* category: 'UTILITY',
|
|
6251
|
+
* components: [
|
|
6252
|
+
* { type: 'BODY', text: 'Your order {{1}} has been confirmed.' },
|
|
6253
|
+
* ],
|
|
6254
|
+
* });
|
|
6255
|
+
* console.log(template.id); // Template ID
|
|
6256
|
+
* console.log(template.status); // "PENDING"
|
|
6257
|
+
* ```
|
|
6258
|
+
*/
|
|
4886
6259
|
createTemplate(template: TemplateRequestBody): Promise<TemplateResponse>;
|
|
6260
|
+
/**
|
|
6261
|
+
* Deletes a message template from the WhatsApp Business Account.
|
|
6262
|
+
*
|
|
6263
|
+
* Deleting a template removes all language variations of that template.
|
|
6264
|
+
* To delete a specific language version, provide the `hsm_id` parameter.
|
|
6265
|
+
*
|
|
6266
|
+
* **Endpoint:** `DELETE /{WABA_ID}/message_templates`
|
|
6267
|
+
*
|
|
6268
|
+
* @param params - The delete parameters
|
|
6269
|
+
* @param params.name - The name of the template to delete (required)
|
|
6270
|
+
* @param params.hsm_id - Optional template ID to delete a specific language version
|
|
6271
|
+
* @returns A promise resolving to a success response (`{ success: true }`)
|
|
6272
|
+
*
|
|
6273
|
+
* @see {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/message-templates | Message Templates Reference}
|
|
6274
|
+
*
|
|
6275
|
+
* @example
|
|
6276
|
+
* ```ts
|
|
6277
|
+
* // Delete all language versions of a template
|
|
6278
|
+
* await client.template.deleteTemplate({ name: 'old_template' });
|
|
6279
|
+
*
|
|
6280
|
+
* // Delete a specific language version
|
|
6281
|
+
* await client.template.deleteTemplate({ name: 'old_template', hsm_id: '123456' });
|
|
6282
|
+
* ```
|
|
6283
|
+
*/
|
|
4887
6284
|
deleteTemplate(params: TemplateDeleteParams): Promise<ResponseSuccess>;
|
|
4888
6285
|
}
|
|
4889
6286
|
//#endregion
|
|
@@ -4894,13 +6291,19 @@ declare class TemplateApi extends BaseAPI implements TemplateClass {
|
|
|
4894
6291
|
* This API allows you to:
|
|
4895
6292
|
* - Set a two-step verification PIN code
|
|
4896
6293
|
* - Manage two-step verification settings
|
|
6294
|
+
*
|
|
6295
|
+
* Endpoints covered:
|
|
6296
|
+
* - `POST /{PHONE_NUMBER_ID}` - Set two-step verification PIN
|
|
6297
|
+
*
|
|
6298
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/two-step-verification/
|
|
4897
6299
|
*/
|
|
4898
6300
|
declare class TwoStepVerificationApi extends BaseAPI implements TwoStepVerificationClass {
|
|
4899
6301
|
/**
|
|
4900
6302
|
* Set a two-step verification PIN code.
|
|
4901
6303
|
*
|
|
4902
|
-
* @param pin The PIN code to set for two-step verification (6-digit numeric string)
|
|
4903
|
-
* @returns Response indicating success or failure
|
|
6304
|
+
* @param pin - The PIN code to set for two-step verification (6-digit numeric string).
|
|
6305
|
+
* @returns Response indicating success or failure.
|
|
6306
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/two-step-verification/
|
|
4904
6307
|
*
|
|
4905
6308
|
* @example
|
|
4906
6309
|
* await whatsappClient.twoStepVerification.setTwoStepVerificationCode('123456');
|
|
@@ -4917,13 +6320,22 @@ declare class TwoStepVerificationApi extends BaseAPI implements TwoStepVerificat
|
|
|
4917
6320
|
* - Manage WABA subscriptions
|
|
4918
6321
|
* - Subscribe/unsubscribe from WABA webhooks
|
|
4919
6322
|
* - Update subscription settings
|
|
6323
|
+
*
|
|
6324
|
+
* Endpoints covered:
|
|
6325
|
+
* - `GET /{WABA_ID}` - Get WABA account information
|
|
6326
|
+
* - `GET /{WABA_ID}/subscribed_apps` - Get all WABA subscriptions
|
|
6327
|
+
* - `POST /{WABA_ID}/subscribed_apps` - Update/create a WABA subscription
|
|
6328
|
+
* - `DELETE /{WABA_ID}/subscribed_apps` - Unsubscribe from WABA webhooks
|
|
6329
|
+
*
|
|
6330
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/
|
|
4920
6331
|
*/
|
|
4921
6332
|
declare class WabaApi extends BaseAPI implements WABAClass {
|
|
4922
6333
|
/**
|
|
4923
6334
|
* Retrieve WhatsApp Business Account information.
|
|
4924
6335
|
*
|
|
4925
|
-
* @param fields Optional array of specific fields to retrieve
|
|
6336
|
+
* @param fields - Optional array of specific fields to retrieve.
|
|
4926
6337
|
* @returns WABA account information including status, health, verification status, etc.
|
|
6338
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/
|
|
4927
6339
|
*
|
|
4928
6340
|
* @example
|
|
4929
6341
|
* const account = await whatsappClient.waba.getWabaAccount(['id', 'name', 'status']);
|
|
@@ -4932,7 +6344,8 @@ declare class WabaApi extends BaseAPI implements WABAClass {
|
|
|
4932
6344
|
/**
|
|
4933
6345
|
* Get all WABA subscriptions for the business account.
|
|
4934
6346
|
*
|
|
4935
|
-
* @returns List of all subscribed apps and their configurations
|
|
6347
|
+
* @returns List of all subscribed apps and their configurations.
|
|
6348
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/
|
|
4936
6349
|
*
|
|
4937
6350
|
* @example
|
|
4938
6351
|
* const subscriptions = await whatsappClient.waba.getAllWabaSubscriptions();
|
|
@@ -4941,8 +6354,9 @@ declare class WabaApi extends BaseAPI implements WABAClass {
|
|
|
4941
6354
|
/**
|
|
4942
6355
|
* Update WABA subscription configuration.
|
|
4943
6356
|
*
|
|
4944
|
-
* @param params Configuration parameters including callback URI and verify token
|
|
4945
|
-
* @returns Response indicating success or failure
|
|
6357
|
+
* @param params - Configuration parameters including callback URI and verify token.
|
|
6358
|
+
* @returns Response indicating success or failure.
|
|
6359
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/
|
|
4946
6360
|
*
|
|
4947
6361
|
* @example
|
|
4948
6362
|
* await whatsappClient.waba.updateWabaSubscription({
|
|
@@ -4957,7 +6371,8 @@ declare class WabaApi extends BaseAPI implements WABAClass {
|
|
|
4957
6371
|
/**
|
|
4958
6372
|
* Unsubscribe from WABA webhooks.
|
|
4959
6373
|
*
|
|
4960
|
-
* @returns Response indicating success or failure
|
|
6374
|
+
* @returns Response indicating success or failure.
|
|
6375
|
+
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/whatsapp-business-accounts/
|
|
4961
6376
|
*
|
|
4962
6377
|
* @example
|
|
4963
6378
|
* await whatsappClient.waba.unsubscribeFromWaba();
|