API reference

Documentation

Send WhatsApp messages from your system with HTTP requests. All endpoints are POST, accept JSON (UTF-8) and reply with JSON.

Base URL  https://api.wantawa.com/api

An instance is a WhatsApp number linked to your account. In every request you say which instance to send from.

Important: Wantawa links your number as a device (like WhatsApp Web); it is not the official WhatsApp Business API. Only message people who expect to hear from you and respect the limits to avoid restrictions on your number.

Authentication

Every account has a private API token (find it in your dashboard). Send it in any of these ways:

FieldTypeDescription
AuthorizationheaderAuthorization: Bearer TU_TOKEN — recommended.
X-API-KeyheaderX-API-Key: TU_TOKEN — alternative if your proxy or server drops Authorization.
tokenbody fieldThe token inside the JSON or form body. Handy for quick tests.
Server-to-server only. Do not include the token in mobile apps or browser JavaScript: it would be exposed. If it leaks, regenerate it from the dashboard and the old one stops working.

Your first instance

  1. Create your account at api.wantawa.com.
  2. In the dashboard, click Add instance and choose a name (letters, numbers and underscore). That name is the instance value in the API.
  3. Click QR and scan the code with WhatsApp on your phone (Linked devices).
  4. Your first instance includes a 5-day trial. After that, activate a plan to keep sending.

Inside the dashboard, the Test API section generates the code for your request in 7 languages and really sends it.

Send text

POSThttps://api.wantawa.com/api/send.php
FieldTypeDescription
instance *stringName of your instance, as shown in the dashboard.
phone *stringDestination with country code, digits only (8 to 15). E.g. 5215512345678.
message *stringUTF-8 text (emojis and line breaks supported). Maximum 4096 characters.

Example

curl -X POST https://api.wantawa.com/api/send.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"instance":"my_instance","phone":"5215512345678","message":"Hello from Wantawa"}'
<?php
$ch = curl_init('https://api.wantawa.com/api/send.php');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer TU_TOKEN',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'instance' => 'my_instance',
    'phone' => '5215512345678',
    'message' => 'Hello from Wantawa',
  ]),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $status . ' ' . $response;
const response = await fetch("https://api.wantawa.com/api/send.php", {
  method: 'POST',
  headers: {
    "Authorization": "Bearer TU_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "instance": "my_instance",
    "phone": "5215512345678",
    "message": "Hello from Wantawa"
  }),
});
console.log(response.status, await response.json());
import requests

response = requests.post(
    "https://api.wantawa.com/api/send.php",
    headers={
        "Authorization": "Bearer TU_TOKEN",
    },
    json={
        "instance": "my_instance",
        "phone": "5215512345678",
        "message": "Hello from Wantawa"
    },
    timeout=30,
)
print(response.status_code, response.json())
using System.Net.Http;
using System.Text;
using System.Text.Json;

var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.wantawa.com/api/send.php");
request.Headers.Add("Authorization", "Bearer TU_TOKEN");

var payload = new Dictionary<string, string>
{
    ["instance"] = "my_instance",
    ["phone"] = "5215512345678",
    ["message"] = "Hello from Wantawa",
};
request.Content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");

var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Main {
    public static void main(String[] args) throws Exception {
        String json = "{\"instance\":\"my_instance\",\"phone\":\"5215512345678\",\"message\":\"Hello from Wantawa\"}";

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.wantawa.com/api/send.php"))
            .timeout(Duration.ofSeconds(30))
            .header("Authorization", "Bearer TU_TOKEN")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]string{
		"instance": "my_instance",
		"phone": "5215512345678",
		"message": "Hello from Wantawa",
	})

	req, _ := http.NewRequest("POST", "https://api.wantawa.com/api/send.php", bytes.NewBuffer(payload))
	req.Header.Set("Authorization", "Bearer TU_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.StatusCode, string(body))
}

Successful response · 200

{
  "success": true,
  "response": {
    "status": "success",
    "response": [ { "id": "true_5215512345678@c.us_3EB0…", "ack": 1, "…": "…" } ],
    "session": "my_instance"
  }
}

The content of response comes from the WhatsApp engine and may include more fields.

Error response

{
  "success": false,
  "error": "Token or instance not authorized"
}

Send image

POSThttps://api.wantawa.com/api/send-image.php
FieldTypeDescription
instance *stringName of your instance, as shown in the dashboard.
phone *stringDestination with country code, digits only (8 to 15). E.g. 5215512345678.
imagestringPublic URL (http/https) or base64 content. Not needed if you upload the file in file.
captionstringOptional caption. Maximum 1024 characters.
filenamestringOptional file name.

Formats: JPG, PNG, WEBP and GIF. Maximum size: 8 MB. The real file content is verified, not just its extension.

Example with a URL

