Send Message
Send a WhatsApp text message via the API. Supports template variables for dynamic content.
Endpoint
POST /api/v1/messages
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| device_id | string | Yes | ID of the connected device to send from |
| to | string | Yes | Recipient phone number (international format, e.g. 628123456789) |
| content | string | Yes | Message text. Use {{1}}, {{2}} for variables. |
| variables | string[] | No | Values to substitute into template placeholders |
Example request
curl -X POST https://wayul.kawilabs.id/api/v1/messages \
-H "X-API-Key: wy_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"device_id": "dev_01",
"to": "628123456789",
"content": "Halo! Kode OTP Anda: {{1}}. Berlaku 5 menit.",
"variables": ["482913"]
}'Response
// 202 Accepted
{
"message_id": "msg_9f8ec2a1b7e3",
"status": "queued"
}Template variables
Use {{1}}, {{2}}, etc. in your content. The variables array maps positionally: {{1}} = variables[0].
Errors
| Code | Status | Description |
|---|---|---|
| UNAUTHORIZED | 401 | Missing or invalid X-API-Key |
| DEVICE_NOT_CONNECTED | 409 | Device is not connected |
| QUOTA_EXCEEDED | 429 | Monthly message quota exhausted |
| RATE_LIMITED | 429 | Too many requests (60/min per key) |
| TEXT_ONLY | 400 | Only text messages are supported in MVP |