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 in production.
If you haven't already done so, it's recommended you set up a single instance of the WhatsApp Business API client on a developer machine following the Developer Setup: Single Instance instructions to test your set up before following this document to set up the WhatsApp Business API client in production.
To complete your initial setup, check our 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.
If you have already run a developer setup and want to reuse the phone number in production, please refer to the Migration guide before continuing with the rest of this document.
The content in this document is based on the assumption of a fresh installation using a new phone number.
You will need:
Either MySQL 5.7.xx or PostgreSQL 13.x/12.x/11.x is required.
Your database password should not contain any of these characters: ?{}&~!()^=
Failing to comply with this will likely cause the setup to fail.
There's also a known compatibility issue with MySQL 8. Please avoid using the latest for now, we're actively working on a fix.
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.
biz
Directory for the Setup ScriptsRun the following code in your preferred location for the WhatsApp Business API client:
mkdir ~/biz; cd ~/biz;
Clone the prod-docker-compose.yml
and db.env
configuration files from the Installation directory of the WhatsApp-Business-API-Setup-Scripts GitHub repository to the ~/biz
directory you created in Step 1.
WA_API_VERSION
Environment VariableThe WA_API_VERSION
environmental variable should be set to the current version using:
export WA_API_VERSION=current-whatsapp-version
Change the database environment variables in the db.env
file under the ~/biz
directory to reflect your MySQL/PostgreSQL configuration.
WA_DB_ENGINE=MYSQL | PGSQL WA_DB_HOSTNAME=your-database-server WA_DB_PORT=your-database-server-port WA_DB_USERNAME=your-database-username WA_DB_PASSWORD=your-database-password
The local media volume (whatsappMedia:/usr/local/wamedia
by default) defined in prod-docker-compose.yml
file is used for storing media files. By default, the volume in mounted to a directory on the Docker machine. Alternatively, you can choose to mount the media volume to a host directory. To change the mount point of the media volume, modify the volume definition inside the services
section from whatsappMedia
to the path of the host directory you're using.
services: wacore: ... volumes: - /your-local-media-volume-path:/usr/local/wamedia ... waweb: ... volumes: - /your-local-media-volume-path:/usr/local/wamedia ...
To start the WhatsApp Business API client with 1 Webapp container and 1 Coreapp container, run:
docker-compose -f prod-docker-compose.yml up -d
The resulting output should look like the following:
Creating biz_wacore_1 ... done Creating biz_waweb_1 ... done
You can check that all containers have an UP state by running:
docker-compose -f prod-docker-compose.yml ps
The resulting output should look like the following:
Name Command State Ports ------------------------------------------------------------------------------------------------- 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
By default, the Webapp container will be running on port 9090
.
You can download and configure our Postman Collection for interacting with the WhatsApp Business API if you do not wish to use the command line.
You can perform a health check on the WhatsApp Business API client using an API call to the health
node.
The resulting output should look like the following:
{ "health": { "gateway_status": "unregistered" } }
The response shows a gateway_status
of unregistered
as the gateway_status
because the WhatsApp Business API client is not yet registered.
You can register your WhatsApp Business API client using an API call to the account
node.
Perform another health check on the WhatsApp Business API client using an API call to the health
node after completing registration.
The resulting output should look like the following:
{ "health": { "gateway_status": "connected" } }
A gateway_status
of connected
means the Coreapp container is able to connect to the WhatsApp server for checking contacts and sending messages.
It's recommended you set up monitoring for your production WhatsApp Business API client.
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 to perform 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
Restart the Docker containers by running:
docker-compose -f prod-docker-compose.yml up -d
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 -f prod-docker-compose.yml up -d
2.29.3
and AboveIf you are upgrading from v2.29.1
, v2.29.2
or encountered problems during upgrade to those versions and had to roll back for stability, we recommend you upgrade to v2.29.3
, then run the following command on the Webapp Docker container:
chown -R root your-media-directory/incoming your-media-directory/outgoing your-media-directory/shared
Unless you have changed it, the default media directory is /usr/local/wamedia
.
Note:
v2.29.1
and v2.29.2
.It is highly recommended to backup your current application settings before uninstallation. 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 prod-docker-compose.yml
file:
docker-compose -f prod-docker-compose.yml down
The resulting output should look like the following:
Stopping biz_waweb_1 ... done Stopping biz_wacore_1 ... done Removing biz_waweb_1 ... done Removing biz_wacore_1 ... done
To get rid of all volumes defined in the prod-docker-compose.yml
file in addition to the containers, run the down
command with the -v
parameter:
docker-compose -f prod-docker-compose.yml 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 -f prod-docker-compose.yml 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 -f prod-docker-compose.yml 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.