Send SMS
SMS is sent synchronously via /api/json.php (immediate gateway response with msg_id per message).
Asynchronous sending is also available at /v1/json (request is queued).
Synchronous sending
Example of request to send SMS message to the specified number.
URI: /api/json.php
All requests to API are sent in JSON format using the POST method.
Header parameters
Requests must contain header Content-Type: application/json, otherwise, the request will be considered invalid even if it has valid JSON.
Request parameters
Request example
{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "sms",
"id": 100500,
"phone": 380971234567,
"sms_signature": "SMSTest",
"sms_message": "Message text to be sent via SMS",
"sms_lifetime": 172800,
"short_link": true,
"unsubscribe_link": true,
"hook": "https://example.org/webhook/url.php"
}
]
}
Response parameters
| successinteger Result of request execution | |||||||
| errorstring Error text, returned if success=false | |||||||
| datalist[object] List of objects with the results of request execution
|
Response examples
- Successful
- Access denied
- Error in Alpha-name
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": true,
"data": [
{
"success": true,
"data": {
"id": 100500,
"msg_id": 123456789,
"data": 1,
"parts": 1
}
}
]
}
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": false,
"error": "Access denied"
}
HTTP Status Code: 200
Content Type: JSON application/json
{
"success": true,
"data": [
{
"success": false,
"error": "Error in Alpha-name",
"data": {
"id": 100500
}
}
]
}
Asynchronous sending
Use the async JSON API when you need to accept large batches without waiting for each message to be processed by the gateway. The request body format is the same as for synchronous sending: auth and a non-empty data array with objects where type is sms.
URI: /v1/json
Example of a successful response:
{
"request_id": "cf-ray-1234567890-ABC",
"success": true
}
Per-message msg_id values are not returned in this response.
Use request_id, webhook via the hook, or message status for delivery results
HTTP error codes:
| Code | Description |
|---|---|
400 | Invalid JSON or empty/invalid data array |
401 | Missing or invalid auth |
405 | Method other than POST |
413 | Request body too large |
415 | Missing or invalid Content-Type (must be application/json) |
503 | Queue unavailable |