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

# MM Error Handling

> MM API error codes, HTTP status codes, error response format, and emergency mode behavior.

## Error response format

All API errors return a JSON body:

```json theme={null}
{
  "detail": "Invalid or missing API key"
}
```

Validation errors include location details:

```json theme={null}
{
  "detail": [
    {
      "loc": ["query", "fixtureId"],
      "msg": "Field required",
      "type": "missing"
    }
  ]
}
```

## HTTP status codes

| Status | Description                                                                                         |
| ------ | --------------------------------------------------------------------------------------------------- |
| `200`  | Success                                                                                             |
| `401`  | Unauthorized — invalid or missing API key (must be valid UUID)                                      |
| `404`  | Not found — resource does not exist                                                                 |
| `409`  | Conflict — action blocked by current state (e.g. deactivating with open orders, duplicate resource) |
| `422`  | Validation error — request parameters failed validation                                             |
| `426`  | Upgrade required — WebSocket endpoint called via HTTP                                               |
| `429`  | Rate limited — exceeded 2,000 requests/minute                                                       |
| `500`  | Internal server error                                                                               |
| `502`  | Bad gateway — partial failure (e.g. cancel request succeeded for some orders but not all)           |

## Rate limiting

The MM API enforces **2,000 requests/minute** per client API key.

When rate limited, the API returns `429 Too Many Requests`. Implement exponential backoff in your retry logic (wait 1s, 2s, 4s, etc.).

## Common errors

### Authentication (401)

Your API key is missing, invalid, or not in UUID format.

```bash theme={null}
# Correct
curl -H "X-API-Key: YOUR_API_KEY" \
  https://mmapi.55-tech.com/api/v1/trading/status

# Wrong header name — returns 401
curl -H "Authorization: Bearer your-key" \
  https://mmapi.55-tech.com/api/v1/trading/status

# Missing header — returns 401
curl https://mmapi.55-tech.com/api/v1/trading/status
```

### Not found (404)

The requested resource doesn't exist:

```bash theme={null}
curl -X POST -H "X-API-Key: YOUR_API_KEY" \
  https://mmapi.55-tech.com/api/v1/orders/999999/cancel
# Returns: 404
```

### Validation errors (422)

Required query parameters are missing or have invalid values. Check the `loc` field to identify the problematic parameter.

### WebSocket upgrade (426)

If you call the WebSocket endpoint via HTTP instead of upgrading to a WebSocket connection, you receive a `426 Upgrade Required`.

## WebSocket errors

When subscribing to the WebSocket, these error messages may be returned:

| Error                       | Description                                  |
| --------------------------- | -------------------------------------------- |
| `apiKey required`           | No `apiKey` field in subscribe message       |
| `Invalid apiKey format`     | Not a valid UUID                             |
| `Invalid API key`           | Key not found or client inactive             |
| `Connection limit exceeded` | Already at 5 active connections for this key |
