Guides
Webhook guide
Prefer webhooks when you have public HTTPS. Mutually exclusive with getUpdates.
When to use
Use webhooks when your bot endpoint is publicly reachable. For local dev without a public URL, use long polling.
Steps
- Expose an
https://endpoint (self-signed certs usually fail). - Set URL +
secret_tokenin the console or viaPOST /api/v1/bots/setWebhook. - Verify V2 signature:
X-StarIM-Signature-V2+X-StarIM-Timestampovertimestamp + "." + rawBody. UseX-StarIM-Update-Idfor idempotency (±300s skew in the official SDK). - Confirm deliveries in the console Delivery logs panel.
Example
curl -X POST "$API/bots/setWebhook" \
-H "Authorization: Bearer $SOCHAT_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/hook","secret_token":"your-secret"}'
Limits & errors
- Conflicts with
getUpdates→409while a webhook is active. - 15s timeout; retries 1m/5m/15m/1h then
dead_letter. - Egress IPs:
getWebhookInfo.platform_egress_ips.
Do not parse JSON before signature verification. Prefer the official SDK webhook helpers.
