- Installation
- Getting Started
- Reference
whatsappbusiness.application.getSettings
whatsappbusiness.application.listMediaProviders
whatsappbusiness.application.removeProvider
whatsappbusiness.application.resetSettings
whatsappbusiness.application.setShards
whatsappbusiness.application.updateMediaProviders
whatsappbusiness.application.updateSettings
whatsappbusiness.backupRestore.settingsPost
whatsappbusiness.backupRestore.settingsPost_0
whatsappbusiness.businessProfile.get
whatsappbusiness.businessProfile.update
whatsappbusiness.certificates.deleteWebhookCa
whatsappbusiness.certificates.downloadCaCertificate
whatsappbusiness.certificates.downloadWebhookCaCertificate
whatsappbusiness.certificates.uploadExternalCertificate
whatsappbusiness.certificates.uploadWebhookCaCertificate
whatsappbusiness.contacts.createContact
whatsappbusiness.groups.createGroup
whatsappbusiness.groups.deleteGroupIcon
whatsappbusiness.groups.deleteInvite
whatsappbusiness.groups.demoteAdmin
whatsappbusiness.groups.getAll
whatsappbusiness.groups.getIconBinary
whatsappbusiness.groups.getInfo
whatsappbusiness.groups.getInviteDetails
whatsappbusiness.groups.leaveGroup
whatsappbusiness.groups.promoteToAdmin
whatsappbusiness.groups.removeParticipant
whatsappbusiness.groups.setGroupIcon
whatsappbusiness.groups.updateInfo
whatsappbusiness.health.checkStatus
whatsappbusiness.health.getAppStats
whatsappbusiness.health.getDbStats
whatsappbusiness.health.getMetricsData
whatsappbusiness.health.getSupportInfo
whatsappbusiness.media.download
whatsappbusiness.media.removeMedia
whatsappbusiness.media.uploadMedia
whatsappbusiness.messages.markAsRead
whatsappbusiness.messages.sendMessage
whatsappbusiness.profile.getAbout
whatsappbusiness.profile.getPhoto
whatsappbusiness.profile.removePhoto
whatsappbusiness.profile.updateAbout
whatsappbusiness.profile.updatePhoto
whatsappbusiness.registration.requestCode
whatsappbusiness.registration.verifyAccount
whatsappbusiness.twoStepVerification.disable
whatsappbusiness.twoStepVerification.enableAccount
whatsappbusiness.users.createUser
whatsappbusiness.users.getByUsername
whatsappbusiness.users.performLogin
whatsappbusiness.users.performLogout
whatsappbusiness.users.removeUser
whatsappbusiness.users.updateUser
import { WhatsAppBusiness } from "whats-app-business-typescript-sdk";
const whatsappbusiness = new WhatsAppBusiness({
// Defining the base path is optional and defaults to http://whatsapp.local
// basePath: "http://whatsapp.local",
accessToken: "ACCESS_TOKEN",
});
const getSettingsResponse = await whatsappbusiness.application.getSettings();
console.log(getSettingsResponse);
Get-Application-Settings
const getSettingsResponse = await whatsappbusiness.application.getSettings();
/settings/application
GET
Get-Media-Providers
const listMediaProvidersResponse =
await whatsappbusiness.application.listMediaProviders();
/settings/application/media/providers
GET
Delete-Media-Providers
const removeProviderResponse =
await whatsappbusiness.application.removeProvider({
providerName: "providerName_example",
});
Provider Name
/settings/application/media/providers/{ProviderName}
DELETE
Reset-Application-Settings
const resetSettingsResponse =
await whatsappbusiness.application.resetSettings();
/settings/application
DELETE
Set-Shards
const setShardsResponse = await whatsappbusiness.application.setShards({
cc: "<Country Code>",
phone_number: "<Phone Number>",
pin: "<Two-Step PIN>",
shards: 32,
});
/account/shards
POST
Update-Media-Providers
const updateMediaProvidersResponse =
await whatsappbusiness.application.updateMediaProviders([
{
config: { bearer: "<Bearer Auth Token>" },
name: "<Provider Name>",
type: "www",
},
]);
/settings/application/media/providers
POST
If a field is not present in the request, no change is made to that setting. For example, if on_call_pager is not sent with the request, the existing configuration for on_call_pager is unchanged.
const updateSettingsResponse =
await whatsappbusiness.application.updateSettings({
callback_backoff_delay_ms: "3000",
callback_persist: true,
heartbeat_interval: 5,
max_callback_backoff_delay_ms: "900000",
on_call_pager: "<WA_ID of valid WhatsApp contact>",
pass_through: true,
sent_status: false,
unhealthy_interval: 30,
});
Backoff delay for a failed callback in milliseconds This setting is used to configure the amount of time the backoff delays before retrying a failed callback. The backoff delay increases linearly by this value each time a callback fails to get a HTTPS 200 OK response. The backoff delay is capped by the max_callback_backoff_delay_ms setting.
Stores callbacks on disk until they are successfully acknowledged by the Webhook or not. Restart required.
Multiconnect: Interval of the Master node monitoring of Coreapp nodes in seconds
Maximum delay for a failed callback in milliseconds
media: Media
Set to valid WhatsApp Group with users who wish to see alerts for critical errors and messages.
When true, removes messages from the local database after they are delivered to or read by the recipient. When false, saves all messages on local storage until they are explicitly deleted. When messages are sent, they are stored in a local database. This database is used as the application\'s history. Since the business keeps its own history, you can specify whether you want message pass_through or not. Restart required.
Receive a notification that a message is sent to server. When true, you will receive a message indicating that a message has been sent. If false (default), you will not receive notification.
Multiconnect: Maximum amount of seconds a Master node waits for a Coreapp node to respond to a heartbeat before considering it unhealthy and starting the failover process.
webhooks: Webhooks
/settings/application
PATCH
Backup-Settings
const settingsPostResponse = await whatsappbusiness.backupRestore.settingsPost({
password: "<Password for Backup>",
});
Used to encrypt backup data for security
/settings/backup
POST
Restore-Settings
const settingsPost_0Response =
await whatsappbusiness.backupRestore.settingsPost_0({
data: "<Data to Restore, from Backup API>",
password: "<Password for Backup>",
});
The data that was returned by the /v1/settings/backup API call
The password you used in the /v1/settings/backup API call to encrypt the backup data
/settings/restore
POST
Get-Business-Profile
const getResponse = await whatsappbusiness.businessProfile.get();
/settings/business/profile
GET
Update-Business-Profile
const updateResponse = await whatsappbusiness.businessProfile.update({
description: "<Business Profile Description>",
address: "<Business Profile Address>",
email: "<Business Profile Email>",
vertical: "<Business Profile Vertical>",
websites: ["websites_example"],
});
Description of the business Maximum of 256 characters
Address of the business Maximum of 256 characters
Email address to contact the business Maximum of 128 characters
Industry of the business Maximum of 128 characters
URLs associated with business (e.g., website, Facebook page, Instagram) Maximum of 2 websites with a maximum of 256 characters each
/settings/business/profile
POST
Delete Webhook CA Certificate
const deleteWebhookCaResponse =
await whatsappbusiness.certificates.deleteWebhookCa();
/certificates/webhooks/ca
DELETE
Download-CA-Certificate
const downloadCaCertificateResponse =
await whatsappbusiness.certificates.downloadCaCertificate();
/certificates/external/ca
GET
Download Webhook CA Certificate
const downloadWebhookCaCertificateResponse =
await whatsappbusiness.certificates.downloadWebhookCaCertificate();
/certificates/webhooks/ca
GET
Upload-Certificate
const uploadExternalCertificateResponse =
await whatsappbusiness.certificates.uploadExternalCertificate();
/certificates/external
POST
Upload Webhook CA Certificate
const uploadWebhookCaCertificateResponse =
await whatsappbusiness.certificates.uploadWebhookCaCertificate();
/certificates/webhooks/ca
POST
Check-Contact
const createContactResponse = await whatsappbusiness.contacts.createContact({
blocking: "no_wait",
contacts: ["contacts_example"],
});
Array of contact phone numbers. The numbers can be in any standard telephone number format.
Blocking determines whether the request should wait for the processing to complete (synchronous) or not (asynchronous).
/contacts
POST
Create-Group
const createGroupResponse = await whatsappbusiness.groups.createGroup({
subject: "<Group Subject>",
});
/groups
POST
Delete-Group-Icon
const deleteGroupIconResponse = await whatsappbusiness.groups.deleteGroupIcon({
groupId: "groupId_example",
File: fs.readFileSync("/path/to/file"),
});
/groups/{GroupId}/icon
DELETE
Delete-Group-Invite
const deleteInviteResponse = await whatsappbusiness.groups.deleteInvite({
groupId: "groupId_example",
});
/groups/{GroupId}/invite
DELETE
Demote-Group-Admin
const demoteAdminResponse = await whatsappbusiness.groups.demoteAdmin({
groupId: "groupId_example",
wa_ids: ["wa_ids_example"],
});
The WhatsApp IDs of the people to be added or removed as group admins
/groups/{GroupId}/admins
DELETE
Get-All-Groups
const getAllResponse = await whatsappbusiness.groups.getAll();
/groups
GET
Get-Group-Icon-Binary
const getIconBinaryResponse = await whatsappbusiness.groups.getIconBinary({
groupId: "groupId_example",
});
/groups/{GroupId}/icon
GET
Get-Group-Info
const getInfoResponse = await whatsappbusiness.groups.getInfo({
groupId: "groupId_example",
});
/groups/{GroupId}
GET
Get-Group-Invite
const getInviteDetailsResponse = await whatsappbusiness.groups.getInviteDetails(
{
groupId: "groupId_example",
}
);
/groups/{GroupId}/invite
GET
Leave-Group
const leaveGroupResponse = await whatsappbusiness.groups.leaveGroup({
groupId: "groupId_example",
});
/groups/{GroupId}/leave
POST
Promote-To-Group-Admin
const promoteToAdminResponse = await whatsappbusiness.groups.promoteToAdmin({
groupId: "groupId_example",
wa_ids: ["wa_ids_example"],
});
The WhatsApp IDs of the people to be added or removed as group admins
/groups/{GroupId}/admins
PATCH
Remove-Group-Participant
const removeParticipantResponse =
await whatsappbusiness.groups.removeParticipant({
groupId: "groupId_example",
wa_ids: ["wa_ids_example"],
});
/groups/{GroupId}/participants
DELETE
Set-Group-Icon
const setGroupIconResponse = await whatsappbusiness.groups.setGroupIcon({
groupId: "groupId_example",
File: fs.readFileSync("/path/to/file"),
});
/groups/{GroupId}/icon
POST
Update-Group-Info
const updateInfoResponse = await whatsappbusiness.groups.updateInfo({
groupId: "groupId_example",
subject: "<New Group Subject>",
});
/groups/{GroupId}
PUT
Check-Health
const checkStatusResponse = await whatsappbusiness.health.checkStatus();
/health
GET
Get-App-Stats
const getAppStatsResponse = await whatsappbusiness.health.getAppStats({});
/stats/app
GET
Get-DB-Stats
const getDbStatsResponse = await whatsappbusiness.health.getDbStats({});
/stats/db
GET
Get-Metrics (since v2.21.3)
const getMetricsDataResponse = await whatsappbusiness.health.getMetricsData({});
/metrics
GET
Get-Support-Info
const getSupportInfoResponse = await whatsappbusiness.health.getSupportInfo();
/support
GET
Download-Media
const downloadResponse = await whatsappbusiness.media.download({
mediaId: "mediaId_example",
});
/media/{MediaId}
GET
Delete-Media
const removeMediaResponse = await whatsappbusiness.media.removeMedia({
mediaId: "mediaId_example",
});
/media/{MediaId}
DELETE
Upload-Media
const uploadMediaResponse = await whatsappbusiness.media.uploadMedia();
/media
POST
Mark-Message-As-Read
const markAsReadResponse = await whatsappbusiness.messages.markAsRead({
messageID: "messageID_example",
status: "read",
});
Message ID from Webhook
/messages/{MessageID}
PUT
Send-Message
const sendMessageResponse = await whatsappbusiness.messages.sendMessage({
preview_url: true,
recipient_type: "individual",
to: "{whatsapp-id}",
type: "text",
});
When recipient_type is individual, this field is the WhatsApp ID (phone number) returned from contacts endpoint. When recipient_type is group, this field is the WhatsApp group ID.
audio: Audio
contacts: Contact
[]
document: Document
hsm: Hsm
image: Image
location: Location
Specifying preview_url in the request is optional when not including a URL in your message. To include a URL preview, set preview_url to true in the message body and make sure the URL begins with http:// or https://. For more information, see the Sending URLs in Text Messages section.
Determines whether the recipient is an individual or a group Specifying recipient_type in the request is optional when the value is individual. However, recipient_type is required when using group. If sending a text message to a group, see the Sending Group Messages documentation.
text: Text
type: MessageType
type of the message
video: Video
/messages
POST
Get-Profile-About
const getAboutResponse = await whatsappbusiness.profile.getAbout();
/settings/profile/about
GET
Get-Profile-Photo
const getPhotoResponse = await whatsappbusiness.profile.getPhoto({});
/settings/profile/photo
GET
Delete-Profile-Photo
const removePhotoResponse = await whatsappbusiness.profile.removePhoto();
/settings/profile/photo
DELETE
Update-Profile-About
const updateAboutResponse = await whatsappbusiness.profile.updateAbout({
text: "your-profile-about-text",
});
Text to display in your profile\'s About section The max length for the string is 139 characters.
/settings/profile/about
PATCH
Update-Profile-Photo
const updatePhotoResponse = await whatsappbusiness.profile.updatePhoto({
File: fs.readFileSync("/path/to/file"),
});
/settings/profile/photo
POST
Request-Code
const requestCodeResponse = await whatsappbusiness.registration.requestCode({
cc: "<Country Code>",
cert: "<Valid Cert from Business Manager>",
method: "< sms | voice >",
phone_number: "<Phone Number>",
pin: "<Two-Step Verification PIN",
});
Numerical country code for the phone number you are registering
Base64-encoded Verified Name certificate
Method of receiving your registration code
Phone number you are registering, without the country code or plus symbol (+)
Existing 6-digit PIN — This is only required when two-factor verification is enabled on this account.
/account
POST
Register-Account
const verifyAccountResponse = await whatsappbusiness.registration.verifyAccount(
{
code: "your-registration-code-received-by-sms-or-voice-call",
}
);
/account/verify
POST
Disable-Two-Step
const disableResponse = await whatsappbusiness.twoStepVerification.disable();
/settings/account/two-step
DELETE
Enable-Two-Step
const enableAccountResponse =
await whatsappbusiness.twoStepVerification.enableAccount({
pin: "your-6-digit-pin",
});
/settings/account/two-step
POST
Create-User
const createUserResponse = await whatsappbusiness.users.createUser({
password: "password",
username: "username",
});
username
password
/users
POST
Get-User
const getByUsernameResponse = await whatsappbusiness.users.getByUsername({
userUsername: "userUsername_example",
});
/users/{UserUsername}
GET
Login-User
const performLoginResponse = await whatsappbusiness.users.performLogin({
new_password: "<New Admin Password>",
});
/users/login
POST
Logout-User
const performLogoutResponse = await whatsappbusiness.users.performLogout();
/users/logout
POST
Delete-User
const removeUserResponse = await whatsappbusiness.users.removeUser({
userUsername: "userUsername_example",
});
/users/{UserUsername}
DELETE
Update-User
const updateUserResponse = await whatsappbusiness.users.updateUser({
userUsername: "userUsername_example",
password: "New Password",
});
password
/users/{UserUsername}
PUT
This TypeScript package is automatically generated by Konfig