Provision the WhatsApp deployment

Before you begin

Prior to deploying the WhatsApp cluster, you must gather some information from the Settings page on the WhatsApp Business dashboard, including:

WhatsApp Business Account ID

  1. Navigate to your business settings page and select Accounts > WhatsApp Accounts.
  2. Select the WhatsApp Business account you are provisioning.
  3. Your WhatsApp Business Account ID is located at the top of the page, below WhatsApp Business Account Name.

Phone Number

  1. Navigate to your business settings page and select Accounts > WhatsApp Accounts.
  2. Select the WhatsApp Business account you are provisioning.
  3. Under the Settings tab, open WhatsApp Manager > Phone numbers.
  4. Locate the desired phone number in the list.

Certificate (associated with your phone number)

  1. Navigate to your business settings page and select Accounts > WhatsApp Accounts.
  2. Select the WhatsApp Business account you are provisioning.
  3. Under the Settings tab, open WhatsApp Manager > Phone numbers.
  4. Locate the desired phone number in the list.
  5. Click the View button (in the Certificate column).
  6. Copy the associated certificate to your clipboard and paste it in a separate document. You will need it in a subsequent step.

Install the Vonage CLI

Install latest version of Vonage Command Line Interface (CLI)

The Vonage CLI allows you to carry out many operations on the command line. Examples include creating applications, purchasing numbers, and linking a number to an application.

To install the CLI with NPM run:

npm install -g @vonage/cli

Set up the Vonage CLI to use your Vonage API Key and API Secret. You can get these from the settings page in the Dashboard.

Run the following command in a terminal, while replacing API_KEY and API_SECRET with your own:

vonage config:set --apiKey=API_KEY --apiSecret=API_SECRET

Create a Vonage Application

A Vonage API application contains the security and configuration information you need to connect to Vonage endpoints and use the Vonage APIs. In this case, you must create an application that uses the Vonage Messages API.

Note: Your WhatsApp account must be connected to your Vonage account before you can link it to a Vonage application. You can connect your WhatsApp account to your Vonage account via the Vonage API Dashboard.

Generate your JWT

Generate a JWT

TIP: You only need to do this step if you are testing with Curl, as the client libraries generate JWTs as needed for you.

Once you have created a Vonage API Application you can use the Application ID and the private key file, private.key, to generate a JWT.

TIP: If you are using the Server SDK for Node (or other languages when supported), the dynamic creation of JWTs is done for you.

If you're using the Vonage CLI, the command to create the JWT is:

JWT="$(vonage jwt --key_file=private.key --app_id=APPLICATION_ID)"

You can then view the JWT with:

echo $JWT

Alternatively, you can use our JWT web app to generate a JWT.

TIP: You can test your generated JWT at jwt.io

Provision WhatsApp Deployment

Key Description
country_code The international dialing code of the number being provisioned.
number The WhatsApp number being provisioned.
vname_certificate The certificate, which you can retrieve from your WhatsApp Business dashboard. > NOTE: Each time you click the View button, the certificate will change. Either download or copy your certificate so you can use it in a subsequent step.
method The method for delivering the one time password (OTP). Must be either sms or voice.
waba_id The WhatsApp Business Account ID of the WhatsApp Number.
curl -X POST https://api.nexmo.com/v0.1/whatsapp-manager/deployments\
  -H "Authorization: Bearer "$JWT\
  -H "Content-Type: application/json"\
  -d '{
        "country_code": "44",
        "number": "7877001122",
        "vname_certificate": "CnQKMAj669nb79e",
        "method": "sms",
        "waba_id": "345676589250625"
      }'

Once provisioned, the WhatsApp cluster progresses through the following deployment stages: INITIALIZING, CREATING_CLUSTER and CLUSTER_CREATED. When the CLUSTER_CREATED stage is reached an OTP voice call or SMS is sent to the specified number and the deployment status becomes CODE_SENT. When the OTP is received, call the Verify API to complete the process.

Verify OTP

Key Description
code The one time password being submitted for verification.
curl -X POST https://api.nexmo.com/v0.1/whatsapp-manager/$DEPLOYMENT_ID/verify\
  -H "Authorization: Bearer "$JWT\
  -H "Content-Type: application/json"\
  -d '{ "code": "$CODE" }'

Now that the WhatsApp cluster has been successfully deployed, you may manage your WhatsApp Business profile.

Reference