Skip to content

Use WhatsApp Messenger to stay in touch with friends and family. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world. WhatsApp's TypeScript SDK for Business API generated by Konfig (https://konfigthis.com/).

Notifications You must be signed in to change notification settings

konfig-sdks/whats-app-business-typescript-sdk

Repository files navigation

Table of Contents

Installation

Getting Started

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);

Reference

whatsappbusiness.application.getSettings

Get-Application-Settings

🛠️ Usage

const getSettingsResponse = await whatsappbusiness.application.getSettings();

🔄 Return

ApplicationSettings

🌐 Endpoint

/settings/application GET

🔙 Back to Table of Contents


whatsappbusiness.application.listMediaProviders

Get-Media-Providers

🛠️ Usage

const listMediaProvidersResponse =
  await whatsappbusiness.application.listMediaProviders();

🔄 Return

GetMediaProvidersResponse

🌐 Endpoint

/settings/application/media/providers GET

🔙 Back to Table of Contents


whatsappbusiness.application.removeProvider

Delete-Media-Providers

🛠️ Usage

const removeProviderResponse =
  await whatsappbusiness.application.removeProvider({
    providerName: "providerName_example",
  });

⚙️ Parameters

providerName: string

Provider Name

🌐 Endpoint

/settings/application/media/providers/{ProviderName} DELETE

🔙 Back to Table of Contents


whatsappbusiness.application.resetSettings

Reset-Application-Settings

🛠️ Usage

const resetSettingsResponse =
  await whatsappbusiness.application.resetSettings();

🌐 Endpoint

/settings/application DELETE

🔙 Back to Table of Contents


whatsappbusiness.application.setShards

Set-Shards

🛠️ Usage

const setShardsResponse = await whatsappbusiness.application.setShards({
  cc: "<Country Code>",
  phone_number: "<Phone Number>",
  pin: "<Two-Step PIN>",
  shards: 32,
});

⚙️ Parameters

cc: string
phone_number: string
pin: string
shards: number

🌐 Endpoint

/account/shards POST

🔙 Back to Table of Contents


whatsappbusiness.application.updateMediaProviders

Update-Media-Providers

🛠️ Usage

const updateMediaProvidersResponse =
  await whatsappbusiness.application.updateMediaProviders([
    {
      config: { bearer: "<Bearer Auth Token>" },
      name: "<Provider Name>",
      type: "www",
    },
  ]);

⚙️ Request Body

MediaProvider[]

🌐 Endpoint

/settings/application/media/providers POST

🔙 Back to Table of Contents


whatsappbusiness.application.updateSettings

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.

🛠️ Usage

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,
  });

⚙️ Parameters

callback_backoff_delay_ms: string

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.

callback_persist: boolean

Stores callbacks on disk until they are successfully acknowledged by the Webhook or not. Restart required.

heartbeat_interval: number

Multiconnect: Interval of the Master node monitoring of Coreapp nodes in seconds

max_callback_backoff_delay_ms: string

Maximum delay for a failed callback in milliseconds

media: Media
on_call_pager: string

Set to valid WhatsApp Group with users who wish to see alerts for critical errors and messages.

pass_through: boolean

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.

sent_status: boolean

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.

unhealthy_interval: number

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

🔄 Return

Response

🌐 Endpoint

/settings/application PATCH

🔙 Back to Table of Contents


whatsappbusiness.backupRestore.settingsPost

Backup-Settings

🛠️ Usage

const settingsPostResponse = await whatsappbusiness.backupRestore.settingsPost({
  password: "<Password for Backup>",
});

⚙️ Parameters

password: string

Used to encrypt backup data for security

🔄 Return

BackupSettingsResponse

🌐 Endpoint

/settings/backup POST

🔙 Back to Table of Contents


whatsappbusiness.backupRestore.settingsPost_0

Restore-Settings

🛠️ Usage

const settingsPost_0Response =
  await whatsappbusiness.backupRestore.settingsPost_0({
    data: "<Data to Restore, from Backup API>",
    password: "<Password for Backup>",
  });

⚙️ Parameters

data: string

The data that was returned by the /v1/settings/backup API call

password: string

The password you used in the /v1/settings/backup API call to encrypt the backup data

🌐 Endpoint

/settings/restore POST

