meta-cloud-api
Version:
WhatsApp TypeScript SDK
1,699 lines (1,698 loc) • 327 kB
text/typescript
import { Agent } from "node:https";
import { IncomingHttpHeaders, IncomingMessage } from "node:http";
//#region src/types/enums.d.ts
declare namespace enums_d_exports {
export { AudioMediaTypesEnum, BusinessVerticalEnum, ButtonPositionEnum, CategoryEnum, ComponentTypesEnum, ConversationTypesEnum, CurrencyCodesEnum, DataLocalizationRegionEnum, DocumentMediaTypesEnum, HttpMethodsEnum, ImageMediaTypesEnum, InteractiveTypesEnum, LanguagesEnum, MessageTypesEnum, ParametersTypesEnum, ReferralSourceTypesEnum, RequestCodeMethodsEnum, StatusEnum, StickerMediaTypesEnum, SubTypeEnum, SystemChangeTypesEnum, TemplateStatusEnum, VideoMediaTypesEnum, WabaConfigEnum, WebhookTypesEnum };
}
declare enum CategoryEnum {
Authentication = "AUTHENTICATION",
Marketing = "MARKETING",
Utility = "UTILITY"
}
declare enum TemplateStatusEnum {
Approved = "APPROVED",
Pending = "PENDING",
Rejected = "REJECTED"
}
declare enum HttpMethodsEnum {
Get = "GET",
Post = "POST",
Put = "PUT",
Delete = "DELETE"
}
declare enum MessageTypesEnum {
Audio = "audio",
Contacts = "contacts",
Document = "document",
Image = "image",
Interactive = "interactive",
Location = "location",
Reaction = "reaction",
Sticker = "sticker",
Template = "template",
Text = "text",
Video = "video",
Button = "button",
Order = "order",
System = "system",
Unsupported = "unsupported",
Unknown = "unknown",
/**
* @deprecated Use WebhookProcessor.onStatus() instead of onMessage(MessageTypesEnum.Statuses)
*/
Statuses = "statuses",
'*' = "*"
}
declare enum ParametersTypesEnum {
Action = "ACTION",
CouponCode = "COUPON_CODE",
Currency = "CURRENCY",
DateTime = "DATE_TIME",
Document = "DOCUMENT",
ExpirationTimeMs = "EXPIRATION_TIME_MS",
Image = "IMAGE",
LimitedTimeOffer = "LIMITED_TIME_OFFER",
Location = "LOCATION",
OrderStatus = "ORDER_STATUS",
Payload = "PAYLOAD",
Product = "PRODUCT",
Text = "TEXT",
TtlMinutes = "TTL_MINUTES",
Video = "VIDEO",
WebviewInteraction = "WEBVIEW_INTERACTION",
WebviewPresentation = "WEBVIEW_PRESENTATION"
}
declare enum InteractiveTypesEnum {
Button = "button",
List = "list",
Product = "product",
ProductList = "product_list",
CatalogMessage = "catalog_message",
CallPermissionRequest = "call_permission_request",
CtaUrl = "cta_url",
Carousel = "carousel",
LocationRequest = "location_request_message",
AddressMessage = "address_message",
Flow = "flow"
}
declare enum ButtonPositionEnum {
First = 1,
Second = 2,
Third = 3,
Fourth = 4,
Fifth = 5
}
declare enum SubTypeEnum {
Catalog = "CATALOG",
CopyCode = "COPY_CODE",
Flow = "FLOW",
Mpm = "MPM",
OrderDetails = "ORDER_DETAILS",
PhoneNumber = "PHONE_NUMBER",
QuickReply = "QUICK_REPLY",
Reminder = "REMINDER",
Url = "URL",
VoiceCall = "VOICE_CALL"
}
declare enum ComponentTypesEnum {
Header = "HEADER",
Body = "BODY",
Button = "BUTTON",
Footer = "FOOTER"
}
declare enum WabaConfigEnum {
AppId = "M4D_APP_ID",
Port = "WA_PORT",
AppSecret = "M4D_APP_SECRET",
PhoneNumberId = "WA_PHONE_NUMBER_ID",
BusinessAcctId = "WA_BUSINESS_ACCOUNT_ID",
APIVersion = "CLOUD_API_VERSION",
AccessToken = "CLOUD_API_ACCESS_TOKEN",
WebhookEndpoint = "WEBHOOK_ENDPOINT",
WebhookVerificationToken = "WEBHOOK_VERIFICATION_TOKEN",
ListenerPort = "LISTENER_PORT",
MaxRetriesAfterWait = "MAX_RETRIES_AFTER_WAIT",
RequestTimeout = "REQUEST_TIMEOUT",
Debug = "DEBUG",
PrivatePem = "FLOW_API_PRIVATE_PEM",
Passphrase = "FLOW_API_PASSPHRASE"
}
declare enum ConversationTypesEnum {
BusinessInitiated = "business_initiated",
CustomerInitiated = "customer_initiated",
ReferralConversion = "referral_conversion"
}
declare enum StatusEnum {
Delivered = "delivered",
Read = "read",
Sent = "sent"
}
declare enum VideoMediaTypesEnum {
Mp4 = "video/mp4",
Threegp = "video/3gp"
}
declare enum StickerMediaTypesEnum {
Webp = "image/webp"
}
declare enum ImageMediaTypesEnum {
Jpeg = "image/jpeg",
Png = "image/png"
}
declare enum DocumentMediaTypesEnum {
Text = "text/plain",
Pdf = "application/pdf",
Ppt = "application/vnd.ms-powerpoint",
Word = "application/msword",
Excel = "application/vnd.ms-excel",
OpenDoc = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
OpenPres = "application/vnd.openxmlformats-officedocument.presentationml.presentation",
OpenSheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
declare enum AudioMediaTypesEnum {
Aac = "audio/aac",
Mp4 = "audio/mp4",
Mpeg = "audio/mpeg",
Amr = "audio/amr",
Ogg = "audio/ogg"
}
declare enum WebhookTypesEnum {
Audio = "audio",
Button = "button",
Document = "document",
Text = "text",
Image = "image",
Interactive = "interactive",
Order = "order",
Sticker = "sticker",
System = "system",
Unknown = "unknown",
Video = "video"
}
declare enum SystemChangeTypesEnum {
CustomerChangedNumber = "customer_changed_number",
CustomerIdentityChanged = "customer_identity_changed"
}
declare enum ReferralSourceTypesEnum {
Ad = "ad",
Post = "post"
}
declare enum RequestCodeMethodsEnum {
Sms = "SMS",
Voice = "VOICE"
}
declare enum LanguagesEnum {
Afrikaans = "af",
Albanian = "sq",
Arabic = "ar",
Azerbaijani = "az",
Bengali = "bn",
Bulgarian = "bg",
Catalan = "ca",
Chinese_CHN = "zh_CN",
Chinese_HKG = "zh_HK",
Chinese_TAI = "zh_TW",
Croatian = "hr",
Czech = "cs",
Danish = "da",
Dutch = "nl",
English = "en",
English_UK = "en_GB",
English_US = "en_US",
Estonian = "et",
Filipino = "fil",
Finnish = "fi",
French = "fr",
Georgian = "ka",
German = "de",
Greek = "el",
Gujarati = "gu",
Hausa = "ha",
Hebrew = "he",
Hindi = "hi",
Hungarian = "hu",
Indonesian = "id",
Irish = "ga",
Italian = "it",
Japanese = "ja",
Kannada = "kn",
Kazakh = "kk",
Kinyarwanda = "rw_RW",
Korean = "ko",
Kyrgyz_Kyrgyzstan = "ky_KG",
Lao = "lo",
Latvian = "lv",
Lithuanian = "lt",
Macedonian = "mk",
Malay = "ms",
Malayalam = "ml",
Marathi = "mr",
Norwegian = "nb",
Persian = "fa",
Polish = "pl",
Portuguese_BR = "pt_BR",
Portuguese_POR = "pt_PT",
Punjabi = "pa",
Romanian = "ro",
Russian = "ru",
Serbian = "sr",
Slovak = "sk",
Slovenian = "sl",
Spanish = "es",
Spanish_ARG = "es_AR",
Spanish_SPA = "es_ES",
Spanish_MEX = "es_MX",
Swahili = "sw",
Swedish = "sv",
Tamil = "ta",
Telugu = "te",
Thai = "th",
Turkish = "tr",
Ukrainian = "uk",
Urdu = "ur",
Uzbek = "uz",
Vietnamese = "vi",
Zulu = "zu"
}
declare enum CurrencyCodesEnum {
AFN = "AFN",
EUR = "EUR",
ALL = "ALL",
DZD = "DZD",
USD = "USD",
AOA = "AOA",
XCD = "XCD",
ARS = "ARS",
AMD = "AMD",
AWG = "AWG",
AUD = "AUD",
AZN = "AZN",
BSD = "BSD",
BHD = "BHD",
BDT = "BDT",
BBD = "BBD",
BYN = "BYN",
BZD = "BZD",
XOF = "XOF",
BMD = "BMD",
INR = "INR",
BTN = "BTN",
BOB = "BOB",
BOV = "BOV",
BAM = "BAM",
BWP = "BWP",
NOK = "NOK",
BRL = "BRL",
BND = "BND",
BGN = "BGN",
BIF = "BIF",
CVE = "CVE",
KHR = "KHR",
XAF = "XAF",
CAD = "CAD",
KYD = "KYD",
CLP = "CLP",
CLF = "CLF",
CNY = "CNY",
COP = "COP",
COU = "COU",
KMF = "KMF",
CDF = "CDF",
NZD = "NZD",
CRC = "CRC",
HRK = "HRK",
CUP = "CUP",
CUC = "CUC",
ANG = "ANG",
CZK = "CZK",
DKK = "DKK",
DJF = "DJF",
DOP = "DOP",
EGP = "EGP",
SVC = "SVC",
ERN = "ERN",
SZL = "SZL",
ETB = "ETB",
FKP = "FKP",
FJD = "FJD",
XPF = "XPF",
GMD = "GMD",
GEL = "GEL",
GHS = "GHS",
GIP = "GIP",
GTQ = "GTQ",
GBP = "GBP",
GNF = "GNF",
GYD = "GYD",
HTG = "HTG",
HNL = "HNL",
HKD = "HKD",
HUF = "HUF",
ISK = "ISK",
IDR = "IDR",
XDR = "XDR",
IRR = "IRR",
IQD = "IQD",
ILS = "ILS",
JMD = "JMD",
JPY = "JPY",
JOD = "JOD",
KZT = "KZT",
KES = "KES",
KPW = "KPW",
KRW = "KRW",
KWD = "KWD",
KGS = "KGS",
LAK = "LAK",
LBP = "LBP",
LSL = "LSL",
ZAR = "ZAR",
LRD = "LRD",
LYD = "LYD",
CHF = "CHF",
MOP = "MOP",
MKD = "MKD",
MGA = "MGA",
MWK = "MWK",
MYR = "MYR",
MVR = "MVR",
MRU = "MRU",
MUR = "MUR",
XUA = "XUA",
MXN = "MXN",
MXV = "MXV",
MDL = "MDL",
MNT = "MNT",
MAD = "MAD",
MZN = "MZN",
MMK = "MMK",
NAD = "NAD",
NPR = "NPR",
NIO = "NIO",
NGN = "NGN",
OMR = "OMR",
PKR = "PKR",
PAB = "PAB",
PGK = "PGK",
PYG = "PYG",
PEN = "PEN",
PHP = "PHP",
PLN = "PLN",
QAR = "QAR",
RON = "RON",
RUB = "RUB",
RWF = "RWF",
SHP = "SHP",
WST = "WST",
STN = "STN",
SAR = "SAR",
RSD = "RSD",
SCR = "SCR",
SLL = "SLL",
SGD = "SGD",
XSU = "XSU",
SBD = "SBD",
SOS = "SOS",
SSP = "SSP",
LKR = "LKR",
SDG = "SDG",
SRD = "SRD",
SEK = "SEK",
CHE = "CHE",
CHW = "CHW",
SYP = "SYP",
TWD = "TWD",
TJS = "TJS",
TZS = "TZS",
THB = "THB",
TOP = "TOP",
TTD = "TTD",
TND = "TND",
TRY = "TRY",
TMT = "TMT",
UGX = "UGX",
UAH = "UAH",
AED = "AED",
USN = "USN",
UYU = "UYU",
UYI = "UYI",
UYW = "UYW",
UZS = "UZS",
VUV = "VUV",
VES = "VES",
VND = "VND",
YER = "YER",
ZMW = "ZMW",
ZWL = "ZWL",
XBA = "XBA",
XBB = "XBB",
XBC = "XBC",
XBD = "XBD",
XTS = "XTS",
XXX = "XXX",
XAU = "XAU",
XPD = "XPD",
XPT = "XPT",
XAG = "XAG",
AFA = "AFA",
FIM = "FIM",
ALK = "ALK",
ADP = "ADP",
ESP = "ESP",
FRF = "FRF",
AOK = "AOK",
AON = "AON",
AOR = "AOR",
ARA = "ARA",
ARP = "ARP",
ARY = "ARY",
RUR = "RUR",
ATS = "ATS",
AYM = "AYM",
AZM = "AZM",
BYB = "BYB",
BYR = "BYR",
BEC = "BEC",
BEF = "BEF",
BEL = "BEL",
BOP = "BOP",
BAD = "BAD",
BRB = "BRB",
BRC = "BRC",
BRE = "BRE",
BRN = "BRN",
BRR = "BRR",
BGJ = "BGJ",
BGK = "BGK",
BGL = "BGL",
BUK = "BUK",
HRD = "HRD",
CYP = "CYP",
CSJ = "CSJ",
CSK = "CSK",
ECS = "ECS",
ECV = "ECV",
GQE = "GQE",
EEK = "EEK",
XEU = "XEU",
GEK = "GEK",
DDM = "DDM",
DEM = "DEM",
GHC = "GHC",
GHP = "GHP",
GRD = "GRD",
GNE = "GNE",
GNS = "GNS",
GWE = "GWE",
GWP = "GWP",
ITL = "ITL",
ISJ = "ISJ",
IEP = "IEP",
ILP = "ILP",
ILR = "ILR",
LAJ = "LAJ",
LVL = "LVL",
LVR = "LVR",
LSM = "LSM",
ZAL = "ZAL",
LTL = "LTL",
LTT = "LTT",
LUC = "LUC",
LUF = "LUF",
LUL = "LUL",
MGF = "MGF",
MVQ = "MVQ",
MLF = "MLF",
MTL = "MTL",
MTP = "MTP",
MRO = "MRO",
MXP = "MXP",
MZE = "MZE",
MZM = "MZM",
NLG = "NLG",
NIC = "NIC",
PEH = "PEH",
PEI = "PEI",
PES = "PES",
PLZ = "PLZ",
PTE = "PTE",
ROK = "ROK",
ROL = "ROL",
STD = "STD",
CSD = "CSD",
SKK = "SKK",
SIT = "SIT",
RHD = "RHD",
ESA = "ESA",
ESB = "ESB",
SDD = "SDD",
SDP = "SDP",
SRG = "SRG",
CHC = "CHC",
TJR = "TJR",
TPE = "TPE",
TRL = "TRL",
TMM = "TMM",
UGS = "UGS",
UGW = "UGW",
UAK = "UAK",
SUR = "SUR",
USS = "USS",
UYN = "UYN",
UYP = "UYP",
VEB = "VEB",
VEF = "VEF",
VNC = "VNC",
YDD = "YDD",
YUD = "YUD",
YUM = "YUM",
YUN = "YUN",
ZRN = "ZRN",
ZRZ = "ZRZ",
ZMK = "ZMK",
ZWC = "ZWC",
ZWD = "ZWD",
ZWN = "ZWN",
ZWR = "ZWR",
XFO = "XFO",
XRE = "XRE",
XFU = "XFU"
}
declare enum DataLocalizationRegionEnum {
AU = "AU",
// Australia
ID = "ID",
// Indonesia
IN = "IN",
// India
JP = "JP",
// Japan
SG = "SG",
// Singapore
KR = "KR",
// South Korea
DE = "DE",
// EU (Germany)
CH = "CH",
// Switzerland
GB = "GB",
// United Kingdom
BR = "BR",
// Brazil
BH = "BH",
// Bahrain
ZA = "ZA",
// South Africa
AE = "AE",
// United Arab Emirates
CA = "CA"
}
/**
* Business category values for WhatsApp Business Profile.
* These values map to specific strings displayed in the WhatsApp client.
*/
declare enum BusinessVerticalEnum {
/**
* Alcoholic Beverages
*/
ALCOHOL = "ALCOHOL",
/**
* Clothing and Apparel
*/
APPAREL = "APPAREL",
/**
* Automotive
*/
AUTO = "AUTO",
/**
* Beauty, Spa and Salon
*/
BEAUTY = "BEAUTY",
/**
* Education
*/
EDU = "EDU",
/**
* Entertainment
*/
ENTERTAIN = "ENTERTAIN",
/**
* Event Planning and Service
*/
EVENT_PLAN = "EVENT_PLAN",
/**
* Finance and Banking
*/
FINANCE = "FINANCE",
/**
* Public Service
*/
GOVT = "GOVT",
/**
* Food and Grocery
*/
GROCERY = "GROCERY",
/**
* Medical and Health
*/
HEALTH = "HEALTH",
/**
* Hotel and Lodging
*/
HOTEL = "HOTEL",
/**
* Non-profit
*/
NONPROFIT = "NONPROFIT",
/**
* Online Gambling & Gaming
*/
ONLINE_GAMBLING = "ONLINE_GAMBLING",
/**
* Over-the-Counter Drugs
*/
OTC_DRUGS = "OTC_DRUGS",
/**
* Other
*/
OTHER = "OTHER",
/**
* Non-Online Gambling & Gaming (E.g. Brick and mortar)
*/
PHYSICAL_GAMBLING = "PHYSICAL_GAMBLING",
/**
* Professional Services
*/
PROF_SERVICES = "PROF_SERVICES",
/**
* Restaurant
*/
RESTAURANT = "RESTAURANT",
/**
* Shopping and Retail
*/
RETAIL = "RETAIL",
/**
* Travel and Transportation
*/
TRAVEL = "TRAVEL"
}
//#endregion
//#region src/types/config.d.ts
/**
* Configuration for automatic retry behavior on throttling errors.
*
* When the WhatsApp API returns a rate limit error (WhatsAppThrottlingError),
* the SDK will automatically retry the request using exponential backoff.
*
* @example
* ```typescript
* const wa = new WhatsApp({
* accessToken: '...',
* phoneNumberId: 123,
* retry: { maxAttempts: 3, backoff: 'exponential', initialDelayMs: 1000 },
* });
* ```
*/
interface RetryConfig {
/**
* Maximum number of attempts (including the initial attempt).
* Defaults to 3.
*/
maxAttempts?: number;
/**
* Backoff strategy.
* - 'exponential': delay doubles each attempt (1s → 2s → 4s)
* - 'fixed': constant delay between attempts
* Defaults to 'exponential'.
*/
backoff?: 'exponential' | 'fixed';
/**
* Initial delay in milliseconds before the first retry.
* Defaults to 1000 (1 second).
*/
initialDelayMs?: number;
}
type WhatsAppConfig = {
accessToken: string;
appId?: string;
appSecret?: string;
phoneNumberId?: number;
businessAcctId?: string;
apiVersion?: string;
webhookEndpoint?: string;
webhookVerificationToken?: string;
listenerPort?: number;
debug?: boolean;
maxRetriesAfterWait?: number;
requestTimeout?: number;
privatePem?: string;
passphrase?: string; /** Automatic retry configuration for throttling errors. */
retry?: RetryConfig;
};
type WabaConfigType = {
/**
* The Meta for Developers business application Id for this registered application.
*/
[WabaConfigEnum.AppId]: string;
/**
* The Meta for Developers business application secret for this registered application.
*/
[WabaConfigEnum.AppSecret]: string;
/**
* The Meta for Developers phone number id used by the registered business.
*/
[WabaConfigEnum.PhoneNumberId]: number;
/**
* The Meta for Developers business id for the registered business.
*/
[WabaConfigEnum.BusinessAcctId]: string;
/**
* The version of the Cloud API being used. Starts with a "v" and follows the major number.
*/
[WabaConfigEnum.APIVersion]: string;
/**
* The access token to make calls on behalf of the signed in Meta for Developers account or business.
*/
[WabaConfigEnum.AccessToken]: string;
/**
* The endpoint path (e.g. if the value here is webhook, the webhook URL would look like http/https://{host}/webhook).
*/
[WabaConfigEnum.WebhookEndpoint]: string;
/**
* The verification token that needs to match what is sent by the Cloud API webhook in order to subscribe.
*/
[WabaConfigEnum.WebhookVerificationToken]: string;
/**
* The listener port for the webhook web server.
*/
[WabaConfigEnum.ListenerPort]: number;
/**
* To turn on global debugging of the logger to print verbose output across the APIs.
*/
[WabaConfigEnum.Debug]: boolean;
/**
* The total number of times a request should be retried after the wait period if it fails.
*/
[WabaConfigEnum.MaxRetriesAfterWait]: number;
/**
* The timeout period for a request to quit and destroy the attempt in ms.
*/
[WabaConfigEnum.RequestTimeout]: number;
/**
* The private key for the Meta for Developers business.
*/
[WabaConfigEnum.PrivatePem]: string;
/**
* The passphrase for the Meta for Developers business.
*/
[WabaConfigEnum.Passphrase]: string;
/**
* Automatic retry configuration for throttling errors.
* Passed through from WhatsAppConfig.
*/
retry?: RetryConfig;
};
//#endregion
//#region src/types/request.d.ts
type GeneralRequestBody = Record<string, unknown>;
type UrlEncodedFormBody = Record<string, string | string[]>;
interface GeneralHeaderInterface {
/**
* Authorization token. This is required for all HTTP requests made to the graph API.
* @default 'Bearer '
*/
Authorization: string;
/**
* Content type of the message being sent. This is required for all HTTP requests made to the graph API.
* @default 'application/json'
*/
'Content-Type': string;
/**
* User agent field sent in all requests. This is used to gather SDK usage metrics and help
* better triage support requests.
* @default `WA_SDK/${ SDK_version } (Node.js ${ process.version })`
*/
'User-Agent': string;
}
interface RequesterResponseInterface<T> {
json: () => Promise<T>;
}
interface ResponseSuccess {
success: boolean;
}
interface ResponseData<T> {
data: T;
}
interface ResponsePagination<T> {
data: T[];
paging: Paging;
}
interface Paging {
cursors: {
before: string;
after: string;
};
next: string;
}
/**
* Common error detail structure used in Meta API responses
* Used for individual item errors in bulk operations
*/
interface MetaErrorDetail {
message: string;
code: string;
error_data?: {
details: string;
};
}
declare class RequesterClass {
constructor(apiVersion: string, phoneNumberId: number, accessToken: string, businessAcctId: string, userAgent: string);
sendRequest: (method: HttpMethodsEnum, path: string, timeout: number, body?: GeneralRequestBody, contentType?: string, additionalHeaders?: Record<string, string>) => Promise<RequesterResponseInterface<unknown>>;
getJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: GeneralRequestBody, additionalHeaders?: Record<string, string>): Promise<T>;
sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: FormData, additionalHeaders?: Record<string, string>): Promise<T>;
sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, formData: UrlEncodedFormBody, additionalHeaders?: Record<string, string>): Promise<T>;
updateTimeout(timeout: number): void;
updateAccessToken(accessToken: string): void;
}
//#endregion
//#region src/types/base.d.ts
declare class BaseClass {
constructor(config: WabaConfigType);
}
declare class BaseAPI implements BaseClass {
protected config: WabaConfigType;
protected client: RequesterClass;
constructor(config: WabaConfigType, client: RequesterClass);
protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
protected sendFormData<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
protected sendUrlEncodedForm<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body: UrlEncodedFormBody): Promise<T>;
}
//#endregion
//#region src/api/blockUsers/types/blockUsers.d.ts
/**
* Block Users API Types
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users
*/
/**
* User object for blocking/unblocking operations
*/
type BlockUserObject = {
user: string;
};
/**
* Blocked user information in response
*/
type BlockedUserInfo = {
input: string;
wa_id: string;
};
/**
* Failed user information with error details
* Uses common MetaErrorDetail type for consistency across APIs
*/
type FailedUserInfo = BlockedUserInfo & {
errors?: MetaErrorDetail[];
};
/**
* Request body for blocking users
*/
type BlockUsersRequest = {
messaging_product: 'whatsapp';
block_users: BlockUserObject[];
};
/**
* Request body for unblocking users
*/
type UnblockUsersRequest = {
messaging_product: 'whatsapp';
block_users: BlockUserObject[];
};
/**
* Response for block/unblock operations
*/
type BlockUsersResponse = {
messaging_product: 'whatsapp';
block_users: {
added_users?: BlockedUserInfo[];
failed_users?: FailedUserInfo[];
};
};
/**
* Pagination cursors for list operations
*/
type PagingCursors = {
after?: string;
before?: string;
};
/**
* Pagination information
*/
type PagingInfo = {
cursors?: PagingCursors;
previous?: string;
next?: string;
};
/**
* List blocked users response
*/
type ListBlockedUsersResponse = {
data: Array<{
block_users: BlockedUserInfo[];
}>;
paging?: PagingInfo;
};
/**
* Query parameters for listing blocked users
*/
type ListBlockedUsersParams = {
limit?: number;
after?: string;
before?: string;
};
/**
* Block Users API Interface
*/
interface BlockUsersClass {
/**
* Block one or more WhatsApp users
* @param users - Array of phone numbers or WhatsApp IDs to block
* @returns Response with successfully blocked and failed users
* @throws Error if users have not messaged in last 24 hours
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#block-users
*/
block(users: string[]): Promise<BlockUsersResponse>;
/**
* Unblock one or more WhatsApp users
* @param users - Array of phone numbers or WhatsApp IDs to unblock
* @returns Response with successfully unblocked and failed users
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#unblock-users
*/
unblock(users: string[]): Promise<BlockUsersResponse>;
/**
* Get list of blocked WhatsApp users with pagination
* @param params - Optional pagination parameters
* @returns List of blocked users with pagination info
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/block-users#get-list-of-blocked-numbers
*/
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
}
//#endregion
//#region src/api/blockUsers/BlockUsersApi.d.ts
/**
* API for blocking and unblocking WhatsApp users.
*
* Provides methods to block, unblock, and list blocked users for your
* WhatsApp Business phone number.
*
* Limitations:
* - Can only block users that have messaged your business in the last 24 hours
* - 64k blocklist limit
*
* Endpoints covered:
* - `POST /{PHONE_NUMBER_ID}/block_users` - Block one or more users
* - `DELETE /{PHONE_NUMBER_ID}/block_users` - Unblock one or more users
* - `GET /{PHONE_NUMBER_ID}/block_users` - List blocked users with pagination
*
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
*/
declare class BlockUsersApi extends BaseAPI implements BlockUsersClass {
private readonly endpoint;
/**
* Build the request body for block/unblock operations.
*
* @param users - Array of phone numbers or WhatsApp IDs.
* @returns The formatted request body.
*/
private buildBlockUsersBody;
/**
* Block one or more WhatsApp users
* @param users - Array of phone numbers or WhatsApp IDs to block
* @returns Response with successfully blocked and failed users
* @throws Error if users have not messaged in last 24 hours
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
*
* @example
* ```typescript
* // Block single user
* const result = await client.blockUsers.block(['1234567890']);
*
* // Block multiple users
* const result = await client.blockUsers.block(['1234567890', '0987654321']);
*
* // Check results
* console.log('Blocked:', result.block_users.added_users);
* console.log('Failed:', result.block_users.failed_users);
* ```
*/
block(users: string[]): Promise<BlockUsersResponse>;
/**
* Unblock one or more WhatsApp users
* @param users - Array of phone numbers or WhatsApp IDs to unblock
* @returns Response with successfully unblocked and failed users
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
*
* @example
* ```typescript
* // Unblock single user
* const result = await client.blockUsers.unblock(['1234567890']);
*
* // Unblock multiple users
* const result = await client.blockUsers.unblock(['1234567890', '0987654321']);
*
* // Check results
* console.log('Unblocked:', result.block_users.added_users);
* console.log('Failed:', result.block_users.failed_users);
* ```
*/
unblock(users: string[]): Promise<BlockUsersResponse>;
/**
* Get list of blocked WhatsApp users with pagination
* @param params - Optional pagination parameters
* @returns List of blocked users with pagination info
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/block-users/
*
* @example
* ```typescript
* // Get first 10 blocked users
* const result = await client.blockUsers.listBlockedUsers({ limit: 10 });
*
* // Pagination with cursor
* const nextPage = await client.blockUsers.listBlockedUsers({
* limit: 10,
* after: result.paging?.cursors?.after
* });
*
* // Get all blocked users
* const allBlocked = await client.blockUsers.listBlockedUsers();
* ```
*/
listBlockedUsers(params?: ListBlockedUsersParams): Promise<ListBlockedUsersResponse>;
}
//#endregion
//#region src/api/business/types/common.d.ts
type BusinessGraphObject = Record<string, unknown>;
type BusinessFieldsParam = string[] | string;
type CursorPaginationParams = {
limit?: number;
after?: string;
before?: string;
};
type BusinessGraphListResponse<T = BusinessGraphObject> = {
data: T[];
paging?: Paging;
summary?: BusinessGraphObject;
};
type BusinessListParams = CursorPaginationParams & {
fields?: BusinessFieldsParam;
filtering?: BusinessGraphObject[] | string;
sort?: string;
};
type AddPhoneNumbersRequest = {
phone_number: string;
verified_name?: string;
[key: string]: unknown;
};
type SharePreVerifiedPhoneNumberRequest = {
preverified_id: string;
partner_business_id: string;
};
type OnboardPartnersToMMLiteRequest = {
solution_id?: string;
[key: string]: unknown;
};
type RequestPreVerifiedPhoneNumberCodeRequest = {
code_method: 'SMS' | 'VOICE';
language?: string;
[key: string]: unknown;
};
type VerifyPreVerifiedPhoneNumberCodeRequest = {
code: string;
[key: string]: unknown;
};
interface BusinessClass {
getConnectedClientBusinesses(applicationId?: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
addPhoneNumbers(businessId: string, request: AddPhoneNumbersRequest): Promise<ResponseSuccess>;
getBusinessPortfolio(businessId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
getPreVerifiedPhoneNumbers(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
getClientWhatsAppBusinessAccounts(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
onboardPartnersToMMLite(businessId: string, request: OnboardPartnersToMMLiteRequest): Promise<BusinessGraphObject>;
getOwnedWhatsAppBusinessAccounts(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
sharePreVerifiedPhoneNumber(businessId: string, request: SharePreVerifiedPhoneNumberRequest): Promise<ResponseSuccess>;
getCreditLines(businessId: string): Promise<BusinessGraphListResponse>;
getAssignedWhatsAppBusinessAccounts(userId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
getWhatsAppAccountNumberDetails(accountNumberId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
getPreVerifiedPhoneNumberDetails(preVerifiedPhoneNumberId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
deletePreVerifiedPhoneNumber(preVerifiedPhoneNumberId: string): Promise<ResponseSuccess>;
getPreVerifiedPhoneNumberPartners(preVerifiedPhoneNumberId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
requestPreVerifiedPhoneNumberCode(preVerifiedPhoneNumberId: string, request: RequestPreVerifiedPhoneNumberCodeRequest): Promise<ResponseSuccess>;
verifyPreVerifiedPhoneNumberCode(preVerifiedPhoneNumberId: string, request: VerifyPreVerifiedPhoneNumberCodeRequest): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/business/BusinessApi.d.ts
declare class BusinessApi extends BaseAPI implements BusinessClass {
private toQuery;
private fieldsQuery;
getConnectedClientBusinesses(applicationId?: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
addPhoneNumbers(businessId: string, request: AddPhoneNumbersRequest): Promise<ResponseSuccess>;
getBusinessPortfolio(businessId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
getPreVerifiedPhoneNumbers(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
getClientWhatsAppBusinessAccounts(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
onboardPartnersToMMLite(businessId: string, request: OnboardPartnersToMMLiteRequest): Promise<BusinessGraphObject>;
getOwnedWhatsAppBusinessAccounts(businessId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
sharePreVerifiedPhoneNumber(businessId: string, request: SharePreVerifiedPhoneNumberRequest): Promise<ResponseSuccess>;
getCreditLines(businessId: string): Promise<BusinessGraphListResponse>;
getAssignedWhatsAppBusinessAccounts(userId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
getWhatsAppAccountNumberDetails(accountNumberId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
getPreVerifiedPhoneNumberDetails(preVerifiedPhoneNumberId: string, fields?: BusinessFieldsParam): Promise<BusinessGraphObject>;
deletePreVerifiedPhoneNumber(preVerifiedPhoneNumberId: string): Promise<ResponseSuccess>;
getPreVerifiedPhoneNumberPartners(preVerifiedPhoneNumberId: string, params?: BusinessListParams): Promise<BusinessGraphListResponse>;
requestPreVerifiedPhoneNumberCode(preVerifiedPhoneNumberId: string, request: RequestPreVerifiedPhoneNumberCodeRequest): Promise<ResponseSuccess>;
verifyPreVerifiedPhoneNumberCode(preVerifiedPhoneNumberId: string, request: VerifyPreVerifiedPhoneNumberCodeRequest): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/calling/types/calling.d.ts
/**
* Calling API Types
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
type CallingStatus = 'ENABLED' | 'DISABLED';
type CallIconVisibility = 'DEFAULT' | 'DISABLE_ALL';
type CallbackPermissionStatus = 'ENABLED' | 'DISABLED';
type CallHoursStatus = 'ENABLED' | 'DISABLED';
type SipStatus = 'ENABLED' | 'DISABLED';
type CallHoursDay = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
type WeeklyOperatingHours = {
day_of_week: CallHoursDay;
open_time: string;
close_time: string;
};
type HolidaySchedule = {
date: string;
start_time: string;
end_time: string;
};
type CallHours = {
status: CallHoursStatus;
timezone_id: string;
weekly_operating_hours: WeeklyOperatingHours[];
holiday_schedule?: HolidaySchedule[];
};
type SipServer = {
hostname: string;
port?: number;
request_uri_user_params?: Record<string, string>;
sip_user_password?: string;
};
type SipSettings = {
status: SipStatus;
servers?: SipServer[];
};
type CallingSettings = {
status?: CallingStatus;
call_icon_visibility?: CallIconVisibility;
call_hours?: CallHours;
callback_permission_status?: CallbackPermissionStatus;
sip?: SipSettings;
};
type UpdateCallingSettingsRequest = {
calling: CallingSettings;
};
type CallingSettingsResponse = {
calling?: CallingSettings;
[key: string]: unknown;
};
type CallPermission = {
status: string;
expiration_time?: number;
};
type CallPermissionLimit = {
time_period: string;
max_allowed: number;
current_usage: number;
limit_expiration_time?: number;
};
type CallPermissionAction = {
action_name: string;
can_perform_action: boolean;
limits?: CallPermissionLimit[];
};
type CallPermissionsResponse = {
messaging_product: 'whatsapp';
permission: CallPermission;
actions?: CallPermissionAction[];
};
type CallSdpType = 'offer' | 'answer';
type CallSession = {
sdp_type: CallSdpType;
sdp: string;
};
type CallAction = 'connect' | 'pre_accept' | 'accept' | 'reject' | 'terminate';
type InitiateCallRequest = {
to: string;
session: CallSession;
biz_opaque_callback_data?: string;
};
type PreAcceptCallRequest = {
call_id: string;
session?: CallSession;
};
type AcceptCallRequest = {
call_id: string;
session?: CallSession;
biz_opaque_callback_data?: string;
};
type RejectCallRequest = {
call_id: string;
};
type TerminateCallRequest = {
call_id: string;
};
type InitiateCallResponse = {
messaging_product: 'whatsapp';
calls: Array<{
id: string;
}>;
};
type CallActionResponse = {
messaging_product: 'whatsapp';
success: boolean;
};
interface CallingClass {
updateCallingSettings(params: UpdateCallingSettingsRequest): Promise<ResponseSuccess>;
getCallingSettings(params?: {
fields?: string[] | string;
include_sip_credentials?: boolean;
}): Promise<CallingSettingsResponse>;
getCallPermissions(params: {
userWaId: string;
}): Promise<CallPermissionsResponse>;
initiateCall(params: InitiateCallRequest): Promise<InitiateCallResponse>;
preAcceptCall(params: PreAcceptCallRequest): Promise<CallActionResponse>;
acceptCall(params: AcceptCallRequest): Promise<CallActionResponse>;
rejectCall(params: RejectCallRequest): Promise<CallActionResponse>;
terminateCall(params: TerminateCallRequest): Promise<CallActionResponse>;
}
//#endregion
//#region src/api/calling/CallingApi.d.ts
/**
* API for WhatsApp Calling features.
*
* Provides methods to manage calling settings, permissions, and call lifecycle
* (initiate, pre-accept, accept, reject, terminate).
*
* Endpoints covered:
* - `POST /{PHONE_NUMBER_ID}/settings` - Update calling settings
* - `GET /{PHONE_NUMBER_ID}/settings` - Get calling settings
* - `GET /{PHONE_NUMBER_ID}/call_permissions` - Get call permissions for a user
* - `POST /{PHONE_NUMBER_ID}/calls` - Initiate, pre-accept, accept, reject, or terminate a call
*
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
declare class CallingApi extends BaseAPI implements CallingClass {
private readonly endpoint;
/**
* Update calling settings for the phone number, such as enabling/disabling calling
* or configuring SIP credentials.
*
* @param params - The calling settings to update.
* @returns A success response confirming the settings were updated.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
updateCallingSettings(params: UpdateCallingSettingsRequest): Promise<ResponseSuccess>;
/**
* Retrieve the current calling settings for the phone number.
*
* @param params - Optional query parameters to filter the response.
* @param params.fields - Specific fields to include in the response.
* @param params.include_sip_credentials - Whether to include SIP credentials in the response.
* @returns The current calling settings configuration.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
getCallingSettings(params?: {
fields?: string[] | string;
include_sip_credentials?: boolean;
}): Promise<CallingSettingsResponse>;
/**
* Get calling permissions for a specific WhatsApp user.
*
* @param params - The request parameters.
* @param params.userWaId - The WhatsApp ID of the user to check permissions for.
* @returns The call permissions for the specified user.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
getCallPermissions(params: {
userWaId: string;
}): Promise<CallPermissionsResponse>;
/**
* Initiate an outbound call to a WhatsApp user.
*
* @param params - The call initiation parameters.
* @param params.to - The recipient's WhatsApp phone number.
* @param params.session - The call session configuration.
* @param params.biz_opaque_callback_data - Optional opaque data passed back in webhooks.
* @returns The initiated call response with call ID and status.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
initiateCall(params: InitiateCallRequest): Promise<InitiateCallResponse>;
/**
* Pre-accept an incoming call, signaling readiness to connect before full acceptance.
*
* @param params - The pre-accept request parameters.
* @param params.call_id - The ID of the call to pre-accept.
* @param params.session - Optional session configuration for the call.
* @returns The call action response confirming the pre-accept.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
preAcceptCall(params: PreAcceptCallRequest): Promise<CallActionResponse>;
/**
* Accept an incoming call and establish the connection.
*
* @param params - The accept request parameters.
* @param params.call_id - The ID of the call to accept.
* @param params.session - Optional session configuration for the call.
* @param params.biz_opaque_callback_data - Optional opaque data passed back in webhooks.
* @returns The call action response confirming acceptance.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
acceptCall(params: AcceptCallRequest): Promise<CallActionResponse>;
/**
* Reject an incoming call.
*
* @param params - The reject request parameters.
* @param params.call_id - The ID of the call to reject.
* @returns The call action response confirming rejection.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
rejectCall(params: RejectCallRequest): Promise<CallActionResponse>;
/**
* Terminate an active call.
*
* @param params - The terminate request parameters.
* @param params.call_id - The ID of the call to terminate.
* @returns The call action response confirming termination.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/calling/reference/
*/
terminateCall(params: TerminateCallRequest): Promise<CallActionResponse>;
}
//#endregion
//#region src/api/commerce/types/commerce.d.ts
/**
* Commerce Settings API Types
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
*/
type CommerceSetting = {
id: string;
is_cart_enabled?: boolean;
is_catalog_visible?: boolean;
};
type CommerceSettingsResponse = {
data: CommerceSetting[];
};
type UpdateCommerceSettingsRequest = {
is_cart_enabled?: boolean;
is_catalog_visible?: boolean;
};
interface CommerceClass {
getCommerceSettings(): Promise<CommerceSettingsResponse>;
updateCommerceSettings(params: UpdateCommerceSettingsRequest): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/commerce/CommerceApi.d.ts
/**
* API for WhatsApp Commerce Settings.
*
* Provides methods to retrieve and update commerce settings such as cart
* and catalog visibility for your WhatsApp Business phone number.
*
* Endpoints covered:
* - `GET /{PHONE_NUMBER_ID}/whatsapp_commerce_settings` - Get commerce settings
* - `POST /{PHONE_NUMBER_ID}/whatsapp_commerce_settings` - Update commerce settings
*
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
*/
declare class CommerceApi extends BaseAPI implements CommerceClass {
private readonly endpoint;
/**
* Retrieve the current commerce settings for the phone number.
*
* @returns The current commerce settings including cart and catalog visibility state.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
*/
getCommerceSettings(): Promise<CommerceSettingsResponse>;
/**
* Update commerce settings for the phone number (e.g., enable/disable cart or catalog).
*
* @param params - The commerce settings to update (e.g., is_cart_enabled, is_catalog_visible).
* @returns A success response confirming the settings were updated.
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/catalogs/sell-products-and-services/set-commerce-settings/
*/
updateCommerceSettings(params: UpdateCommerceSettingsRequest): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/encryption/types/publicKey.d.ts
type EncryptionPublicKeyResponse = ResponseData<{
business_public_key: string;
business_public_key_signature_status: 'VALID' | 'MISMATCH';
}>;
//#endregion
//#region src/api/encryption/types/common.d.ts
interface EncryptionClass {
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/encryption/EncryptionApi.d.ts
/**
* API for managing WhatsApp Business Encryption keys.
*
* Provides methods to get and set the public encryption key used for
* end-to-end encrypted messaging with WhatsApp Business.
*
* Endpoints covered:
* - `GET /{PHONE_NUMBER_ID}/whatsapp_business_encryption` - Get the current public encryption key
* - `POST /{PHONE_NUMBER_ID}/whatsapp_business_encryption` - Set a new public encryption key
*
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
*/
declare class EncryptionApi extends BaseAPI implements EncryptionClass {
private readonly endpoint;
/**
* Retrieve the current public encryption key for the phone number.
*
* @returns The current public encryption key.
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
*/
getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
/**
* Set a new public encryption key for the phone number.
*
* @param businessPublicKey - The PEM-encoded public key string to set.
* @returns A success response confirming the key was set.
* @see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/whatsapp-business-encryption/
*/
setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
}
//#endregion
//#region src/api/groups/types/groups.d.ts
/**
* Groups API Types
* @see https://developers.facebook.com/documentation/business-messaging/whatsapp/groups/reference/
*/
type GroupJoinApprovalMode = 'approval_required' | 'auto_approve';
type GroupCreateRequest = {
subject: string;
description?: string;
join_approval_mode?: GroupJoinApprovalMode;
};
type GroupCreateResponse = {
messaging_product: 'whatsapp';
id: string;
invite_link?: string;
};
type GroupInfoField = 'join_approval_mode' | 'subject' | 'description' | 'suspended' | 'creation_timestamp' | 'participants' | 'total_participant_count';
type GroupInfoFieldsParam = GroupInfoField[] | string;
type GroupParticipant = {
wa_id: string;
};
type GroupInfoResponse = {
messaging_product: 'whatsapp';
id: string;
subject?: string;
description?: string;
suspended?: boolean;
creation_timestamp?: number;
participants?: GroupParticipant[];
total_participant_count?: number;
join_approval_mode?: GroupJoinApprovalMode;
};
type GroupInviteLinkResponse = {
messaging_product: 'whatsapp';
invite_link: string;
};
type GroupJoinRequest = {
join_request_id: string;
wa_id: string;
creation_timestamp: number;
};
type GroupJoinRequestError = {
code: number;
message: string;
title?: string;
error_data?: {
details?: string;
};
};
type GroupJoinRequestFailure = {
join_request_id: string;
errors: GroupJoinRequestError[];
};
type GroupJoinRequestsResponse = {
data: GroupJoinRequest[];
paging?: PagingInfo$1;
};
type GroupJoinRequestsActionResponse = {
messaging_product: 'whatsapp';
approved_join_requests?: string[];
rejected_join_requests?: string[];
failed_join_requests?: GroupJoinRequestFailure[];
errors?: GroupJoinRequestError[];
};
type GroupSummary = {
id: string;
subject: string;
created_at: number;
};
type GroupListResponse = {
data: {
groups: GroupSummary[];
};
paging?: PagingInfo$1;
};
type GroupListParams = {
limit?: number;
after?: string;
before?: string;
};
type GroupParticipantInput = {
user: string;
};
type GroupParticipantsRequest = {
participants: GroupParticipantInput[];
};
type UpdateGroupSettingsRequest = {
subject?: string;
description?: string;
profilePictureFile?: Blob | Buffer;
};
type GroupSettingsResponse = ResponseSuccess;
interface GroupsClass {
createGroup(params: GroupCreateRequest): Promise<GroupCreateResponse>;
deleteGroup(groupId: string): Promise<ResponseSuccess>;
getGroupInfo(groupId: string, fields?: GroupInfoFieldsParam): Promise<GroupInfoResponse>;
getActiveGroups(params?: GroupListParams): Promise<GroupListResponse>;
getGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
createGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
resetGroupInviteLink(groupId: string): Promise<GroupInviteLinkResponse>;
deleteGroupInviteLink(groupId: string): Promise<ResponseSuccess>;
getJoinRequests(groupId: string): Promise<GroupJoinRequestsResponse>;
approveJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
rejectJoinRequests(groupId: string, joinRequestIds: string[]): Promise<GroupJoinRequestsActionResponse>;
addParticipants(groupId: string, participants: string[]): Promise<ResponseSuccess>;
removeParticipants(groupId: string, participants: string[]): Promise<ResponseSuccess>;
updateGroupSettings(groupId: string, params: UpdateGroupSettingsRequest): Promise<GroupSettingsResponse>;
}
type PagingInfo$1 = {
cursors?: {
before?: string;
after?: string;
};
previous?: string;
next?: string;
};
//#endregion
//#region src/api/messages/types/text.d.ts
type TextObject = {
body: string;
preview_url?: boolean;
};
interface TextMessageParams extends MessageRequestParams<TextObject | string> {
previewUrl?: boolean;
}
//#endregion
//#region src/api/messages/types/template.d.ts
type LanguageObject = {
policy: 'deterministic';
code: LanguagesEnum | (string & {});
};
type ParametersObject<T extends ParametersTypesEnum> = {
type: T;
};
type SimpleTextObject$1 = {
text: string;
};
type TextParametersObject = ParametersObject<ParametersTypesEnum.Text> & SimpleTextObject$1;
type CouponCodeParametersObject = ParametersObject<ParametersTypesEnum.CouponCode> & {
coupon_code: string;
};
type CurrencyObject = {
fallback_value: string;
code: CurrencyCodesEnum;
amount_1000: number;
};
type CurrencyParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {
currency: CurrencyObject;
};
type DateTimeObject = {
fallback_value: string;
};
type DateTimeParametersObject = ParametersObject<ParametersTypesEnum.Currency> & {
date_time: DateTimeObject;
};
type DocumentMediaObject$2 = {
id?: string;
link?: string;
caption?: string;
filename?: string;
};
type ImageMediaObject$2 = {
id?: string;
link?: string;
caption?: string;
};
type VideoMediaObject$2 = {
id?: string;
link?: string;
caption?: string;
};
type DocumentParametersObject = ParametersObject<ParametersTypesEnum.Document> & DocumentMediaObject$2;
type ImageParametersObject = ParametersObject<ParametersTypesEnum.Image> & ImageMediaObject$2;
type VideoParametersObject = ParametersObject<ParametersTypesEnum.Video> & VideoMediaObject$2;
type ComponentObject<T extends ComponentTypesEnum> = {
type: T;
parameters: (CurrencyParametersObject | DateTimeParametersObject | DocumentParametersObject | ImageParametersObject | TextParametersObject | VideoParametersObject | CouponCodeParametersObject)[];
};
type ButtonComponentObject = ComponentObject<ComponentTypesEnum.Button> & {
parameters?: (TextParametersObject | PayloadParametersObject)[];
sub_type: SubTypeEnum;
index: ButtonPositionEnum;
};
type PayloadParametersObject = ParametersObject<ParametersTypesEnum.Payload> & {
payload: string;
};
type MessageTemplateObject<T extends ComponentTypesEnum> = {
name: string;
language: LanguageObject;
components?: (ComponentObject<T> | ButtonComponentObject)[];
};
type MessageTemplateRequestBody<T extends ComponentTypesEnum> = MessageRequestBody<MessageTypesEnum.Template> & MessageTemplateObject<T>;
//#endregion
//#region src/api/messages/types/media.d.ts
type MetaMediaObject = {
id: string;
link?: never;
};
type HostedMediaObject = {
id?: never;
link: string;
};
type AudioMediaObject = MetaMediaObject | HostedMediaObject;
type MetaDocumentMediaObject = MetaMediaObject & {
caption?: string;
filename?: string;
};
type HostedDocumentMediaObject = HostedMediaObject & {
caption?: string;
filename?: string;
};
type DocumentMediaObject = MetaDocumentMediaObject | HostedDocumentMediaObject;
type MetaImageMediaObject = MetaMediaObject & {
caption?: string;
};
type HostedImageMediaObject = HostedMediaObject & {
caption?: string;
};
type ImageMediaObject = MetaImageMediaObject | HostedImageMediaObject;
type MetaVideoMediaObject = MetaMediaObject & {
caption?: string;
};
type HostedVideoMediaObject = HostedMediaObject & {