SDKs
Official clients for Node.js, Python and PHP cover every endpoint, verify webhook signatures and retry safely. They are open source: warsita-node, warsita-python and warsita-php. For other languages, use the plain HTTP examples in the Quickstart or generate a client from the OpenAPI file.
Install
| Node.js 20+ | npm install warsita |
| Python 3.10+ | pip install warsita |
| PHP 8.1+ | composer require warsita/warsita-php |
Send a message
Node.js:
import Warsita from "warsita";
const warsita = new Warsita({ apiKey: process.env.WARSITA_API_KEY });
const message = await warsita.messages.send({ to: "+6281234567890", text: "Your order has shipped." });
Python:
from warsita import Warsita
warsita = Warsita(api_key="wsk_…") # or set WARSITA_API_KEY
message = warsita.messages.send(to="+6281234567890", text="Your order has shipped.")
PHP:
use Warsita\Warsita;
$warsita = new Warsita('wsk_…'); // or set WARSITA_API_KEY
$message = $warsita->messages->send(['to' => '+6281234567890', 'text' => 'Your order has shipped.']);
Python also has an asyncio client, AsyncWarsita, with the same methods. In Laravel the PHP client registers itself: set WARSITA_API_KEY in .env and inject Warsita\Warsita.
Every send carries an Idempotency-Key, so the clients retry rate limits and dropped connections without sending a message twice.
Tokens and sessions
A session API key acts for its own session. With a personal access token, name the session for messages, media, contacts and groups, either once or per call:
const warsita = new Warsita({ apiKey: process.env.WARSITA_TOKEN, sessionId: "ses_3kV9mQ2pX7aL0zR5tN8w" });
warsita = Warsita(api_key="wsp_…", session_id="ses_3kV9mQ2pX7aL0zR5tN8w")
$warsita = new Warsita('wsp_…', sessionId: 'ses_3kV9mQ2pX7aL0zR5tN8w');
Verify webhooks
Pass the raw request body, before any JSON parsing:
import { verifyWebhook } from "warsita";
const event = verifyWebhook(rawBody, request.headers["x-warsita-signature"], process.env.WARSITA_WEBHOOK_SECRET);
from warsita import verify_webhook
event = verify_webhook(raw_body, request.headers.get("X-Warsita-Signature"), WEBHOOK_SECRET)
use Warsita\Webhook;
$event = Webhook::verify($request->getContent(), $request->header('X-Warsita-Signature'), $webhookSecret);
All three throw when the signature is wrong or more than five minutes old.
What they cover
| Area | Node.js and PHP | Python |
|---|---|---|
| Messages | messages.send, list, get, edit, delete, resend, react, markRead |
the same, mark_read |
| Media | media.upload, get |
the same |
| Account | account.get, setPresence, setChatPresence |
set_presence, set_chat_presence |
| Contacts | contacts.list, check, get, picture, ids, block, unblock, blocklist |
the same |
| Groups | groups.list, get, create, update, updateParticipants, setPicture, inviteLink, resetInviteLink, inviteInfo, join, leave |
snake_case names |
| Sessions | sessions.list, create, get, update, delete, connect, restart, disconnect, qr, pairingCode, regenerateApiKey, logs, clearMessages, events |
snake_case names |
| Webhook | sessions.webhook.get, set, rotateSecret, test, deliveries, resend |
snake_case names |
PHP reaches the resources as properties ($warsita->messages->send(…), $warsita->sessions->webhook->get(…)). Errors come back as WarsitaError (PHP: WarsitaException, with errorCode) carrying the API's status, code and message. Responses that hold only data are unwrapped.