🔙 Back to Table of Contents


whatsappbusiness.businessProfile.get

Get-Business-Profile

🛠️ Usage

const getResponse = await whatsappbusiness.businessProfile.get();

🔄 Return

GetBusinessProfileResponse

🌐 Endpoint

/settings/business/profile GET

🔙 Back to Table of Contents


whatsappbusiness.businessProfile.update

Update-Business-Profile

🛠️ Usage

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"],
});

⚙️ Parameters

description: string

Description of the business Maximum of 256 characters

address: string

Address of the business Maximum of 256 characters

email: string

Email address to contact the business Maximum of 128 characters

vertical: string

Industry of the business Maximum of 128 characters

websites: string[]

URLs associated with business (e.g., website, Facebook page, Instagram) Maximum of 2 websites with a maximum of 256 characters each

🌐 Endpoint

/settings/business/profile POST

🔙 Back to Table of Contents


whatsappbusiness.certificates.deleteWebhookCa

Delete Webhook CA Certificate

🛠️ Usage

const deleteWebhookCaResponse =
  await whatsappbusiness.certificates.deleteWebhookCa();

🌐 Endpoint

/certificates/webhooks/ca DELETE

🔙 Back to Table of Contents


whatsappbusiness.certificates.downloadCaCertificate

Download-CA-Certificate

🛠️ Usage

const downloadCaCertificateResponse =
  await whatsappbusiness.certificates.downloadCaCertificate();

🌐 Endpoint

/certificates/external/ca GET

🔙 Back to Table of Contents


whatsappbusiness.certificates.downloadWebhookCaCertificate

Download Webhook CA Certificate

🛠️ Usage

const downloadWebhookCaCertificateResponse =
  await whatsappbusiness.certificates.downloadWebhookCaCertificate();

🌐 Endpoint

/certificates/webhooks/ca GET

🔙 Back to Table of Contents


whatsappbusiness.certificates.uploadExternalCertificate

Upload-Certificate

🛠️ Usage

const uploadExternalCertificateResponse =
  await whatsappbusiness.certificates.uploadExternalCertificate();

🌐 Endpoint

/certificates/external POST

🔙 Back to Table of Contents


whatsappbusiness.certificates.uploadWebhookCaCertificate

Upload Webhook CA Certificate

🛠️ Usage

const uploadWebhookCaCertificateResponse =
  await whatsappbusiness.certificates.uploadWebhookCaCertificate();

🌐 Endpoint

/certificates/webhooks/ca POST

🔙 Back to Table of Contents


whatsappbusiness.contacts.createContact

Check-Contact

🛠️ Usage

const createContactResponse = await whatsappbusiness.contacts.createContact({
  blocking: "no_wait",
  contacts: ["contacts_example"],
});

⚙️ Parameters

contacts: string[]

Array of contact phone numbers. The numbers can be in any standard telephone number format.

blocking: string

Blocking determines whether the request should wait for the processing to complete (synchronous) or not (asynchronous).

🔄 Return

CheckContactResponse

🌐 Endpoint

/contacts POST

🔙 Back to Table of Contents


whatsappbusiness.groups.createGroup

Create-Group

🛠️ Usage

const createGroupResponse = await whatsappbusiness.groups.createGroup({
  subject: "<Group Subject>",
});

⚙️ Parameters

subject: string

🔄 Return

GroupsResponse

🌐 Endpoint

/groups POST

🔙 Back to Table of Contents


whatsappbusiness.groups.deleteGroupIcon

Delete-Group-Icon

🛠️ Usage

const deleteGroupIconResponse = await whatsappbusiness.groups.deleteGroupIcon({
  groupId: "groupId_example",
  File: fs.readFileSync("/path/to/file"),
});

⚙️ Parameters

groupId: string
file: Uint8Array | File | buffer.File

🌐 Endpoint

/groups/{GroupId}/icon DELETE

🔙 Back to Table of Contents


whatsappbusiness.groups.deleteInvite

Delete-Group-Invite

🛠️ Usage

const deleteInviteResponse = await whatsappbusiness.groups.deleteInvite({
  groupId: "groupId_example",
});

⚙️ Parameters

groupId: string

🌐 Endpoint

/groups/{GroupId}/invite DELETE

🔙 Back to Table of Contents


