We are sunsetting On-Premises API. Refer to our On-Premises API Sunset document for details, and to learn how to migrate to our next-generation Cloud API.
This document shows you how to set up a single instance of the WhatsApp Business API client on a developer machine for testing purposes. For a production setup, follow the relevant instructions listed in Production Setups.
To initially set up a single instance, check our list of requirements, and follow these steps:
biz
directory for the setup scriptsWA_API_VERSION
environment variableOnce you have completely set up your instance, you can choose to upgrade it. To uninstall the client, follow these steps.
Before you start, you will need to complete the following:
To install Docker Desktop on your developer machine:
The remaining steps are based on macOS and should be very similar for Linux or Windows 10.
To install Docker using macOS:
Docker Compose is a plugin that is bundled with Docker Desktop and should have installed automatically. For more information about using or Docker Compose, see Overview of Docker Compose. If for some reason Docker Compose was not installed, you can install it by following the instructions located at Install Docker Compose.
Make sure you set up a local test account in a development environment. This is for fast development and to test new releases.
Perform the following steps to install a single instance of the WhatsApp Business API client on a developer system.
Create a ~/biz
directory for the WhatsApp Business API client.
Clone the WhatsApp Business API Client docker-compose.yml
and db.env
configuration files from the WhatsApp GitHub repository for either a
MySQL database setup or a Postgres database setup to your ~/biz
directory.
The WA_API_VERSION
environmental variable should be set to the current version.
~/biz $ export WA_API_VERSION=CURRENT-WA-API-VERSION
To find the current version of the API that you installed, open docker-compose.yml
and search for "WA_API_VERSION=
". The version number should be noted by a developer in the wacore
label:
wacore: image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.31.4 docker-compose <command> <options>)}
To start the WhatsApp Business API client, run:
~/biz $ docker-compose up -d
The resulting output should look like the following:
Creating volume "biz_whatsappMedia" with local driver Creating volume "biz_mysqlData" with local driver Creating biz_db_1 ... done Creating biz_wacore_1 ... done Creating biz_waweb_1 ... done
You can check that all containers have an UP state by running:
~/biz $ docker-compose ps
By default, the Webapp container will be running on port 9090
(https://localhost:9090
) and the database container will be running on port 33060
(https://localhost:33060
).
The resulting output should look like the following:
~/biz $ docker-compose ps Name Command State Ports ------------------------------------------------------------------------------------------------- biz_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:33060->3306/tcp, 33060/tcp biz_wacore_1 /opt/whatsapp/bin/wait_on_ ... Up 6250/tcp, 6251/tcp, 6252/tcp, 6253/tcp biz_waweb_1 /opt/whatsapp/bin/wait_on_ ... Up 0.0.0.0:9090->443/tcp
Send a GET
request to /v1/health
endpoint to check the status of your client.
On success, you will see the following:
{ "health": { "gateway_status": "unregistered" } }
To register your WhatsApp Business API client, send a POST
request to the /v1/account
endpoint.
Upon registration gateway_status
will be set connected
. Your Coreapp container is able to connect to the WhatsApp server for checking contacts and sending messages.
There will be downtime during the upgrade process.
Backing up your current application settings before upgrading is highly recommended to ensure you can get back up and running quickly. Please follow the Backup and Restore documentation.
It is always recommended performing upgrades during your least busiest hours.
WA_API_VERSION
Environment Variable to the New VersionThe WA_API_VERSION
environmental variable should be updated to the new version number using:
export WA_API_VERSION=new-whatsapp-version
If you are upgrading to version 2.33.4, the example command would be:
~/biz $ export WA_API_VERSION=2.33.4
Restart the Docker containers by running:
docker-compose up -d
The resulting output should look like the following:
biz_db_1 is up-to-date Recreating biz_wacore_1 ... done Recreating biz_waweb_1 ... done
v2.23.x
and AboveYou can now make use of a database upgrade service that will let you upgrade your database while your application is still running to avoid downtime.
The dbupgrade-compose.yml file has fields indicating the container version.
Example:
services: dbupgrade: image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:-2.21.3}
To upgrade an installation, start the dbupgrade-service container with the WA_API_VERSION
environment variable set to the latest version:
WA_API_VERSION=new-whatsapp-version docker-compose -f dbupgrade-compose.yml up -d
Note: If you are using an orchestration that restarts the container upon exit irrespective of the exit code, start the service with the EXIT_ON_SUCCESS
environment variable set to FALSE
in order to avoid exiting the container when the exit code is 0
.
If the database upgrade is successful, the container will exit with code 0
. You can use the following Docker command to track the status:
docker wait your-database-upgrade-container-name
This will output the exit code of the dbupgrade-service container.
Restart the Coreapp and Webapp Docker containers with the WA_API_VERSION
environment variable set to the latest version:
WA_API_VERSION=new-whatsapp-version docker-compose up -d
It is highly recommended to backup your current application settings before uninstalling. Please follow the Backup and Restore documentation.
If you need to reset your development environment by removing all containers, run the following command from the directory containing the docker-compose.yml
file:
WA_API_VERSION={VERSION_NUMBER} docker-compose down
The resulting output should look like the following:
Stopping biz_waweb_1 ... done Stopping biz_wacore_1 ... done Stopping biz_db_1 ... done Removing biz_waweb_1 ... done Removing biz_wacore_1 ... done Removing biz_db_1 ... done
To get rid of all volumes defined in the docker-compose.yml
file in addition to the containers, run the down
command with the -v
parameter:
WA_API_VERSION={VERSION_NUMBER} docker-compose down -v
We recommend using WADebug for more effective troubleshooting. WADebug is a command line tool to help find any potential issues with the WhatsApp Business API setup and to make requesting help from WhatsApp support more effective.
In cases where WADebug cannot be used or running the tool returns errors run the following command to collect logs from all containers:
docker-compose logs > debug_output.txt
To collect the logs of a specific service, append the service name (waweb
or wacore
) to the docker-compose logs
command:
docker-compose logs waweb > debug_output.txt
You can find the logs in the debug_output.txt
file in the current directory.
This software uses code of FFmpeg licensed under the LGPLv2.1 and its source can be downloaded here.