curl -X POST https://api.wantawa.com/api/send-image.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"instance":"my_instance","phone":"5215512345678","image":"https://example.com/photo.jpg","caption":"Our catalog"}'
<?php
$ch = curl_init('https://api.wantawa.com/api/send-image.php');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer TU_TOKEN',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'instance' => 'my_instance',
    'phone' => '5215512345678',
    'image' => 'https://example.com/photo.jpg',
    'caption' => 'Our catalog',
  ]),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $status . ' ' . $response;
const response = await fetch("https://api.wantawa.com/api/send-image.php", {
  method: 'POST',
  headers: {
    "Authorization": "Bearer TU_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "instance": "my_instance",
    "phone": "5215512345678",
    "image": "https://example.com/photo.jpg",
    "caption": "Our catalog"
  }),
});
console.log(response.status, await response.json());
import requests

response = requests.post(
    "https://api.wantawa.com/api/send-image.php",
    headers={
        "Authorization": "Bearer TU_TOKEN",
    },
    json={
        "instance": "my_instance",
        "phone": "5215512345678",
        "image": "https://example.com/photo.jpg",
        "caption": "Our catalog"
    },
    timeout=30,
)
print(response.status_code, response.json())
using System.Net.Http;
using System.Text;
using System.Text.Json;

var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.wantawa.com/api/send-image.php");
request.Headers.Add("Authorization", "Bearer TU_TOKEN");

var payload = new Dictionary<string, string>
{
    ["instance"] = "my_instance",
    ["phone"] = "5215512345678",
    ["image"] = "https://example.com/photo.jpg",
    ["caption"] = "Our catalog",
};
request.Content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");

var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Main {
    public static void main(String[] args) throws Exception {
        String json = "{\"instance\":\"my_instance\",\"phone\":\"5215512345678\",\"image\":\"https://example.com/photo.jpg\",\"caption\":\"Our catalog\"}";

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.wantawa.com/api/send-image.php"))
            .timeout(Duration.ofSeconds(30))
            .header("Authorization", "Bearer TU_TOKEN")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]string{
		"instance": "my_instance",
		"phone": "5215512345678",
		"image": "https://example.com/photo.jpg",
		"caption": "Our catalog",
	})

	req, _ := http.NewRequest("POST", "https://api.wantawa.com/api/send-image.php", bytes.NewBuffer(payload))
	req.Header.Set("Authorization", "Bearer TU_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.StatusCode, string(body))
}

Uploading the file (multipart/form-data)

Avoid base64's extra 33 %: send the file in the file field.

curl -X POST https://api.wantawa.com/api/send-image.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -F instance=my_instance \
  -F phone=5215512345678 \
  -F caption="Our catalog" \
  -F file=@photo.jpg

Send document

POSThttps://api.wantawa.com/api/send-document.php
FieldTypeDescription
instance *stringName of your instance, as shown in the dashboard.
phone *stringDestination with country code, digits only (8 to 15). E.g. 5215512345678.
documentstringPublic URL (http/https) or base64 content. Not needed if you upload the file in file.
filenamestringName with extension (e.g. invoice.pdf). Recommended, and required if the type cannot be inferred.
captionstringOptional caption. Maximum 1024 characters.

Formats: PDF, DOC/DOCX, XLS/XLSX, PPT/PPTX, TXT, CSV, RTF, ZIP, JSON, XML and ODT/ODS/ODP. Maximum size: 16 MB.

Example with a URL

curl -X POST https://api.wantawa.com/api/send-document.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"instance":"my_instance","phone":"5215512345678","document":"https://example.com/invoice.pdf","filename":"invoice.pdf","caption":"Your November invoice"}'
<?php
$ch = curl_init('https://api.wantawa.com/api/send-document.php');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer TU_TOKEN',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'instance' => 'my_instance',
    'phone' => '5215512345678',
    'document' => 'https://example.com/invoice.pdf',
    'filename' => 'invoice.pdf',
    'caption' => 'Your November invoice',
  ]),
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $status . ' ' . $response;
const response = await fetch("https://api.wantawa.com/api/send-document.php", {
  method: 'POST',
  headers: {
    "Authorization": "Bearer TU_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "instance": "my_instance",
    "phone": "5215512345678",
    "document": "https://example.com/invoice.pdf",
    "filename": "invoice.pdf",
    "caption": "Your November invoice"
  }),
});
console.log(response.status, await response.json());
import requests

response = requests.post(
    "https://api.wantawa.com/api/send-document.php",
    headers={
        "Authorization": "Bearer TU_TOKEN",
    },
    json={
        "instance": "my_instance",
        "phone": "5215512345678",
        "document": "https://example.com/invoice.pdf",
        "filename": "invoice.pdf",
        "caption": "Your November invoice"
    },
    timeout=30,
)
print(response.status_code, response.json())
using System.Net.Http;
using System.Text;
using System.Text.Json;

var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.wantawa.com/api/send-document.php");
request.Headers.Add("Authorization", "Bearer TU_TOKEN");