whatsappbusiness.groups.demoteAdmin

Demote-Group-Admin

🛠️ Usage

const demoteAdminResponse = await whatsappbusiness.groups.demoteAdmin({
  groupId: "groupId_example",
  wa_ids: ["wa_ids_example"],
});

⚙️ Parameters

wa_ids: string[]

The WhatsApp IDs of the people to be added or removed as group admins

groupId: string

🌐 Endpoint

/groups/{GroupId}/admins DELETE

🔙 Back to Table of Contents


whatsappbusiness.groups.getAll

Get-All-Groups

🛠️ Usage

const getAllResponse = await whatsappbusiness.groups.getAll();

🔄 Return

GroupsResponse

🌐 Endpoint

/groups GET

🔙 Back to Table of Contents


whatsappbusiness.groups.getIconBinary

Get-Group-Icon-Binary

🛠️ Usage

const getIconBinaryResponse = await whatsappbusiness.groups.getIconBinary({
  groupId: "groupId_example",
});

⚙️ Parameters

groupId: string

🌐 Endpoint

/groups/{GroupId}/icon GET

🔙 Back to Table of Contents


whatsappbusiness.groups.getInfo

Get-Group-Info

🛠️ Usage

const getInfoResponse = await whatsappbusiness.groups.getInfo({
  groupId: "groupId_example",
});

⚙️ Parameters

groupId: string

🔄 Return

GroupResponse

🌐 Endpoint

/groups/{GroupId} GET

🔙 Back to Table of Contents


whatsappbusiness.groups.getInviteDetails

Get-Group-Invite

🛠️ Usage

const getInviteDetailsResponse = await whatsappbusiness.groups.getInviteDetails(
  {
    groupId: "groupId_example",
  }
);

⚙️ Parameters

groupId: string

🔄 Return

GroupInviteResponse

🌐 Endpoint

/groups/{GroupId}/invite GET

🔙 Back to Table of Contents


whatsappbusiness.groups.leaveGroup

Leave-Group

🛠️ Usage

const leaveGroupResponse = await whatsappbusiness.groups.leaveGroup({
  groupId: "groupId_example",
});

⚙️ Parameters

groupId: string

🌐 Endpoint

/groups/{GroupId}/leave POST

🔙 Back to Table of Contents


whatsappbusiness.groups.promoteToAdmin

Promote-To-Group-Admin

🛠️ Usage

const promoteToAdminResponse = await whatsappbusiness.groups.promoteToAdmin({
  groupId: "groupId_example",
  wa_ids: ["wa_ids_example"],
});

⚙️ Parameters

wa_ids: string[]

The WhatsApp IDs of the people to be added or removed as group admins

groupId: string

🌐 Endpoint

/groups/{GroupId}/admins PATCH

🔙 Back to Table of Contents


whatsappbusiness.groups.removeParticipant

Remove-Group-Participant

🛠️ Usage

const removeParticipantResponse =
  await whatsappbusiness.groups.removeParticipant({
    groupId: "groupId_example",
    wa_ids: ["wa_ids_example"],
  });

⚙️ Parameters

wa_ids: string[]
groupId: string

🌐 Endpoint

/groups/{GroupId}/participants DELETE

🔙 Back to Table of Contents


whatsappbusiness.groups.setGroupIcon

Set-Group-Icon

🛠️ Usage

const setGroupIconResponse = await whatsappbusiness.groups.setGroupIcon({
  groupId: "groupId_example",
  File: fs.readFileSync("/path/to/file"),
});

⚙️ Parameters

groupId: string
file: Uint8Array | File | buffer.File

🌐 Endpoint

/groups/{GroupId}/icon POST

🔙 Back to Table of Contents


whatsappbusiness.groups.updateInfo

Update-Group-Info

🛠️ Usage

const updateInfoResponse = await whatsappbusiness.groups.updateInfo({
  groupId: "groupId_example",
  subject: "<New Group Subject>",
});

⚙️ Parameters

subject: string
groupId: string

🌐 Endpoint

/groups/{GroupId} PUT

🔙 Back to Table of Contents


whatsappbusiness.health.checkStatus

Check-Health

🛠️ Usage

const checkStatusResponse = await whatsappbusiness.health.checkStatus();

🌐 Endpoint

