API

Webhook / ロングポーリング

setWebhook は getUpdates と競合します; ローカルポーリングの前に webhook を削除します。

認証: Authorization: Bearer sbot_…

POST/api/v1/bots/setWebhook
Bot Token

setWebhookWebhook を構成する

Bot TokenでWebhookを構成します(開発者JWTエンドポイントの代替)。`Bot.delivery_mode`を`webhook`に設定します。

  • 必須: url (HTTPSである必要があります)
  • 配信に強く必要: secret_token (これがないと、webhookの配信に失敗します—プラットフォームは署名できません)
  • Optional: allowed_updates[], allowed_ips[], max_connections (1..100, default 40), drop_pending_updates (default false)
  • Returns: webhook (redacted), migrated_update_count, dropped_update_count
  • Side effect: Bot.delivery_mode = webhook
POST/api/v1/bots/deleteWebhook
Bot Token

deleteWebhookWebhook を削除します

現在の Webhook 構成を削除し、アクティブな POST 配信を停止します。ロボット配信モードは自動的に `polling` に切り替わり、代わりに `getUpdates` プルを使用できます。

  • オプション:drop_pending_updates (デフォルトはfalse; falseの場合、保留中のUpdatesはgetUpdatesキューに移動します)
  • 返却:bot_id / delivery_mode = "polling" / migrated_update_count / dropped_update_count
POST/api/v1/bots/getUpdates
Bot Token

getUpdatesgetUpdates 長文 Polling

在 `polling` 模式下拉取等待中的 Update。无公网 IP 也能起 bot;与 webhook 模式互斥(webhook 模式下调用该端点会返回 409)。

  • オプション: offset (update_seq >= offset のエントリをプルします。次のオフセットとして「前のバッチの最後の update_seq + 1」を使用することをお勧めします。これは ack と同等です)
  • オプション: limit (1..100、デフォルトは 100)
  • オプション: timeout (長いポーリング秒数、0 はすぐに返されます、最大 50、デフォルトは 0)
  • オプション: allowed_updates[] (["message","callback_query"] など、デフォルト = all)
  • リターン:{ updates: [{ update_id, type, message?, callback_query?, update_seq }] }
  • 競合: Webhook モードで呼び出されました → 409 Conflict: can't use getUpdates method while webhook is active
GET/api/v1/bots/getWebhookInfo
Bot Token

getWebhookInfoWebhook 情報を取得する

返回当前 Webhook 配置摘要 + 平台出站 IP,方便客户在防火墙做白名单。

  • Returns: { url, has_custom_certificate, pending_update_count, allowed_updates, allowed_ips, last_error_date, last_error_message, last_delivery_at, max_connections, delivery_mode, platform_egress_ips[] }
  • platform_egress_ips are platform egress IPs; delivery_mode is webhook or polling