When send or download fails
HTTP status and error field on the public /v1 API.
3 min read
When GET /v1/me, POST /v1/messages/send, or GET /v1/files/:id fails, the response is usually JSON with an error field (snake_case). A successful file download returns raw bytes, not JSON.
Authentication & keys
| HTTP | error | Meaning | What to do |
|---|---|---|---|
| 401 | invalid_api_key | Missing, wrong, or revoked Bearer | Copy a fresh knk_live_… from dashboard → Developer → API keys; use Authorization: Bearer … |
| 403 | scope_required | Key lacks messages:send | Create a key with send scope, or do not call send with a read-only key |
GET /v1/me and GET /v1/files/:id do not require the messages:send scope.
Quota & rate limits
| HTTP | error | Meaning | What to do |
|---|---|---|---|
| 429 | api_quota_exceeded | API send quota exhausted (billing) | Check dashboard → Billing; wait for reset or upgrade |
| 429 | rate_limited | Too many requests in a short window | Wait, backoff, reduce parallelism |
Send message (POST /v1/messages/send)
| HTTP | error | Meaning | What to do |
|---|---|---|---|
| 400 | bad_request | Invalid JSON, forbidden fields (id, sender_id, …), bad to/group_id, url mixed with cards, bad username format | See Send a message; flat body, no body wrapper |
| 402 | ai_budget_insufficient | @ai + AI mention but insufficient token budget | Shorten text or add AI budget on dashboard |
| 403 | forbidden | Not connected, blocked, not a member, deleted room, channel (owner/admin send only), mute/ban | Ensure the integration account can chat to the same target in the app |
| 404 | user_not_found | Unknown username in to | Check spelling (lowercase) |
| 409 | idempotency_replay | Same Idempotency-Key within 1 hour after a successful send | New key for a different message; reuse only to retry the same request — Idempotency |
| 413 | too_large | URL attachment too large | Smaller file or CDN with size limits |
| 502 | upstream_fetch_failed | Server could not fetch attachment url | Public HTTPS URL, valid MIME/size, not blocked by SSRF rules |
| 500 | internal_error | Temporary server fault | Retry; idempotency key is released when send fails |
Form (type: form)
| HTTP | error | Meaning |
|---|---|---|
| 400 | form_fields_forbidden | Body still has inline fields — use form_id only |
| 403 | form_forbidden | form_id is not owned by the key holder |
| 404 | form_not_found | Form ULID does not exist |
Define forms under dashboard → Forms. Sending: Forms.
Download file (GET /v1/files/:id)
| HTTP | error | Meaning | What to do |
|---|---|---|---|
| 401 | invalid_api_key | Same as above | |
| 403 | forbidden | Not in that file’s chat, or view-once | View-once never appears on webhooks and cannot be downloaded |
| 404 | not_found | Wrong file_id | Use attachment.file_id from the webhook |
| 410 | gone | Past 7-day retention | Cannot be recovered |
| 503 | unavailable | Attachment service not ready (some dev setups) | Ensure API + storage are running |
200 = file stream. If-None-Match with ETag = file id → 304 with no body.