Skip to main content
Version: 4.0.0

Initialization

To use the WhatsApp package, initialize the class object using the constructor.

const accessToken = 'YOUR_ACCESS_TOKEN';
const fromNumberId = 'YOUR_BUSINESS_PHONE_NUMBER_ID';

final whatsapp = WhatsApp(accessToken, fromNumberId);
paramtyperequireddescription
accessTokenStringyesAccess token for your Facebook App
fromNumberIdStringyesPhone Number ID for your WhatsApp business

⚙️ API Version Customization

By default, the package uses WhatsApp Business API version v23.0. If you want to target a specific Graph API release, you can override the default version using the setVersion method. This ensures compatibility with version-dependent features and prevents issues with deprecated endpoints.

Default Version

If not set, the API version defaults to v23.0.

String version = "v21.0"; // specify as needed
whatsapp.setVersion(version);