/health GET

🔙 Back to Table of Contents


whatsappbusiness.health.getAppStats

Get-App-Stats

🛠️ Usage

const getAppStatsResponse = await whatsappbusiness.health.getAppStats({});

⚙️ Parameters

format: string

🌐 Endpoint

/stats/app GET

🔙 Back to Table of Contents


whatsappbusiness.health.getDbStats

Get-DB-Stats

🛠️ Usage

const getDbStatsResponse = await whatsappbusiness.health.getDbStats({});

⚙️ Parameters

format: string

🌐 Endpoint

/stats/db GET

🔙 Back to Table of Contents


whatsappbusiness.health.getMetricsData

Get-Metrics (since v2.21.3)

🛠️ Usage

const getMetricsDataResponse = await whatsappbusiness.health.getMetricsData({});

⚙️ Parameters

format: string

🌐 Endpoint

/metrics GET

🔙 Back to Table of Contents


whatsappbusiness.health.getSupportInfo

Get-Support-Info

🛠️ Usage

const getSupportInfoResponse = await whatsappbusiness.health.getSupportInfo();

🌐 Endpoint

/support GET

🔙 Back to Table of Contents


whatsappbusiness.media.download

Download-Media

🛠️ Usage

const downloadResponse = await whatsappbusiness.media.download({
  mediaId: "mediaId_example",
});

⚙️ Parameters

mediaId: string

🌐 Endpoint

/media/{MediaId} GET

🔙 Back to Table of Contents


whatsappbusiness.media.removeMedia

Delete-Media

🛠️ Usage

const removeMediaResponse = await whatsappbusiness.media.removeMedia({
  mediaId: "mediaId_example",
});

⚙️ Parameters

mediaId: string

🌐 Endpoint

/media/{MediaId} DELETE

🔙 Back to Table of Contents


whatsappbusiness.media.uploadMedia

Upload-Media

🛠️ Usage

const uploadMediaResponse = await whatsappbusiness.media.uploadMedia();

🔄 Return

UploadMediaResponse

🌐 Endpoint

/media POST

🔙 Back to Table of Contents


whatsappbusiness.messages.markAsRead

Mark-Message-As-Read

🛠️ Usage

const markAsReadResponse = await whatsappbusiness.messages.markAsRead({
  messageID: "messageID_example",
  status: "read",
});

⚙️ Parameters

status: string
messageID: string

Message ID from Webhook

🌐 Endpoint

/messages/{MessageID} PUT

🔙 Back to Table of Contents


whatsappbusiness.messages.sendMessage

Send-Message

🛠️ Usage

const sendMessageResponse = await whatsappbusiness.messages.sendMessage({
  preview_url: true,
  recipient_type: "individual",
  to: "{whatsapp-id}",
  type: "text",
});

⚙️ Parameters

to: string

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
preview_url: boolean

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.

recipient_type: string

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
ttl: object

type of the message

video: Video

🔄 Return

MessageResponse

🌐 Endpoint

/messages POST

🔙 Back to Table of Contents


whatsappbusiness.profile.getAbout

Get-Profile-About

🛠️ Usage

const getAboutResponse = await whatsappbusiness.profile.getAbout();

🔄 Return

GetProfileAboutResponse

🌐 Endpoint

/settings/profile/about GET

🔙 Back to Table of Contents


whatsappbusiness.profile.getPhoto

Get-Profile-Photo

🛠️ Usage

const getPhotoResponse = await whatsappbusiness.profile.getPhoto({});

⚙️ Parameters

format: string

🔄 Return

GetProfilePhotoResponse

🌐 Endpoint

/settings/profile/photo GET

🔙 Back to Table of Contents


whatsappbusiness.profile.removePhoto

Delete-Profile-Photo

🛠️ Usage

const removePhotoResponse = await whatsappbusiness.profile.removePhoto();

🌐 Endpoint

/settings/profile/photo DELETE

🔙 Back to Table of Contents


whatsappbusiness.profile.updateAbout

Update-Profile-About

🛠️ Usage

const updateAboutResponse = await whatsappbusiness.profile.updateAbout({
  text: "your-profile-about-text",
});

⚙️ Parameters

text: string

Text to display in your profile\'s About section The max length for the string is 139 characters.

🌐 Endpoint

