# Errors and limits

HTTP statuses, close codes and limits of the Enhancer API.

Most failures show up as an HTTP status when the WebSocket opens. After that, the socket is closed with a code.

## When connecting (HTTP status)

| Status | Body | Meaning | What to do |
| --- | --- | --- | --- |
| 400 | `bad redirect: ...` | Redirect missing, or not a `ws://` / `wss://` URL | Fix the redirect parameter or path |
| 401 | `unauthorized` | API key missing or wrong | Check the key; for carriers, use the path form |
| 402 | `Zero Balance please recharge.` | Wallet is empty | Add credits, then call again |
| 503 | `service temporarily unavailable` | Key check briefly unavailable | Retry |
| 503 | `relay capacity full` | At the connection limit | Retry, and tell us your peak concurrency |

## After connecting (close code)

| Code | Reason | Meaning |
| --- | --- | --- |
| 1000 | `relay teardown` | Normal end of the call |
| 4001 | `denoise unavailable` | The noise-removal engine couldn't take the call |
| 4002 | `redirect target unreachable` | Your redirect URL didn't accept the connection within 10 s |

## Limits

- **32 KB per message.** Keep every message under 32 KB, including `playAudio` from your bot. A bigger message ends the call. Base64 PCM16 at 8 kHz fits about 1 second of audio in 32 KB.
- **Keep reading.** If your redirect socket stops reading for 5 seconds, the call is dropped.
- **10-second connect.** Your redirect must accept the connection within 10 seconds.
- **Concurrency.** Tell us your expected peak of simultaneous calls before you launch.
