> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio watermark detection errors

> Error codes, HTTP status codes, WebSocket error frames, and close codes returned by the Telnyx audio watermark detection API.

The audio watermark detection API returns errors in the standard Telnyx format. The HTTP endpoint and the WebSocket handshake answer with an `errors` array. An open WebSocket session sends JSON error frames and closes with a WebSocket close code.

## HTTP errors

`POST /v2/audio_watermark_detections` and the upgrade request of the WebSocket endpoint return errors in this shape:

```json theme={null}
{
  "errors": [
    {
      "code": "37003",
      "title": "Unsupported audio format",
      "detail": "The file is not audio this API reads: WAV, MP3, FLAC, OGG (Vorbis or Opus) or AIFF, up to 8 channels",
      "source": { "pointer": "/file" }
    }
  ]
}
```

`code` and `title` are stable. `detail` is a human-readable explanation; do not parse it. `source.pointer` names the request field when the error is about one.

### Error codes

| Status | Code | Title | Cause | What to do |
| - | - | - | - | - |
| 400 | `10015` | Bad Request | The body is not `multipart/form-data`, or the multipart body cannot be read. | Send the audio as a `multipart/form-data` part named `file`. |
| 401 | `10009` | Authentication failed | The API key is missing or invalid. | Send `Authorization: Bearer YOUR_API_KEY`. |
| 403 | `10038` | Feature not permitted | The account level does not permit watermark detection. Pretrial and everroam accounts cannot use it. | Upgrade the account. |
| 413 | `37001` | Audio file too large | The file is larger than 100 MB. | Send a shorter or more compressed file. |
| 413 | `37002` | Audio too long | A channel is longer than 60 minutes. | Cut the recording into parts of 60 minutes or less. |
| 415 | `37003` | Unsupported audio format | The file is not WAV, MP3, FLAC, OGG (Vorbis or Opus), or AIFF, or it has more than 8 channels. | Convert the file, for example with `ffmpeg -i input.m4a output.wav`. |
| 422 | `10004` | Missing required parameter | The request has no `file` part. | Send the audio in the `file` part. |
| 422 | `37004` | Invalid audio | The file is empty or contains no audio. | Check the file. |
| 422 | `37005` | Data locality mismatch | The organization is pinned to a data locality that this endpoint does not serve. | Contact support. |
| 429 | `10011` | Too many requests | The request rate limit was exceeded. | Retry with exponential backoff. |
| 500 | `10007` | Unexpected error | Detection failed unexpectedly. | Retry. If the error persists, contact support with the `X-Request-Id` response header. |
| 503 | `37006` | Detection temporarily unavailable | Detection is busy or restarting. | Retry after the number of seconds in the `Retry-After` header. |

The WebSocket upgrade request can fail with `401`, `403`, or `422` (`37005`) before the connection opens.

## WebSocket errors

During a session, the server sends errors as JSON text frames:

```json theme={null}
{
  "type": "error",
  "code": "invalid_params",
  "message": "sample_rate is required: the audio's rate in Hz, 8000-48000"
}
```

`code` is a stable identifier. `message` is a human-readable description; do not parse it.

### WebSocket error codes

| Error code | Close code | Cause |
| - | - | - |
| `invalid_params` | 1008 | A query parameter is missing or has an unsupported value: `format`, `sample_rate`, or `channels`. |
| `max_session_duration` | 1008 | The session reached 590 seconds or 60 minutes of audio. The server sends the `summary` message before it closes. |
| `internal_error` | 1011 | Detection failed. Reconnect and send the audio again. |
| `overloaded` | 1013 | The service has too many open sessions. Reconnect after a short wait. |
| `chunk_too_large` | None, the session continues | The binary frame is larger than 65,536 bytes. The server drops the frame. |
| `decode_error` | None, the session continues | The frame length is not a whole number of samples for all channels. The server drops the frame. |
| `unsupported_message` | None, the session continues | The text frame is not `{"type": "end_of_stream"}`. |

### Close codes

The close reason is the error code. Before every close that the server makes with a code other than `1000`, it sends the matching error frame.

| Close code | Reason | What to do |
| - | - | - |
| 1000 | `end_of_stream` | Nothing. Normal end, after the `summary` message. |
| 1008 | `invalid_params` | Fix the query parameter before you reconnect. |
| 1008 | `max_session_duration` | The `summary` message covers the audio received so far. Open a new session for the rest. |
| 1011 | `internal_error` | Reconnect and send the audio again. |
| 1013 | `overloaded` | Reconnect after a short wait, with exponential backoff. |

A connection that closes with any other code, for example `1001` or `1012` while the server restarts, or a network failure, ends without a `summary` message. Reconnect with exponential backoff and send the audio again: the service keeps no state between connections.
