Sending Messages
Send a message to a client via messenger. Async delivery — track status via webhooks.
POST
/api/v1/sendRequest Headers
| Header | Value | Required |
|---|---|---|
| X-API-Key | string | Yes |
| Content-Type | application/json | Yes |
Request Body
json
{
"phone_number": "12345678901",
"text": Ваш заказ готов!,
"service": "telegram",
"bot_name": "my-bot",
"buttons": [
{"text": "Open Site", "url": "https://massaccess.net"}
]
}Request Fields
| Name | Type | Required | Description |
|---|---|---|---|
| phone_number | string | Yes | Recipient phone number in international format (12345678901) |
| text | string | Yes | Message text |
| service | string | Yes | Messenger: telegram, max |
| bot_name | string | No | Bot name. If not specified, default bot is used |
| buttons | array | No | Array of {text, url} for inline keyboard (optional, max 10) |
Examples
bash
curl -X POST /api/v1/send \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"phone_number": "12345678901",
"text": Ваш заказ готов!,
"service": "telegram",
"bot_name": "my-bot",
"buttons": [
{"text": "Open Site", "url": "https://massaccess.net"}
]
}'HTTP Response Codes
All API responses return HTTP status codes. For a complete reference of error codes with explanations of causes and solutions, see the HTTP Response Codes page.
Response Body
json
{
"status": "accepted",
"event_id": "550e8400-e29b-41d4-a716-446655440000",
"data": {
"state": "new"
}
}Response Fields
| Name | Type | Required | Description |
|---|---|---|---|
| status | string | Yes | Request status: "accepted" — accepted into processing queue |
| event_id | string (UUID) | Yes | Unique message identifier |
| data.state | string | Yes | Message status: "new" — created, awaiting processing |
Webhooks
After sending a message, MassAccess notifies your server of the delivery result via an HTTP POST request to the configured Webhook URL. The webhook contains a JSON payload with state, event_id, and timestamp fields.
For the message.status event, two outcomes are possible:
- Successful delivery (state: "sent") — message delivered to the recipient;
- Failed delivery (state: "failed") — on error, error_code and error_description fields with failure details are additionally included.
For details on webhook structure, delivery, and validation — see the Webhooks.