REST API
Access wakit via the REST API using your API key.
wakit provides a REST API at /functions/v1/api that lets you list conversations, send messages, search contacts, and more. All endpoints authenticate with your wakit API key (sk_*).
Authentication
Every request requires the Authorization header with your wakit API key:
curl "https://api.wakit.ai/functions/v1/api/accounts" \
-H "Authorization: Bearer {API_KEY}"Create API keys in the wakit dashboard under Settings > API Keys.
CLI
You can also use the wakit CLI instead of curl:
npm install -g wakit-cli
wakit init # configure API key and default account
wakit conversations # list conversations
wakit send 5215551234 "Hello" # send a message
wakit chat 5215551234 # view conversation historySee the CLI section below for all commands.
Endpoints
List accounts
List connected WhatsApp numbers for your organization.
GET /functions/v1/api/accountsResponse:
{
"accounts": [
{ "phone": "5215588392274", "name": "Mirlo" }
]
}List conversations
Get recent conversations with last message preview.
GET /functions/v1/api/conversations?limit=10&account_phone=5215588392274| Parameter | Required | Description |
|---|---|---|
limit | No | Max conversations (default 10) |
account_phone | No* | WhatsApp number to use (*required if org has multiple numbers) |
Response:
{
"account": { "name": "Mirlo", "phone": "5215588392274" },
"conversations": [
{
"contact": { "name": "Maria Garcia", "phone": "5215551234567" },
"unread": 2,
"last_message": {
"direction": "incoming",
"content": { "kind": "text", "text": "Hola, necesito ayuda" },
"timestamp": "10:30",
"status": "delivered"
}
}
]
}Get conversation (full context)
Fetch all messages from a conversation with a specific contact. Includes service window status.
GET /functions/v1/api/conversation?contact_phone=5215551234567&limit=50&account_phone=5215588392274| Parameter | Required | Description |
|---|---|---|
contact_phone | Yes | Contact phone number (digits only, with country code) |
limit | No | Max messages (default 50) |
account_phone | No* | WhatsApp number to use |
Response:
{
"account": { "name": "Mirlo", "phone": "5215588392274" },
"contact": { "name": "Maria Garcia", "phone": "5215551234567" },
"service_window": "open",
"messages": [
{
"direction": "incoming",
"content": { "kind": "text", "text": "Hola, necesito ayuda" },
"time": "10:30",
"status": "delivered"
},
{
"direction": "outgoing",
"content": { "kind": "text", "text": "Hola Maria! En que te puedo ayudar?" },
"time": "10:31",
"status": "read"
}
]
}Send a text message
Send a text message to a contact. Requires an open service window (incoming message within 24h).
POST /functions/v1/api/messages
Content-Type: application/json
{
"contact_phone": "5215551234567",
"text": "Hello from the API!",
"account_phone": "5215588392274"
}Send a template message
Send a pre-approved template. Works even outside the 24h service window.
POST /functions/v1/api/messages
Content-Type: application/json
{
"contact_phone": "5215551234567",
"template": {
"name": "hello_world",
"language": { "code": "es" },
"components": []
},
"account_phone": "5215588392274"
}Response (both):
{ "status": "sent" }Search contacts
Search contacts by name or phone number.
GET /functions/v1/api/contacts?name=maria&limit=10
GET /functions/v1/api/contacts?number=5215551234567| Parameter | Required | Description |
|---|---|---|
name | No | Search by name (partial match) |
number | No | Search by phone number (partial match) |
limit | No | Max results (default 10) |
Response:
{
"contacts": [
{ "name": "Maria Garcia", "phone": "5215551234567" }
]
}List templates
List available WhatsApp message templates.
GET /functions/v1/api/templates?account_phone=5215588392274Response:
{
"templates": [
{ "id": "123", "name": "hello_world", "status": "APPROVED", "category": "UTILITY", "language": "es" }
]
}Get template details
Fetch a specific template with its components.
GET /functions/v1/api/templates?template_id=123&account_phone=5215588392274Response:
{
"id": "123",
"name": "hello_world",
"status": "APPROVED",
"category": "UTILITY",
"language": "es",
"components": [{ "type": "BODY", "text": "Hello {{1}}" }]
}Health check
Validate Meta API tokens for all connected WhatsApp accounts. Returns quality rating and messaging limits.
GET /functions/v1/api/healthResponse:
{
"accounts": [
{
"phone": "5215588392274",
"name": "Mirlo",
"address": "238013449404478",
"status": "active",
"quality": "GREEN",
"messaging_limit": "TIER_10K"
},
{
"phone": "15550405258",
"name": "Mirlo",
"address": "375446602312881",
"status": "error",
"error": "Session has expired"
}
]
}Use this to monitor token health and detect disconnected numbers before they affect message delivery.
Errors
Errors return a JSON object with an error field:
{ "error": "Service window is closed (24h+ since last user message). You must send a template content to re-open it." }| Status | Meaning |
|---|---|
| 401 | Invalid or missing API key |
| 400 | Bad request (missing required parameter) |
| 405 | Method not allowed |
| 500 | Internal error |
Supabase REST API (advanced)
For direct database access, wakit also exposes tables via the Supabase REST API (PostgREST). This requires a user JWT or service_role key and is intended for advanced use cases. All tables have Row Level Security (RLS) enabled.
| Table | Description |
|---|---|
organizations | Tenant entities with metadata |
organizations_addresses | Connected phone numbers |
contacts | Address book entries |
contacts_addresses | Phone numbers for contacts |
conversations | Conversations between org and contact |
messages | Messages within conversations |
agents | Human or AI agents |
api_keys | API access keys |
webhooks | Outbound webhook subscriptions |
quick_replies | Reusable response snippets |
CLI reference
The wakit CLI (wakit-cli on npm) wraps the REST API for terminal usage.
Install
npm install -g wakit-cliSetup
wakit init
# → Base URL: https://api.wakit.ai
# → API Key: sk_...
# → Select default accountConfig is saved to ~/.wakit/config.json.
Commands
| Command | Description |
|---|---|
wakit init | Configure API key and default account |
wakit status | Show connection status and accounts |
wakit health | Check Meta API token status for all accounts |
wakit conversations | List recent conversations with preview |
wakit chat <phone or name> | View conversation history with a contact |
wakit send <phone or name> "text" | Send a text message |
wakit send <phone> --template <name> | Send a template message |
wakit send <phone> --template <name> --vars "a,b" | Send template with variables |
wakit contacts [query] | List all or search contacts by name/number |
wakit templates | List WhatsApp message templates |
wakit switch <account> | Change default WhatsApp account |
Flags
| Flag | Description |
|---|---|
--json | Output as JSON (for piping to other tools) |
--from <phone> | Override default account for this command |
--limit <n> | Limit number of results |
--lang <code> | Template language (default: es) |