Common Patterns
Error Handling
Errors use one response format:
{"error":{"code":"validation_failed","message":"Invalid input","details":[]},"requestId":"request-id"}Use error.code for application logic. error.details is optional and provides validation or limit information. Keep requestId when contacting support.
| Status | What to do |
|---|---|
400 |
Check the Qwetty-Version header (invalid_version) |
401 |
Check the key, expiration, and enabled state |
403 |
Check permissions, IP restrictions, all-channel access, plan access, monthly quota, or a closed messaging window (message_window_closed) |
404 |
Check the resource ID and the key’s organization/channel access |
409 |
Resolve the conflict before retrying; inspect error.code |
410 |
The key’s organization has been deleted (organization_deleted) |
413 |
Reduce the JSON body to at most 1 MiB |
422 |
Correct the request fields or cursor |
429 |
Wait for Retry-After before retrying |
500, 503 |
Retry with backoff, preserving the idempotency key when required |
Idempotency
Section titled “Idempotency”For operations marked with Idempotency-Key in the API reference, generate a unique value of at most 255 characters for each intended operation; a missing key returns 422 idempotency_key_required. Keys are scoped to the API key and the endpoint. Preserve that value and the same request fields across retries.
Completed responses replay for 24 hours. Reusing the key with different input returns 409; concurrent requests with the same key also return 409. A replay still checks current access permissions.
If an operation has an uncertain result, do not send it again with a new key: the provider may already have accepted it. Check message history and contact support with the request ID before attempting a new send.