Skip to content
WhatSync/DocsAPI v1

Call WhatsApp from your code

Create a key, verify the connection, and read a saved message before making your first send.

1. Create an API key

API keys and webhooks require the Max plan or higher. Connect WhatsApp, then open Developers. Create a separate key for your integration. Read and send are selected by default; deselect send for a reporting-only integration. Add other permissions only when your integration needs them.

Copy the key once into your server or workflow secret store as WHATSYNC_API_KEY. Keep it out of browser code, public repositories, URLs and screenshots. The commands below assume this environment variable is already set.

2. Check the account and sender

Request
curl https://whatsync.app/api/v1/me \
  -H "Authorization: Bearer $WHATSYNC_API_KEY"

Expect HTTP 200. Check providers for the connection you intend to use and permissions for your key's scopes. A disconnected provider needs setup before tool calls can use it. This shortened example is fictional; your response can list both QR and Business providers.

Illustrative account response
{
  "connection_id": "conn_example",
  "account_id": "conn_example",
  "key_name": "Read-only reporting",
  "permissions": [
    "whatsapp.messages:read"
  ],
  "providers": [
    {
      "channel": "qr",
      "connected": true,
      "status": "connected",
      "phone_number": "15550000002",
      "display_name": "Sample account",
      "connect_url": "https://whatsync.app/dashboard",
      "capabilities": [
        "one_to_one_text",
        "groups",
        "selected_group_sync"
      ],
      "bulk_sending": false
    }
  ],
  "routing": "Choose the channel explicitly when both accounts are connected.",
  "numbers": [
    {
      "id": "conn_example",
      "first_number": true,
      "name": "Sample account",
      "phone": "+15550000002",
      "linked_as": "qr",
      "connected": true,
      "qr": {
        "phone": "+15550000002",
        "connected": true
      },
      "business": null
    }
  ]
}

3. Discover the tools your key can use

Request
curl https://whatsync.app/api/v1/tools \
  -H "Authorization: Bearer $WHATSYNC_API_KEY"

The response is {"tools":[...]}. Each item includes its name, description, annotations and input schema. This list reflects your key's permissions. The tool reference shows the full catalog with conditions and examples.

4. Read saved messages

Search request
curl -X POST https://whatsync.app/api/v1/tools/search_messages \
  -H "Authorization: Bearer $WHATSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"delivery","limit":20}'

HTTP 200 returns JSON directly. An empty messages array means no match in the permitted search window, not proof that the conversation never existed. WhatSync searches saved messages, not your entire historical WhatsApp account.

Illustrative search response
{
  "messages": [
    {
      "message_id": "example-stored-message",
      "conversation_id": "15550000001@s.whatsapp.net",
      "channel": "qr",
      "provider_phone_number_id": null,
      "sent_at": "2026-10-08T09:41:12.000Z",
      "direction": "inbound",
      "sender": "15550000001",
      "recipient": "15550000002",
      "contact_name": "Sample contact",
      "group_name": null,
      "participant_id": null,
      "type": "text",
      "text": "The delivery is booked for Tuesday.",
      "attachment": null,
      "quoted_message_id": null,
      "delivery_status": null
    }
  ],
  "has_more": false,
  "searched_after": "2026-10-01T00:00:00.000Z",
  "searched_before": "2026-10-09T00:00:00.000Z",
  "next_before": null,
  "next_cursor": null,
  "message_access_starts_at": "2026-10-01T00:00:00.000Z",
  "note": "Illustrative saved messages within the permitted history window."
}

When next_cursor is not null, send it back as cursor with the same query and filters. Stop at null. Other tools use after, offset or before; follow that tool's pagination instructions.

5. Send one message when you are ready

This step sends a real message and requires send permission. Replace the example number with your intended recipient. Use channel: qr for your linked personal account. Do not run a copied example against a number you do not intend to contact.

Personal WhatsApp text request
curl -X POST https://whatsync.app/api/v1/tools/send_message \
  -H "Authorization: Bearer $WHATSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: my-first-send-001" \
  -d '{"channel":"qr","phoneNumber":"15550000001","text":"Your requested update is ready."}'

An accepted request can look like this. Save intent_id. Acceptance does not confirm delivery.

Illustrative send response
{
  "intent_id": "00000000-0000-4000-8000-000000000001",
  "status": "accepted",
  "recipient_phone": "15550000001",
  "channel": "qr",
  "provider_message_id": "example-provider-message",
  "delivery_status": null,
  "delivery_status_at": null,
  "delivery_errors": [],
  "next_action": null,
  "error": null,
  "note": "WhatsApp accepted the message. Personal numbers send no delivery receipts, so this is the final answer; do not resend."
}

Call get_send_status with that value as intentId. For Business templates, use channel: business, an approved template and confirmed recipient opt-in. Business free-form text requires an incoming customer message within 24 hours. See the two sending examples for the different request bodies.

6. Handle errors before adding automation

Keep the same idempotency key and input for a retry of the same action. A timeout or HTTP 409 can mean the provider accepted the action; inspect its status before trying again. A new key can send a duplicate. Use the error and retry guide, then add signed webhooks for incoming messages and Business delivery updates. For workflows that run with nobody watching, start from safe send and Running WhatsApp unattended. Download OpenAPI for machine-readable inputs and responses.