var payload = new Dictionary<string, string>
{
    ["instance"] = "my_instance",
    ["phone"] = "5215512345678",
    ["document"] = "https://example.com/invoice.pdf",
    ["filename"] = "invoice.pdf",
    ["caption"] = "Your November invoice",
};
request.Content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");

var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Main {
    public static void main(String[] args) throws Exception {
        String json = "{\"instance\":\"my_instance\",\"phone\":\"5215512345678\",\"document\":\"https://example.com/invoice.pdf\",\"filename\":\"invoice.pdf\",\"caption\":\"Your November invoice\"}";

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.wantawa.com/api/send-document.php"))
            .timeout(Duration.ofSeconds(30))
            .header("Authorization", "Bearer TU_TOKEN")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]string{
		"instance": "my_instance",
		"phone": "5215512345678",
		"document": "https://example.com/invoice.pdf",
		"filename": "invoice.pdf",
		"caption": "Your November invoice",
	})

	req, _ := http.NewRequest("POST", "https://api.wantawa.com/api/send-document.php", bytes.NewBuffer(payload))
	req.Header.Set("Authorization", "Bearer TU_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.StatusCode, string(body))
}

Uploading the file (multipart/form-data)

curl -X POST https://api.wantawa.com/api/send-document.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -F instance=my_instance \
  -F phone=5215512345678 \
  -F filename=invoice.pdf \
  -F caption="Your November invoice" \
  -F file=@invoice.pdf
File URLs must be public and reachable on ports 80 or 443. Up to 3 redirects are followed; private or internal addresses are rejected.

Idempotency-Key

If your client retries a request after a timeout, you could send the message twice. To avoid it, add the optional Idempotency-Key header with a unique identifier per message (for example a UUID, 1 to 64 characters: letters, numbers and _ . : -). It works on all three endpoints.

curl -X POST https://api.wantawa.com/api/send.php \
  -H "Authorization: Bearer TU_TOKEN" \
  -H "Idempotency-Key: order-48213-shipping-notice" \
  -H "Content-Type: application/json" \
  -d '{"instance":"my_instance","phone":"5215512345678","message":"Your order is on its way"}'
FieldTypeDescription
Same key, same content—Returns the original response with the Idempotent-Replayed: true header, without resending the message.
First request still in progress409Replies with Retry-After. Retry in a few seconds.
Same key, different content422The key was already used with another request. Generate a new one.
Errors—They are not stored: after a 4xx or 5xx error you can retry with the same key.

Keys last 24 hours and are independent per instance.

Limits and sizes

ItemLimit
Sending rate30 messages per minute on each instance (honor Retry-After if you get a 429)
Text4096 characters
Caption1024 characters
Image8 MB
Document16 MB
Phone8 to 15 digits, with country code
Recommended timeout in your client30 seconds or more
Always use the exact https:// URL, with no redirects: many libraries turn a redirected POST into a GET and lose the body.

Response codes

CodeMeaning
200Sent successfully.
400Missing or invalid parameters: malformed JSON, phone, file or URL.
401Missing token, or the token or instance is not valid.
403The instance's validity has expired: renew your plan.
409A request with the same Idempotency-Key is still being processed.
413File or body too large.
415File type not allowed.
422Idempotency-Key reused with a different request.
429You exceeded the per-minute sending limit.
502WhatsApp rejected the send or did not respond (for example, a disconnected instance).

Errors return {"success": false, "error": "…"} with a descriptive message.

Webhooks (incoming messages)

In the dashboard, click the plug button on your instance and register a public https URL. We will send a POST for every message received:

{
  "instance": "my_instance",
  "event": "onmessage",
  "data": { "…": "message data: from, body, type, timestamp, …" }
}
  • event: onmessage (message received) or onselfmessage (sent from your own phone).
  • Reply with a 2xx code within 5 seconds; process in the background if you need more time.
  • Every request includes X-WA-Signature: sha256=…, the HMAC-SHA256 of the body using your token as the key.

Verify the signature

<?php
$body = file_get_contents('php://input');
$sig  = $_SERVER['HTTP_X_WA_SIGNATURE'] ?? '';
$calc = 'sha256=' . hash_hmac('sha256', $body, 'TU_TOKEN');

if (!hash_equals($calc, $sig)) { http_response_code(401); exit; }

$event = json_decode($body, true);
// ... process $event['data'] and reply quickly with 200
http_response_code(200);
const crypto = require('crypto');

// IMPORTANT: use the raw (unparsed) body to compute the signature
function verify(rawBody, header, token) {
  const calc = 'sha256=' + crypto.createHmac('sha256', token).update(rawBody).digest('hex');
  const a = Buffer.from(calc), b = Buffer.from(header || '');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
import hmac, hashlib

def verify(body: bytes, header: str, token: str) -> bool:
    calc = "sha256=" + hmac.new(token.encode(), body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(calc, header or "")