# Rate limits & error codes

Canonical URL: https://docs.chartvoyant.com/rate-limits-and-errors/

Every ChartVoyant surface enforces two simultaneous token-bucket windows — a per-second burst and a sustained window — and returns structured, PHI-free error payloads with a correlation ID.

## Rate limit budgets across all surfaces

| Surface & Scope | Burst | Sustained / Cap | When Exceeded |
| --- | --- | --- | --- |
| **REST API & Practice MCP** — per `cvk_` key | 150 req / sec | 3,600 req / min | HTTP `429` + `Retry-After` |
| **REST API & Practice MCP** — per practice total | 400 req / sec | 12,000 req / min | HTTP `429` + `Retry-After` |
| **Self-serve sandbox key** — per key | 38 req / sec | 900 req / min · 5,000 req / day | HTTP `429` + `Retry-After` |
| **FHIR R4** — per SMART token | 300 req / sec | 9,000 req / min | HTTP `429` + `Retry-After` |
| **FHIR R4** — per practice total | 600 req / sec | 18,000 req / min | HTTP `429` + `Retry-After` |
| **SMART Write** — per app per practice | — | 30 writes / min (500 / day full-access) | HTTP `429` + `Retry-After: 60` |
| **Patient MCP** — per `cvpk_` key | 20 req / sec | 300 req / min · 5,000 req / hr | HTTP `429` + `Retry-After` |
| **HL7 v2 Interface** — per `interfaceId` | 20 msg / sec | 600 msg / min (max 2 MiB/msg) | HTTP `200` with generic `MSA\|AE` (ERR `207`) |
| **Public Practice Status** — per caller IP | 5 req / sec | 20 req / min | HTTP `429` |

**Need a higher limit or a migration window?** Email [info@chartvoyant.com](mailto:info@chartvoyant.com?subject=Rate%20limit%20increase%20request) with your key prefix or app ID, traffic pattern, and peak rate. Higher limits carry no fee.

## Handling 429 & exponential backoff

Always inspect `Retry-After` (integer seconds) on `429` responses and add small random jitter before retrying. For `5xx` transient errors, retry idempotent reads with exponential backoff and log the `correlationId`.

## Error payload formats

### ChartVoyant REST API (`application/json`)

```
{
  "error": {
    "code": "forbidden",
    "message": "This API key is read-only; POST is not permitted",
    "correlationId": "01J8ZCSYNTHETIC0001"
  }
}
```

### FHIR R4 & SMART Write (`application/fhir+json`)

```
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "forbidden",
      "diagnostics": "Requested resource is outside the granted SMART scope."
    }
  ]
}
```

## Searchable API error codes

ChartVoyant uses stable string identifiers in `error.code` rather than opaque numeric codes. When escalating to support, share the `code` and `correlationId` — never patient data.

| Code | HTTP | Meaning | Recommended Client Action |
| --- | --- | --- | --- |
| `bad_request` | 400 | Malformed JSON, invalid UUID/date format (use `YYYY-MM-DD`), missing required field, or out-of-order workflow step. | Inspect `error.message`, fix request payload, and do not retry unchanged. |
| `validation_failed` | 400 | Domain validation failed (field-level constraints, incomplete attestation, invalid NPI/code). | Inspect `error.fields` or `error.details` and fix the invalid fields. |
| `unauthorized` | 401 | Missing, unknown, expired, or revoked credential, or wrong secret. Details are intentionally uniform. | Verify `Authorization: Bearer` header, check key expiry, or re-run OAuth authorization. |
| `forbidden` | 403 | Valid credential, but action is not permitted (`read_only` key attempting write, out-of-scope route, or suspended office). | Request appropriate scope/access level or use an allowed route; do not retry blindly. |
| `ai_addon_disabled` | 403 | The optional AI assistant add-on is not enabled for the office. | Practice administrator must enable the add-on first. |
| `module_disabled` | 403 | An optional office module (such as GLP-1) is not enabled for this tenant. | Practice administrator can enable the module under Admin → Modules. |
| `not_found` | 404 | Record does not exist in the key's bound practice (records at another practice also return `404`, never `403`). | Verify the UUID belongs to the authenticated tenant. |
| `method_not_allowed` | 405 | HTTP method not supported on this route (for example `GET` or `DELETE` on `/api/v1/mcp`). | Use the documented HTTP verb. |
| `conflict` | 409 | Concurrent version modification, duplicate unique identifier, or an asynchronous export/job already running. | Re-read current resource state before retrying; never blindly re-POST non-idempotent writes. |
| `rate_limited` | 429 | Per-second burst, per-minute sustained, or daily cap exceeded. | Sleep for `Retry-After` seconds plus jitter, and reduce concurrency. |
| `internal` | 500 | Unexpected server error (generic message to prevent PHI leakage). | Retry idempotent requests with backoff; report persistent failures with `correlationId`. |
| `service_unavailable` | 503 | Upstream dependency or kill-switch (such as paused sandbox issuance) is unavailable. | Honor `Retry-After` if present or check [status.chartvoyant.com](https://status.chartvoyant.com/). |
