Sending Messages

Send a message to a client via messenger. Async delivery — track status via webhooks.

POST/api/v1/send

Request Headers

HeaderValueRequired
X-API-KeystringYes
Content-Typeapplication/jsonYes

Request Body

json
{
  "phone_number": "12345678901",
  "text": Ваш заказ готов!,
  "service": "telegram",
  "bot_name": "my-bot",
  "buttons": [
    {"text": "Open Site", "url": "https://massaccess.net"}
  ]
}

Request Fields

NameTypeRequiredDescription
phone_numberstringYesRecipient phone number in international format (12345678901)
textstringYesMessage text
servicestringYesMessenger: telegram, max
bot_namestringNoBot name. If not specified, default bot is used
buttonsarrayNoArray 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

NameTypeRequiredDescription
statusstringYesRequest status: "accepted" — accepted into processing queue
event_idstring (UUID)YesUnique message identifier
data.statestringYesMessage 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.