🔌 Connect
Use this interactive panel to create a session, connect it using QR or pairing code, check status, and send a test message — no tools required.
WhatsInfinity Messaging API
Send messages and media (images, videos, audio, PDFs, and documents) programmatically from any platform: web, mobile, and backend services.
Introduction
What this API does
Create a session, connect it, then send messages or media to recipients. Sessions are authenticated using a per-session API key.
Base URL
Use your deployment domain. In this page, the base URL auto-detects from window.location.origin.
Quick start (3 steps)
- Create a session with POST /create-session (server returns apiKey).
- Connect by scanning a QR (GET /qr/:sessionId) or using a pairing code.
- Send a message with POST /send.
Use dryRun: true to validate payloads without sending real messages.
Authentication
Most endpoints require x-api-key. Create-session returns an apiKey you must store securely.
- Header name: x-api-key
- Where to get it: response from POST /create-session
Session Management
Create Session
Creates a new session and returns an auto-generated apiKey. Save it securely — it is required for all protected endpoints.
| Field | Type | Required | Description |
|---|---|---|---|
| sessionId | string | Yes | Unique identifier for this session. |
cURLcurl -s -X POST "http://api.api.whatsinfinity.com/create-session" \ -H "Content-Type: application/json" \ -d '{"sessionId":"client1"}'
JavaScript (fetch)const baseUrl = window.location.origin; const res = await fetch(`${baseUrl}/create-session`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ sessionId: "client1" }) }); console.log(await res.json());
Python (requests)import requests base_url = "http://api.api.whatsinfinity.com" r = requests.post(f"{base_url}/create-session", json={"sessionId": "client1"}) print(r.json())
PHP (cURL)<?php $baseUrl = "http://api.api.whatsinfinity.com"; $payload = json_encode(["sessionId" => "client1"]); $ch = curl_init("$baseUrl/create-session"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ["Content-Type: application/json"], CURLOPT_POSTFIELDS => $payload ]); echo curl_exec($ch); curl_close($ch);
Get QR Code
Returns a QR code PNG image. Scan to connect (WhatsApp → Linked Devices).
cURLcurl -L "http://api.api.whatsinfinity.com/qr/client1" \ -H "x-api-key: YOUR_API_KEY" \ --output qr.png
JavaScript (fetch → blob)const baseUrl = window.location.origin; const apiKey = "YOUR_API_KEY"; const res = await fetch(`${baseUrl}/qr/client1`, { headers: { "x-api-key": apiKey } }); const blob = await res.blob(); const url = URL.createObjectURL(blob); document.querySelector("#qr").src = url;
Pairing Code
Get a pairing code by providing the phone number (country code + number, no +).
cURLcurl -s -X POST "http://api.api.whatsinfinity.com/pairing-code" \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_API_KEY" \ -d '{"sessionId":"client1","phoneNumber":"918511305416"}'
Python (requests)import requests base_url = "http://api.api.whatsinfinity.com" api_key = "YOUR_API_KEY" r = requests.post( f"{base_url}/pairing-code", headers={"x-api-key": api_key}, json={"sessionId":"client1","phoneNumber":"918511305416"} ) print(r.json())
Check Session
Returns status and readiness.
cURLcurl -s "http://api.api.whatsinfinity.com/check-session/client1" \ -H "x-api-key: YOUR_API_KEY"
JavaScript (fetch)const baseUrl = window.location.origin; const res = await fetch(`${baseUrl}/check-session/client1`, { headers: { "x-api-key": "YOUR_API_KEY" } }); console.log(await res.json());
All Sessions
Lists all sessions.
Restart Session
Soft restart (wipe false) or wipe auth (wipe true).
Delete Session
Permanently deletes a session.
Rotate API Key
Rotate apiKey without disconnecting.
cURLcurl -s -X POST "http://api.api.whatsinfinity.com/rotate-key" \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_API_KEY" \ -d '{"sessionId":"client1"}'
JavaScript (fetch)const baseUrl = window.location.origin; const res = await fetch(`${baseUrl}/rotate-key`, { method: "POST", headers: { "content-type":"application/json", "x-api-key":"YOUR_API_KEY" }, body: JSON.stringify({ sessionId: "client1" }) }); console.log(await res.json());
Sending Messages
Send Text
Send a text message using type: "text".
Send Media
Send media by public URL. Types supported: image, video, audio, document.
Features
Message Queue
If disconnected, messages may queue and send on reconnect (up to 100 per session).
Rate Limits
10 messages per minute per session. 429 includes retryAfter.
Dry Run Mode
Use dryRun: true in POST /send to validate without sending.
Reference
Error Reference
All errors follow the standard response format.
Response Format
Success{"success":true,"requestId":"...","data":{}}
Error{"success":false,"requestId":"...","error":"Bad Request","details":"..."}
Session Lifecycle
Created → Connecting → QR/Pairing → Active → Disconnected → Retry → Disabled.
Quick Integration Guide (Detailed)
If you prefer not to use the live Connect panel, follow this step-by-step guide. All examples are copy/paste ready. Replace BASE_URL with your domain (this page uses window.location.origin).
0) Set variables
cURLexport BASE_URL="http://localhost:9797" export SESSION_ID="client1" export TO="918511305416"
1) Create session (apiKey is auto-generated)
cURLcurl -s -X POST "$BASE_URL/create-session" \ -H "Content-Type: application/json" \ -d "{\"sessionId\":\"$SESSION_ID\"}"
JavaScript (fetch)const baseUrl = window.location.origin; const sessionId = "client1"; const res = await fetch(`${baseUrl}/create-session`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ sessionId }) }); const json = await res.json(); console.log("apiKey:", json?.data?.apiKey);
Python (requests)import requests base_url = "http://localhost:9797" session_id = "client1" r = requests.post(f"{base_url}/create-session", json={"sessionId": session_id}) print(r.json()) print("apiKey:", r.json().get("data", {}).get("apiKey"))
PHP (cURL)<?php $baseUrl = "http://localhost:9797"; $payload = json_encode(["sessionId" => "client1"]); $ch = curl_init("$baseUrl/create-session"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ["Content-Type: application/json"], CURLOPT_POSTFIELDS => $payload ]); $resp = curl_exec($ch); curl_close($ch); echo $resp;
Copy data.apiKey from the response and use it as x-api-key for all protected endpoints.
2) Connect the session
Option A — QR code
cURLexport API_KEY="PASTE_API_KEY_HERE" curl -L "$BASE_URL/qr/$SESSION_ID" \ -H "x-api-key: $API_KEY" \ --output qr.png
Open qr.png and scan it in WhatsApp → Linked Devices.
Option B — Pairing code
cURLcurl -s -X POST "$BASE_URL/pairing-code" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"phoneNumber\":\"919999999999\"}"
Enter the returned code in WhatsApp → Settings → Linked Devices → Link with phone number.
3) Check session status (poll until active)
cURLcurl -s "$BASE_URL/check-session/$SESSION_ID" \ -H "x-api-key: $API_KEY"
4) Send messages
Send text
cURLcurl -s -X POST "$BASE_URL/send" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"to\":\"$TO\",\"type\":\"text\",\"message\":\"Hello from WhatsInfinity\",\"typing\":true}"
JavaScript (fetch)const baseUrl = window.location.origin; const apiKey = "PASTE_API_KEY_HERE"; await fetch(`${baseUrl}/send`, { method: "POST", headers: { "content-type": "application/json", "x-api-key": apiKey }, body: JSON.stringify({ sessionId: "client1", to: "918511305416", type: "text", message: "Hello from WhatsInfinity", typing: true }) });
Send image (URL)
cURLcurl -s -X POST "$BASE_URL/send" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"to\":\"$TO\",\"type\":\"image\",\"url\":\"https://www.gstatic.com/webp/gallery/1.jpg\",\"caption\":\"Test image\"}"
Send video (URL)
cURLcurl -s -X POST "$BASE_URL/send" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"to\":\"$TO\",\"type\":\"video\",\"url\":\"https://files.example.com/video.mp4\",\"caption\":\"Test video\"}"
Send audio (URL)
cURLcurl -s -X POST "$BASE_URL/send" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"to\":\"$TO\",\"type\":\"audio\",\"url\":\"https://files.example.com/audio.mp3\"}"
Send document (URL + fileName)
cURLcurl -s -X POST "$BASE_URL/send" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"to\":\"$TO\",\"type\":\"document\",\"url\":\"https://files.example.com/invoice.pdf\",\"fileName\":\"invoice.pdf\",\"caption\":\"Invoice\"}"
5) Rotate API key
cURLcurl -s -X POST "$BASE_URL/rotate-key" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\"}"
6) Restart session
cURL (soft)curl -s -X POST "$BASE_URL/restart-session" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"wipe\":false}"
cURL (wipe)curl -s -X POST "$BASE_URL/restart-session" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\",\"wipe\":true}"
7) Delete session
cURLcurl -s -X POST "$BASE_URL/delete-session" \ -H "Content-Type: application/json" \ -H "x-api-key: $API_KEY" \ -d "{\"sessionId\":\"$SESSION_ID\"}"
FAQ
Can I have multiple sessions?
Yes, each sessionId is independent.