Admin API
Admin endpoints for managing API keys, monitoring usage, and controlling customer access.
All endpoints on this page require a Master Admin API Key (wamk_...).
Create API Key
Create a new managed API key for a customer.
POST /admin/api-keys
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name for the key |
type | string | No | Key type (standard, premium, etc.) |
isAdmin | boolean | No | Grant admin privileges (default: false) |
rateLimitGeneral | number | No | General API rate limit (req/min) |
rateLimitMessages | number | No | Message rate limit (msg/min) |
rateLimitSessions | number | No | Session creation limit (sessions/hour) |
maxSessions | number | No | Maximum concurrent sessions |
metadata | object | No | Custom metadata |
Example Request
curl -X POST http://localhost:3000/admin/api-keys \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Customer: John Doe",
"type": "standard",
"isAdmin": false,
"rateLimitGeneral": 100,
"rateLimitMessages": 30,
"rateLimitSessions": 10,
"maxSessions": 5,
"metadata": {
"customerId": "123",
"email": "john@example.com"
}
}'
Response
{
"success": true,
"apiKey": {
"id": "key_abc123",
"key": "wask_d5726b79a64573672bd70fa06f3632ea...",
"name": "Customer: John Doe",
"type": "standard",
"isAdmin": false,
"rateLimits": {
"general": 100,
"messages": 30,
"sessions": 10
},
"maxSessions": 5,
"createdAt": "2026-01-28T10:00:00.000Z"
},
"warning": "IMPORTANT: Save this API key securely! The raw key will NOT be shown again."
}
Create Trial API Key
Create a time-limited trial key restricted to specific phone numbers.
POST /admin/api-keys/trial
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name for the trial |
trialDays | number | Yes | Trial duration in days |
allowedNumbers | array | Yes | Phone numbers allowed to receive messages |
rateLimitMessages | number | No | Message rate limit (default: 10) |
maxSessions | number | No | Maximum sessions (default: 1) |
Example Request
curl -X POST http://localhost:3000/admin/api-keys/trial \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Trial User: prospect@email.com",
"trialDays": 7,
"allowedNumbers": ["+919876543210", "+919876543211"],
"rateLimitMessages": 10,
"maxSessions": 1
}'
Response
{
"success": true,
"apiKey": {
"id": "key_trial123",
"key": "wask_trial_key_here...",
"name": "Trial: Trial User: prospect@email.com",
"type": "trial",
"isTrial": true,
"trialExpiresAt": "2026-02-08T12:00:00.000Z",
"allowedNumbers": ["+919876543210", "+919876543211"],
"rateLimits": {
"general": 50,
"messages": 10,
"sessions": 2
}
},
"trialInfo": {
"expiresAt": "2026-02-08T12:00:00.000Z",
"allowedNumbers": ["+919876543210", "+919876543211"],
"restrictions": "This trial key can only send messages to the specified numbers"
}
}
List All API Keys
Get a list of all API keys.
GET /admin/api-keys
Query Parameters
| Parameter | Type | Description |
|---|---|---|
includeInactive | boolean | Include deactivated keys (default: false) |
type | string | Filter by type (standard, trial, premium) |
Example Request
curl -H "X-API-Key: wamk_your_admin_key" \
"http://localhost:3000/admin/api-keys?includeInactive=false&type=standard"
Response
{
"success": true,
"apiKeys": [
{
"id": "key_abc123",
"name": "Customer: John Doe",
"type": "standard",
"isAdmin": false,
"isActive": true,
"rateLimits": {
"general": 100,
"messages": 30,
"sessions": 10
},
"isTrial": false,
"usage": {
"messagesSent": 150,
"sessionsCreated": 2
},
"createdAt": "2026-01-28T10:00:00.000Z",
"lastUsedAt": "2026-02-01T10:00:00.000Z"
}
],
"count": 1
}
Get API Key Details
Get detailed information about a specific API key.
GET /admin/api-keys/{id}
Example Request
curl -H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/api-keys/key_abc123
Update API Key
Update an API key's settings.
PUT /admin/api-keys/{id}
Request Body
{
"name": "Updated Name",
"rateLimitGeneral": 200,
"rateLimitMessages": 50,
"maxSessions": 10
}
Example Request
curl -X PUT http://localhost:3000/admin/api-keys/key_abc123 \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Name",
"rateLimitMessages": 50
}'
Update Rate Limits
Update rate limits for an API key.
PUT /admin/api-keys/{id}/rate-limits
Request Body
{
"general": 200,
"messages": 50,
"sessions": 20
}
Example Request
curl -X PUT http://localhost:3000/admin/api-keys/key_abc123/rate-limits \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"general": 200,
"messages": 50,
"sessions": 20
}'
Deactivate API Key
Deactivate an API key (can be reactivated later).
POST /admin/api-keys/{id}/deactivate
Example Request
curl -X POST \
-H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/api-keys/key_abc123/deactivate
Activate API Key
Reactivate a deactivated API key.
POST /admin/api-keys/{id}/activate
Example Request
curl -X POST \
-H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/api-keys/key_abc123/activate
Delete API Key
Permanently delete an API key.
DELETE /admin/api-keys/{id}
Example Request
curl -X DELETE \
-H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/api-keys/key_abc123
This action is irreversible. All sessions created with this key will lose access.
Extend Trial Period
Extend the trial period for a trial API key.
POST /admin/api-keys/{id}/extend-trial
Request Body
{
"days": 3
}
Example Request
curl -X POST http://localhost:3000/admin/api-keys/key_trial123/extend-trial \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{"days": 3}'
Convert Trial to Paid
Convert a trial key to a paid/standard key.
POST /admin/api-keys/{id}/convert-to-paid
Request Body
{
"type": "standard",
"rateLimitGeneral": 100,
"rateLimitMessages": 30,
"maxSessions": 5
}
Example Request
curl -X POST http://localhost:3000/admin/api-keys/key_trial123/convert-to-paid \
-H "X-API-Key: wamk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"type": "standard",
"rateLimitMessages": 30,
"maxSessions": 5
}'
Get Usage Statistics
Get overall usage statistics for all API keys.
GET /admin/usage
Example Request
curl -H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/usage
Response
{
"success": true,
"stats": {
"totalKeys": 10,
"activeKeys": 8,
"trialKeys": 3,
"adminKeys": 1,
"totalSessions": 25,
"totalMessagesSent": 5000,
"keysByType": {
"standard": 5,
"trial": 3,
"premium": 2
}
},
"keys": [
{
"id": "key_abc123",
"name": "Customer: John Doe",
"type": "standard",
"isActive": true,
"sessionStats": {
"sessions": 2,
"messagesSent": 150
},
"lastUsedAt": "2026-02-01T10:00:00.000Z"
}
]
}
Get API Key Usage Details
Get detailed usage for a specific API key including all sessions.
GET /admin/api-keys/{id}/usage
Example Request
curl -H "X-API-Key: wamk_your_admin_key" \
http://localhost:3000/admin/api-keys/key_abc123/usage
Response
{
"success": true,
"apiKey": {
"id": "key_abc123",
"name": "Customer: John Doe",
"type": "standard"
},
"usage": {
"totalSessions": 2,
"activeSessions": 1,
"totalMessagesSent": 150,
"totalMessagesReceived": 75
},
"sessions": [
{
"id": "session-uuid-1",
"name": "my-whatsapp",
"state": "ready",
"phoneNumber": "919876543210",
"messagesSent": 100,
"messagesReceived": 50,
"createdAt": "2026-01-28T10:00:00.000Z"
}
]
}