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}.

FieldTypeMeaning
chatstring or numberRequired. An alias you were given, or a chat id that equals one of your allowed aliases.
textstringThe message. With photo or document it is the caption.
photostringA URL or a Telegram file_id. Not together with document.
documentstringA URL or a Telegram file_id.
parse_modestringHTML or MarkdownV2.
silentbooleanSend 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.

StatuserrorCause
400bad_requestThe 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.
401unauthorizedThe key is missing or unknown.
403bot_not_allowedYour product may not use this bot.
403chat_not_allowedYour product may not send to this chat.
404unknown_botThere is no such bot.
429rate_limitedYour product is over its limit.
429, 502telegramTelegram refused the message or could not be reached.
503no_tokenThe 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.