Send API
The send API lets a product send a Telegram message as one of the bots. It is for products, not for people, and is available inside the operator's network. The operator gives your product a key and decides which bots and chats it may use.
Authentication#
Every request carries Authorization: Bearer <key>. The key belongs to one product. What the product may do is decided per bot: each bot lists the chat aliases a product may send to. A bot that lists nothing for your product is closed to it.
Send a message#
POST /v1/bots/{bot}/send sends as the bot {bot}.
| Field | Type | Meaning |
|---|---|---|
chat | string or number | Required. An alias you were given, or a chat id that equals one of your allowed aliases. |
text | string | The message. With photo or document it is the caption. |
photo | string | A URL or a Telegram file_id. Not together with document. |
document | string | A URL or a Telegram file_id. |
parse_mode | string | HTML or MarkdownV2. |
silent | boolean | Send without a notification. Default false. |
curl -sS -X POST "$BOTPARK_URL/v1/bots/health/send" \
-H "Authorization: Bearer $BOTPARK_KEY" \
-H "Content-Type: application/json" \
-d '{"chat": "owner", "text": "Disk usage is above 90%", "silent": true}'
A successful reply:
{ "ok": true, "bot": "health", "chat_id": 123456789, "message_id": 42 }
Text is limited to 4096 characters, and a caption to 1024.
List what you may use#
GET /v1/bots returns the bots your product may use and the chat aliases for each:
{ "product": "your-product", "bots": [ { "id": "health", "username": "…", "chats": ["owner"] } ] }
Rate limits#
Each product may send at most 60 messages per minute and 600 per hour. Past that the API answers 429 rate_limited with a Retry-After header.
Errors#
An error is a JSON body { "error": "<code>", "message": "<explanation>" }. The message text is in Ukrainian.
| Status | error | Cause |
|---|---|---|
| 400 | bad_request | The body is not JSON, chat is missing, photo and document are both set, text and media are both empty, the text is too long, or parse_mode is invalid. |
| 401 | unauthorized | The key is missing or unknown. |
| 403 | bot_not_allowed | Your product may not use this bot. |
| 403 | chat_not_allowed | Your product may not send to this chat. |
| 404 | unknown_bot | There is no such bot. |
| 429 | rate_limited | Your product is over its limit. |
| 429, 502 | telegram | Telegram refused the message or could not be reached. |
| 503 | no_token | The bot is not set up with a Telegram token. |
Health#
GET /health/live and GET /health/ready need no key and report whether the service is up.