Learning path: Your first WhatsApp Cloud API integrationStep 1 of 7

WhatsApp· 5 min read

Send your first WhatsApp Cloud API message with the test number


Create a Meta app with the WhatsApp use case, connect a WhatsApp Business account, and open API Setup. Meta generates and registers a test business number for you. Generate a temporary access token there, add your own phone as a To number, and click Send message to receive the hello_world template. Reply from your phone, and you can send free-form text for 24 hours. Meta’s Get Started guide lays this out in seven steps (Get started, accessed 2026-11-02).

Create the app and the business account

In the App Dashboard, create an app, “Select the Connect with customers through WhatsApp use case and click Next”, then pick an existing business portfolio or create one. In the API Setup section, connect the app to a Messaging account. If you don’t have one, click Create a WhatsApp Business account and follow the prompts for the business profile. The Messaging account ID then appears in the API Setup panel.

You don’t register the test number yourself. Per Meta’s phone number page, “a test business phone number is generated and registered for you automatically” (Business phone numbers, accessed 2026-11-02).

Send hello_world from API Setup

Click Generate access token. Select the test number as the From number, then add a To number that will receive the message. The dashboard limits how many To numbers a test number can message. Meta’s guide doesn’t say how many, or how each recipient is verified, so follow what the panel asks for. Click Send message, and the hello_world template arrives on your phone.

Copy two values before you leave the page: the test phone number ID and the Messaging account ID. Later calls and settings use them.

The panel’s button runs the call for you. Meta’s guide doesn’t print a curl for it, but a template send has the shape below in Meta’s template documentation. The hello_world version has the same shape with no components. That’s an inference from the template docs, not a sample Meta publishes (Template fundamentals, accessed 2026-11-02).

curl "https://graph.facebook.com/$API_VERSION/$TEST_BUSINESS_PHONE_NUMBER_ID/messages" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "'"$WHATSAPP_USER_PHONE_NUMBER"'",
    "type": "template",
    "template": { "name": "hello_world", "language": { "code": "en_US" } }
  }'

Write the To number in international format. Phone number format and E.164 normalization covers the edge cases.

The temporary token stops working

The token from Generate access token is a user access token. Meta says these “expire quickly, so you have to keep generating a new one every few hours”, and the panel “always generates a new User access token whenever you visit it” (Access tokens, accessed 2026-11-02). It’s fine for the first message. A script that runs overnight will start failing with an expired token.

Step 5 of the guide replaces it with a system user token. In Business Settings, open System users, add your app with Manage app under Full control, and add your WhatsApp account with Manage WhatsApp Business accounts under Full control. Generate the token with business_management, whatsapp_business_management and whatsapp_business_messaging. You choose its expiration when you create it. WhatsApp Cloud API access tokens goes through the token types in detail.

Reply to open the customer service window

After hello_world arrives, reply to it from your phone. Meta’s guide explains why: “When you responded to your earlier test message, you triggered what is known as a customer service window.” That 24-hour window “allows you to send non-template messages to users on WhatsApp.” Once it closes, “you can only send pre-approved template messages” (Send messages, accessed 2026-11-02).

Inside the window, send text with the system user token. This is Meta’s request from step 6 of the guide.

curl 'https://graph.facebook.com/v23.0/<TEST_BUSINESS_PHONE_NUMBER_ID>/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <SYSTEM_USER_ACCESS_TOKEN>' \
-d '
{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<WHATSAPP_USER_PHONE_NUMBER>",
  "type": "text",
  "text": {
    "body": "Hello!"
  }
}'

The guide uses v23.0 while the send messages page uses v26.0. Use the current version your App Dashboard shows. Free-form text outside the window fails, and error 131047 explains that response.

The reply contains messaging_product, a contacts array with the input number and its wa_id, and a messages array with the message id. A successful response means the API accepted the request. Delivery is reported later, by webhook.

Receive your first webhook

Without a webhook endpoint you can send but never see replies or statuses. Meta’s guide says you “will need to set up a webhook endpoint in order to receive notifications about message statuses”. Its test webhook app is a small Node.js server. Meta’s verification handler from that app’s app.js is below. The file defines app and verifyToken above it (Test webhook endpoint, accessed 2026-11-02).

// Route for GET requests
app.get('/', (req, res) => {
  const { 'hub.mode': mode, 'hub.challenge': challenge, 'hub.verify_token': token } = req.query;

  if (mode === 'subscribe' && token === verifyToken) {
    console.log('WEBHOOK VERIFIED');
    res.status(200).send(challenge);
  } else {
    res.status(403).end();
  }
});

In the App Dashboard, paste the app’s URL into Callback URL, put your VERIFY_TOKEN string in Verify token, and click Verify and save. Subscribe to the messages field. The Test link next to it sends a test notification to your app.

When you message the test number from your phone, a messages webhook like Meta’s sample arrives (messages webhook reference, accessed 2026-11-02):

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "102290129340398",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": {
              "display_phone_number": "15550783881",
              "phone_number_id": "106540352242922"
            },
            "contacts": [
              {
                "profile": {
                  "name": "Sheena Nelson"
                },
                "wa_id": "16505551234"
              }
            ],
            "messages": [
              {
                "from": "16505551234",
                "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgASGBQzQTRBNjU5OUFFRTAzODEwMTQ0RgA=",
                "timestamp": "1749416383",
                "type": "text",
                "text": {
                  "body": "Does it come in another color?"
                }
              }
            ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}

metadata.phone_number_id tells you which of your numbers received the message. That matters once a real number sits next to the test one. The same field carries statuses events for your outbound messages, described in message status webhooks. The handler above covers only the verification GET. Check the signature on every POST before production with X-Hub-Signature-256 verification.

Moving to a real number

A production number must “be owned by you” and “have a country and area code (short codes are not supported)”. It must also “be able to receive voice calls or SMS” and “have scaled capabilities”. It also must be registered before it can send. Registration is a POST /<PHONE_NUMBER_ID>/register call with a six-digit PIN in the body. Meta’s example body is {"messaging_product": "whatsapp", "pin": "212834"} (Register a phone number, accessed 2026-11-02). Register a WhatsApp business number walks through verification and the PIN.

Plan for the number cap too. “New business portfolios are initially capped at two registered business phone numbers.” Meta raises it to 20 after business verification or once the portfolio reaches a 2,000 messaging limit.

Meta doesn’t document whether test-number templates carry over, what messaging limit the test number has, or whether its messages are billed. Check those in your own account before you plan around them. When something fails on the real number, the Cloud API error codes reference maps the codes.

If you want both connection types available while you build, Z-API Omni lets you choose between the QR connection and Meta’s official API in the same account. Meta’s fees are passed through on the official connection. View documentation.

Z-API Omni team