/settings/profile/about PATCH

🔙 Back to Table of Contents


whatsappbusiness.profile.updatePhoto

Update-Profile-Photo

🛠️ Usage

const updatePhotoResponse = await whatsappbusiness.profile.updatePhoto({
  File: fs.readFileSync("/path/to/file"),
});

⚙️ Parameters

file: Uint8Array | File | buffer.File

🌐 Endpoint

/settings/profile/photo POST

🔙 Back to Table of Contents


whatsappbusiness.registration.requestCode

Request-Code

🛠️ Usage

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",
});

⚙️ Parameters

cc: string

Numerical country code for the phone number you are registering

cert: string

Base64-encoded Verified Name certificate

method: string

Method of receiving your registration code

phone_number: string

Phone number you are registering, without the country code or plus symbol (+)

pin: string

Existing 6-digit PIN — This is only required when two-factor verification is enabled on this account.

🌐 Endpoint

/account POST

🔙 Back to Table of Contents


whatsappbusiness.registration.verifyAccount

Register-Account

🛠️ Usage

const verifyAccountResponse = await whatsappbusiness.registration.verifyAccount(
  {
    code: "your-registration-code-received-by-sms-or-voice-call",
  }
);

⚙️ Parameters

code: string

🌐 Endpoint

/account/verify POST

🔙 Back to Table of Contents


whatsappbusiness.twoStepVerification.disable

Disable-Two-Step

🛠️ Usage

const disableResponse = await whatsappbusiness.twoStepVerification.disable();

🌐 Endpoint

/settings/account/two-step DELETE

🔙 Back to Table of Contents


whatsappbusiness.twoStepVerification.enableAccount

Enable-Two-Step

🛠️ Usage

const enableAccountResponse =
  await whatsappbusiness.twoStepVerification.enableAccount({
    pin: "your-6-digit-pin",
  });

⚙️ Parameters

pin: string

🌐 Endpoint

/settings/account/two-step POST

🔙 Back to Table of Contents


whatsappbusiness.users.createUser

Create-User

🛠️ Usage

const createUserResponse = await whatsappbusiness.users.createUser({
  password: "password",
  username: "username",
});

⚙️ Parameters

password: string

username

username: string

password

🔄 Return

UserResponse

🌐 Endpoint

/users POST

🔙 Back to Table of Contents


whatsappbusiness.users.getByUsername

Get-User

🛠️ Usage

const getByUsernameResponse = await whatsappbusiness.users.getByUsername({
  userUsername: "userUsername_example",
});

⚙️ Parameters

userUsername: string

🔄 Return

DetailedUserResponse

🌐 Endpoint

/users/{UserUsername} GET

🔙 Back to Table of Contents


whatsappbusiness.users.performLogin

Login-User

🛠️ Usage

const performLoginResponse = await whatsappbusiness.users.performLogin({
  new_password: "<New Admin Password>",
});

⚙️ Parameters

new_password: string

🔄 Return

UserLoginResponse

🌐 Endpoint

/users/login POST

🔙 Back to Table of Contents


whatsappbusiness.users.performLogout

Logout-User

🛠️ Usage

const performLogoutResponse = await whatsappbusiness.users.performLogout();

🌐 Endpoint

/users/logout POST

🔙 Back to Table of Contents


whatsappbusiness.users.removeUser

Delete-User

🛠️ Usage

const removeUserResponse = await whatsappbusiness.users.removeUser({
  userUsername: "userUsername_example",
});

⚙️ Parameters

userUsername: string

🔄 Return

UserResponse

🌐 Endpoint

/users/{UserUsername} DELETE

🔙 Back to Table of Contents


whatsappbusiness.users.updateUser

Update-User

🛠️ Usage

const updateUserResponse = await whatsappbusiness.users.updateUser({
  userUsername: "userUsername_example",
  password: "New Password",
});

⚙️ Parameters

password: string

password

userUsername: string

🔄 Return

UserResponse

🌐 Endpoint

/users/{UserUsername} PUT

🔙 Back to Table of Contents


Author

This TypeScript package is automatically generated by Konfig

About

Use WhatsApp Messenger to stay in touch with friends and family. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world. WhatsApp's TypeScript SDK for Business API generated by Konfig (https://konfigthis.com/).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published