RU Open Web

Type to search client APIs, Bot API methods, and guides.

Build Your Own Client — Error Codes & Rate Limits
Build Your Own Client Error Codes & Rate Limits

Error Codes & Rate Limits

Canonical JSON error contract, HTTP status mappings, custom api_id RPM quotas, and FLOOD_WAIT / SLOWMODE_WAIT backoff handling.

All REST and WebSocket RPC errors use a consistent structured JSON schema and uppercase symbolic error string so clients never need to parse human-readable descriptions.

Canonical error envelope

{
  "ok": false,
  "success": false,
  "error_code": 429,
  "error": "FLOOD_WAIT",
  "description": "Rate limit exceeded. Retry in 14 seconds.",
  "message": "Rate limit exceeded. Retry in 14 seconds.",
  "parameters": {
    "retry_after": 14
  },
  "retry_after": 14
}

HTTP responses triggered by 429 limits also include a standard Retry-After response header.

Error code reference

HTTP StatuserrorMeaning & Client Handling
400BAD_REQUESTInvalid parameter format or constraint violation
400 / 401API_ID_INVALIDX-Api-Id is malformed, unknown, or revoked
401API_HASH_INVALIDMissing or invalid X-Api-Hash for a custom api_id >= 100000
401UNAUTHORIZEDMissing, malformed, expired, or wrong-scope JWT
401SESSION_REVOKEDSession terminated remotely; wipe local credentials and prompt re-login
401TWO_FACTOR_REQUIREDCloud 2FA password required to finish sign-in
403FORBIDDENInsufficient permissions for the target resource
403CHAT_WRITE_FORBIDDENNot a member, muted, or restricted from sending media in chat
403CHAT_FORWARDS_RESTRICTEDForwarding/copying disabled by channel or group admins
403USER_PRIVACY_RESTRICTEDAction blocked by recipient’s privacy rules
403USER_IS_BLOCKEDSender is blocked by the recipient
404NOT_FOUNDChat, message, user, or invite code does not exist
409CONFLICT / USERNAME_OCCUPIEDUniqueness or state conflict (choose another username)
429FLOOD_WAITPer-IP, auth, or per-api_id sliding-window RPM limit exceeded
429SLOWMODE_WAITChat slowmode cooldown still active; sleep parameters.retry_after seconds
400 / 500UNKNOWN_METHOD / INTERNAL_ERRORUnsupported WS RPC type or transient server error
503SERVICE_UNAVAILABLEStorage, database, or upstream worker temporarily busy

Custom app rate limits & backoff rules

  • Every newly created custom app (api_id >= 100000) starts with a default quota of 600 RPM across authenticated requests plus anti-abuse caps on unauthenticated /api/auth/* endpoints.
  • Retry strategy: on 429 (FLOOD_WAIT or SLOWMODE_WAIT), read parameters.retry_after (falling back to the Retry-After HTTP header), pause queued retries on that endpoint/chat for retry_after + 0.25s jitter, and never tight-loop retry auth or login calls.
  • On 401 SESSION_REVOKED, do not call /api/auth/refresh in a loop — drop local session tokens immediately.