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

# Errors

> Understand API error responses and status codes

# Errors

The Gomry API uses standard HTTP status codes to indicate the outcome of a request. Errors return a JSON body with an `error` field describing the issue.

## Error Response Format

```json theme={null}
{
  "error": "Human-readable error message"
}
```

For validation errors, additional detail may be included:

```json theme={null}
{
  "error": "Invalid pagination parameters",
  "details": {
    "fieldErrors": {
      "page_size": ["Number must be less than or equal to 200"]
    }
  }
}
```

## Status Codes

| Code  | Meaning                   | When It Happens                                               |
| ----- | ------------------------- | ------------------------------------------------------------- |
| `200` | **OK**                    | Request succeeded                                             |
| `400` | **Bad Request**           | Invalid query parameters or request body                      |
| `401` | **Unauthorized**          | Missing or invalid API key                                    |
| `404` | **Not Found**             | Resource doesn't exist or doesn't belong to your organization |
| `429` | **Too Many Requests**     | Rate limit exceeded — slow down and retry                     |
| `500` | **Internal Server Error** | Something went wrong on our end                               |

## Handling Errors

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch(url, { headers: { "X-API-KEY": apiKey } });

  if (!response.ok) {
    const { error } = await response.json();
    
    switch (response.status) {
      case 401:
        console.error("Authentication failed:", error);
        break;
      case 404:
        console.error("Resource not found:", error);
        break;
      case 429:
        // Retry after a short delay
        await new Promise((r) => setTimeout(r, 2000));
        break;
      default:
        console.error(`API error (${response.status}):`, error);
    }
  }
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(url, headers={"X-API-KEY": api_key})

  if response.status_code == 429:
      import time
      time.sleep(2)
      # retry...
  elif not response.ok:
      error = response.json().get("error", "Unknown error")
      raise Exception(f"API error ({response.status_code}): {error}")
  ```
</CodeGroup>

<Note>
  A `404` response does **not** confirm the resource doesn't exist — it may belong to a different organization. The API intentionally returns `404` instead of `403` to avoid leaking information about other organizations' data.
</Note>
