WhatsApp Business API Quick Start Guide: Account Setup and Environment Preparation

I. Introduction

Before sending your first WhatsApp message to a user, thorough account setup and environment preparation are essential. Completing business verification, phone number binding, credential retrieval, and setting up a local testing environment ensures efficient, stable, and monitorable messaging operations. This guide walks you through setting up the WhatsApp Business API from scratch, helping you send your first message in the shortest time possible.

II. Register Facebook Business Manager and Apply for WABA

2.1 Create or Log into Facebook Business Manager

  1. Visit business.facebook.com and log in with your business admin account or create a new Business Manager.

  2. In “Business Settings,” enter your business name, business license details, and contact email.

  3. After verifying your email, you’ll be directed to the backend management page.

2.2 Submit Business Info and Verification Tips

Complete Documentation: Upload clear scanned copies of your business license, organization code certificate, or equivalent documents with consistent information.
Business Use Case: Provide a brief explanation of your use case (e.g., customer notifications, marketing). This helps reviewers quickly approve your application.
Add Multiple Admins: It’s recommended to add at least two admins to avoid access interruptions due to personnel changes.

2.3 WABA (WhatsApp Business Account) Application Process

  1. In “Business Settings” → “WhatsApp Accounts,” click “Add.”

  2. Select “Create New WhatsApp Business Account,” fill out the required business info, and submit.

  3. Wait for Facebook’s review, which typically takes 1–3 business days.

III. Phone Number Binding and Verification

3.1 Choose and Add a Dedicated Business Phone Number

  • Use your company’s official number or apply for a new number specifically for customer service or marketing.

  • Ensure the number hasn’t already been registered with WhatsApp.

3.2 Verification Method: SMS/Voice Code

  • A 6-digit code will be sent to your phone via SMS.

  • If SMS fails, switch to the “voice call” option to receive the code.

3.3 Tips to Improve Approval Rate

Stable Network: Ensure smooth internet connectivity during the code delivery process.
Use Valid Numbers: Avoid virtual or temporary numbers. Use numbers intended for long-term use.
Handle Errors Properly: After multiple failed attempts, wait 15 minutes before trying again or contact Facebook support.

IV. Obtain API Credentials

4.1 Access Token: Short-Term vs Long-Term

  • Short-Term Token: Valid for ~1 hour; ideal for debugging.

  • Long-Term Token: Valid for ~60 days; can be refreshed via API. Recommended for production use.

# Example: Get Short-Term Token (using curl)

curl -X GET \

"https://graph.facebook.com/v16.0/oauth/access_token?grant_type=client_credentials&client_id={APP_ID}&client_secret={APP_SECRET}"

4.2 App Secret & App Secret Proof

  • App Secret: Obtain from Facebook Developer Console; used for signing/encryption.

  • App Secret Proof: An HMAC-SHA256 signature of your token to prevent MITM attacks.

import hashlib

import hmac

app_secret = b'your_app_secret'

token = b'your_access_token'

proof = hmac.new(app_secret, msg=token, digestmod=hashlib.sha256).hexdigest()

print(proof)

4.3 Configure Environment Variables and Secure Storage

  • Use environment variables for local or CI/CD environments:

    export WA_APP_ID=your_app_id

    export WA_APP_SECRET=your_app_secret

    export WA_TOKEN=your_long_lived_token

  • For production, use secret managers like HashiCorp Vault or AWS Secrets Manager to avoid storing plaintext credentials.

V. Development and Testing Environment Setup

5.1 Postman Debugging

  1. Import Official Collection: Download the WhatsApp Business API Postman Collection from Facebook’s documentation.

  2. Set Environment Variables: Set base_url (e.g., https://graph.facebook.com/v16.0), phone_number_id, access_token, and app_secret_proof.

  3. Send Test Requests:

    • Get phone numbers: GET {{base_url}}/{{phone_number_id}}/phone_numbers?access_token={{access_token}}

    • Send a message:

      {

      "messaging_product": "whatsapp",

      "to": "8613712345678",

      "type": "text",

      "text": { "body": "Hello from Postman!" }

      }

  4. View Responses & Callbacks: Configure Webhooks to receive incoming message callbacks.

5.2 Code Examples: Node.js and Java

Node.js (Express)

const express = require('express');

const axios = require('axios');

const app = express();

app.use(express.json());

app.post('/send', async (req, res) => {

const { to, message } = req.body;

try {

const response = await axios.post(

`https://graph.facebook.com/v16.0/${process.env.PHONE_NUMBER_ID}/messages`,

{

messaging_product: "whatsapp",

to,

type: "text",

text: { body: message }

},

{

headers: {

Authorization: `Bearer ${process.env.WA_TOKEN}`

}

}

);

res.json(response.data);

} catch (err) {

res.status(500).json(err.response.data);

}

});

app.listen(3000, () => console.log('Server running on port 3000'));

Java (HttpClient)

import java.net.URI;

import java.net.http.HttpClient;

import java.net.http.HttpRequest;

import java.net.http.HttpResponse;

public class WhatsAppSender {

public static void main(String[] args) throws Exception {

String token = System.getenv("WA_TOKEN");

String url = "https://graph.facebook.com/v16.0/"

+ System.getenv("PHONE_NUMBER_ID") + "/messages";

String payload = """

{

"messaging_product": "whatsapp",

"to": "8613712345678",

"type": "text",

"text": { "body": "Hello from Java!" }

}

""";

HttpRequest request = HttpRequest.newBuilder()

.uri(URI.create(url))

.header("Authorization", "Bearer " + token)

.header("Content-Type", "application/json")

.POST(HttpRequest.BodyPublishers.ofString(payload))

.build();

HttpClient client = HttpClient.newHttpClient();

HttpResponse<String> response =

client.send(request, HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

}

}

5.3 Number Verification Script (LuckData Call-out)

During testing, sending messages to unregistered or deactivated numbers can fail or trigger risk controls. Use LuckData’s WhatsApp Number Validation API to pre-screen valid numbers and protect your testing environment.

LuckData Verification Example

import requests

headers = {'X-Luckdata-Api-Key': 'your_free_key'}

payload = {'phone_number': '8613712345678'}

response = requests.post(

'https://luckdata.io/api/whatsapp-number-validator/rltsvuouydi1',

headers=headers,

json=payload

)

print(response.json())

  • Free Quota: 100 credits/month, 1 request/sec;

  • Plans: Basic (5,000/month @ 5 QPS), Pro (15,000/month @ 10 QPS), Ultra (100,000/month @ 15 QPS)

VI. Conclusion

This guide walked through the entire setup process for WhatsApp Business API—from creating a Facebook Business Manager and applying for WABA, to phone number verification, credential retrieval, and building local testing environments using Postman or code. By using the LuckData validator during testing, you can further stabilize and optimize your development process. Once these preparations are complete, you’ll be fully equipped to send and receive WhatsApp messages, paving the way for template management, webhook integration, and large-scale operations.

Articles related to APIs :