Skip to content

Quick start

This page takes you from zero to a sent WhatsApp message. It takes about five minutes.

Before you start, you need a SanadWA account with a connected WhatsApp number, and an approved template. You also need to be an admin of the account, because only admins can create API keys.

  1. In the console, open Settings → Developers → API keys and click New API key.

    • Name: something that tells you where the key is used, for example Order system.
    • Scope: choose Send. It can send messages, start campaigns and read data. If your code will also create contacts or tags, choose Full instead.
    • IP allowlist (optional): leave it empty for now.

    Click Mint key. The console shows the key once. It starts with pk_live_. Copy it and store it in your server’s secret store. You cannot see it again.

    If your plan does not include API access, the console shows an error instead. Contact SanadWA to change your plan.

  2. Put the key in an environment variable on your server, so that it is never written in your code:

    Terminal window
    export SANADWA_API_KEY="pk_live_YOUR_KEY"

    Now call GET /health. It does nothing except check your key.

    Terminal window
    curl https://api.sanadwa.com/v1/health \
    -H "Authorization: Bearer $SANADWA_API_KEY"

    A working key returns 200 and a body like this:

    {
    "success": true,
    "tenant_id": 1234,
    "scope": "send",
    "server_time": "2026-11-11T08:00:00.000Z"
    }

    If you get 401, check that the header is exactly Authorization: Bearer followed by the key. See Errors for every error code.

  3. Every send needs a phone_number_id: the id of the WhatsApp number you send from. In the console it is called the Sender ID (Settings → Developers → Senders). You can also get it from the API:

    Terminal window
    curl https://api.sanadwa.com/v1/phone-numbers \
    -H "Authorization: Bearer $SANADWA_API_KEY"
    {
    "success": true,
    "data": [
    {
    "phone_number_id": "100000000000001",
    "display_phone_number": "+1 202-555-0100",
    "verified_name": "Example Store",
    "name_status": "APPROVED",
    "new_name_status": null,
    "waba_id": "200000000000002",
    "quality_rating": "GREEN",
    "status": "CONNECTED"
    }
    ]
    }

    Copy the phone_number_id.

  4. Use the name and language of one of your approved templates. template_params fills the template’s variables {{1}}, {{2}}, and so on, in order. to_phone is the recipient in E.164 format.

    The Idempotency-Key header makes the request safe to retry: if you send the same request again with the same key, the message is not sent twice. Use a new random value for every new message. See Idempotency.

    Terminal window
    curl https://api.sanadwa.com/v1/messages/template \
    -H "Authorization: Bearer $SANADWA_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -d '{
    "phone_number_id": "100000000000001",
    "to_phone": "+12025550123",
    "template_name": "order_update",
    "template_language": "en",
    "template_params": ["Sara", "A-1042"]
    }'

    When WhatsApp accepts the message, you get 200:

    {
    "success": true,
    "message_id": "wamid.HBgLMTIwMjU1NTAxMjMVAgARGBI",
    "accepted_at": "2026-11-11T08:00:01.000Z",
    "upstream": {
    "messaging_product": "whatsapp",
    "contacts": [{ "input": "+12025550123", "wa_id": "12025550123" }],
    "messages": [{ "id": "wamid.HBgLMTIwMjU1NTAxMjMVAgARGBI" }]
    }
    }

    Save message_id. You can look up the message’s delivery status with GET /messages/{id}, and webhooks for this message refer to it. See Send a template message.