Bot API
Bot API Docs
Публичный справочник по owner-side управлению и bot-token runtime endpoint-ам.
GET/v1/bot-api/botsВозвращает всех ботов текущего owner-аккаунта.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots
{
"items": [
{
"bot_user_id": "b63c...",
"created_at": "2026-04-21T10:00:00Z",
"description": "Publishes Russia news",
"display_name": "News Bot Russia",
"id": "7f9d...",
"owner_user_id": "25c0...",
"updated_at": "2026-04-21T10:30:00Z",
"username": "newsbot_russia_v1",
"webhook_url": "https://bot.example.test/webhook"
}
]
}POST/v1/bot-api/botsСоздаёт нового бота и один раз возвращает стартовый токен.
curl -X POST https://api.yullama.ru/v1/bot-api/bots \
-H "Authorization: Bearer <owner_token>" \
-H "Content-Type: application/json" \
-d '{"username":"news_tatarstan_bot","display_name":"News Bot","description":"Publishes verified news"}'{
"description": "Publishes verified news",
"display_name": "News Bot",
"username": "news_tatarstan_bot"
}{
"bot": {
"bot_user_id": "b63c...",
"created_at": "2026-04-21T10:00:00Z",
"description": "Publishes verified news",
"display_name": "News Bot",
"id": "7f9d...",
"owner_user_id": "25c0...",
"updated_at": "2026-04-21T10:00:00Z",
"username": "news_tatarstan_bot"
},
"token": {
"created_at": "2026-04-21T10:00:00Z",
"token": "bot_..."
}
}GET/v1/bot-api/bots/{id}Возвращает одного бота текущего owner-аккаунта.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>
{
"bot_user_id": "b63c...",
"created_at": "2026-04-21T10:00:00Z",
"description": "Publishes Russia news",
"display_name": "News Bot Russia",
"id": "7f9d...",
"owner_user_id": "25c0...",
"updated_at": "2026-04-21T10:30:00Z",
"username": "newsbot_russia_v1",
"webhook_url": "https://bot.example.test/webhook"
}GET/v1/bot-api/bots/{id}/channelsВозвращает каналы, привязанные к одному боту.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>/channels
{
"items": [
{
"bot_role": "moderator",
"created_at": "2026-04-21T10:00:00Z",
"description": "Owned channel for bot publishing",
"id": "22d6...",
"slug": "news-russia",
"title": "News Russia"
}
]
}POST/v1/bot-api/bots/{id}/channels/{channelId}Привязывает бота к одному owned channel с ролью moderator.
curl -X POST https://api.yullama.ru/v1/bot-api/bots/<bot_id>/channels/<channel_id> \ -H "Authorization: Bearer <owner_token>"
{
"attached_by": "25c0...",
"bot_id": "7f9d...",
"channel_id": "22d6...",
"role": "moderator"
}GET/v1/bot-api/bots/{id}/statsВозвращает счётчики очереди и delivery по одному боту.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>/stats
{
"attached_channel_count": 2,
"bot_id": "7f9d...",
"delivered_updates": 16,
"last_attempted_at": "2026-04-21T10:42:02Z",
"last_delivered_at": "2026-04-21T10:42:02Z",
"last_update_at": "2026-04-21T10:42:00Z",
"pending_updates": 1,
"scheduled_retries": 1,
"terminal_failed_updates": 1,
"total_updates": 18
}POST/v1/bot-api/bots/{id}/tokenВыпускает новый bot token и инвалидирует предыдущий.
curl -X POST https://api.yullama.ru/v1/bot-api/bots/<bot_id>/token -H "Authorization: Bearer <owner_token>"
{
"created_at": "2026-04-21T10:30:00Z",
"token": "bot_..."
}GET/v1/bot-api/bots/{id}/updatesВозвращает последние bot_api_updates rows с payload и delivery state.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>/updates?limit=20
{
"items": [
{
"created_at": "2026-04-21T10:42:00Z",
"delivered_webhook_at": "2026-04-21T10:42:02Z",
"event_type": "channel.post_created",
"last_attempted_at": "2026-04-21T10:42:02Z",
"last_delivery_error": "",
"payload": {
"body": "Owner update for history",
"channel_id": "22d6...",
"post_id": "90ab..."
},
"update_id": 41,
"webhook_attempt_count": 1
}
]
}GET/v1/bot-api/bots/{id}/webhookВозвращает webhook URL, наличие секрета и delivery health.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>/webhook
{
"has_secret_token": true,
"last_attempted_at": "2026-04-21T10:42:02Z",
"last_delivered_at": "2026-04-21T10:42:02Z",
"last_delivery_error": "",
"next_retry_at": null,
"pending_update_count": 0,
"url": "https://bot.example.test/webhook"
}PUT/v1/bot-api/bots/{id}/webhookУстанавливает webhook URL и необязательный secret token.
curl -X PUT https://api.yullama.ru/v1/bot-api/bots/<bot_id>/webhook \
-H "Authorization: Bearer <owner_token>" \
-H "Content-Type: application/json" \
-d '{"url":"https://bot.example.test/webhook","secret_token":"secret-123"}'{
"secret_token": "secret-123",
"url": "https://bot.example.test/webhook"
}{
"has_secret_token": true,
"last_attempted_at": "2026-04-21T10:42:02Z",
"last_delivered_at": "2026-04-21T10:42:02Z",
"last_delivery_error": "",
"next_retry_at": null,
"pending_update_count": 0,
"url": "https://bot.example.test/webhook"
}DELETE/v1/bot-api/bots/{id}/webhookОтключает webhook delivery для одного бота.
curl -X DELETE https://api.yullama.ru/v1/bot-api/bots/<bot_id>/webhook -H "Authorization: Bearer <owner_token>"
{
"status": "ok"
}GET/v1/bot-api/bots/{id}/webhook/errorsВозвращает конкретные ошибки webhook delivery.
curl -H "Authorization: Bearer <owner_token>" https://api.yullama.ru/v1/bot-api/bots/<bot_id>/webhook/errors?limit=20
{
"items": [
{
"created_at": "2026-04-21T10:52:00Z",
"event_type": "channel.post_created",
"last_attempted_at": "2026-04-21T10:52:02Z",
"last_delivery_error": "500 Internal Server Error",
"next_retry_at": "2026-04-21T10:52:04Z",
"update_id": 44,
"webhook_attempt_count": 1
}
]
}POST/v1/bot-api/bots/{id}/webhook/replayВозвращает failed rows обратно в delivery queue.
curl -X POST "https://api.yullama.ru/v1/bot-api/bots/<bot_id>/webhook/replay?limit=100" \ -H "Authorization: Bearer <owner_token>"
{
"bot_id": "7f9d...",
"max_window": 6,
"requeued": 3
}GET/v1/bot-api/channelsСписок каналов, доступных текущему bot token.
curl -H "Authorization: Bearer <bot_token>" https://api.yullama.ru/v1/bot-api/channels
{
"items": [
{
"bot_role": "moderator",
"created_at": "2026-04-21T10:00:00Z",
"description": "Owned channel for bot publishing",
"id": "22d6...",
"slug": "news-russia",
"title": "News Russia"
}
]
}POST/v1/bot-api/channels/{id}/postsПубликует пост от имени бота в привязанный канал.
curl -X POST https://api.yullama.ru/v1/bot-api/channels/<channel_id>/posts \
-H "Authorization: Bearer <bot_token>" \
-H "Content-Type: application/json" \
-d '{"body":"Bot API production news update"}'{
"body": "Bot API production news update"
}{
"author_username": "newsbot_russia_v1",
"body": "Bot API production news update",
"channel_id": "22d6...",
"created_at": "2026-04-21T10:55:00Z",
"id": "90ab..."
}GET/v1/bot-api/meВозвращает identity текущего бота по bot token.
curl -H "Authorization: Bearer <bot_token>" https://api.yullama.ru/v1/bot-api/me
{
"bot_user_id": "b63c...",
"display_name": "News Bot Russia",
"id": "7f9d...",
"username": "newsbot_russia_v1"
}GET/v1/bot-api/updatesЗабирает bot events через offset/limit/timeout polling.
curl -H "Authorization: Bearer <bot_token>" "https://api.yullama.ru/v1/bot-api/updates?offset=0&limit=50&timeout=30"
{
"items": [
{
"created_at": "2026-04-21T10:42:00Z",
"event_type": "channel.post_created",
"payload": {
"body": "Owner published to channel",
"channel_id": "22d6...",
"post_id": "90ab..."
},
"update_id": 41
}
]
}