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

# Error handling

> How Cotality signals errors — HTTP status codes, the error envelope, common error codes, and what AI agents should do for each class.

> [!NOTE]
>
> This page describes errors from the **REST APIs**, and from the valuation and credit MCP tools
> that wrap them. The property data, CLIP, and market trend analytics MCP tools use a different
> contract — they raise an MCP error carrying a `ToolError` payload and never return a `success`
> field. See [MCP error contract](https://develop.cotality.com/reference/mcp-errors.md) for those tools.

## Error shape

REST errors use the [REST response envelope](https://develop.cotality.com/reference/response-envelope.md#rest-envelope) with
`success: false`. Detail is in the `messages` array.

```json theme={null}
{
  "success": false,
  "count": 0,
  "data": [],
  "messages": [
    { "code": "ENTITLEMENT_DENIED", "message": "Asset not licensed for this token." }
  ]
}
```

## HTTP status codes

| HTTP | Class | Meaning | Agent action |
| - | - | - | - |
| `400` | Validation | Malformed input — bad filter, missing required param, invalid enum value | Fix the request; do not retry as-is |
| `401` | Auth | Missing or expired bearer token | Refresh token; retry once |
| `403` | Entitlement | Token valid but asset not licensed | Stop; surface to user — do not loop |
| `404` | Not found | No property, CLIP, or geography matched | Report no match; never fabricate a value |
| `422` | Semantic | Valid shape but invalid values (e.g., date out of range, unsupported product ID) | Correct values per asset limits |
| `429` | Rate limit | Too many requests | Back off; see [Rate limits](https://develop.cotality.com/reference/rate-limits.md) |
| `5xx` | Server | Transient upstream error | Retry with exponential backoff + jitter; cap at 3 retries |

## Common error codes

| Code | Cause | Fix |
| - | - | - |
| `ENTITLEMENT_DENIED` | Asset or tool not licensed for this token | Contact Cotality account team |
| `CLIP_NOT_FOUND` | Address did not resolve to a CLIP | Re-check and standardize the address; see [Identifiers](https://develop.cotality.com/ontology/identifiers.md) |
| `INVALID_GEOGRAPHY` | `geographyType` / `geographyTypeValues` pair is invalid | Use a supported type and valid code format |
| `OUT_OF_RANGE_DATE` | Requested date is outside the asset's available history or forecast | Adjust to the asset's temporal limits; see [Data freshness](https://develop.cotality.com/ontology/data-freshness.md) |
| `UNSUPPORTED_PRODUCT_ID` | `product_id` is not a supported value | Use a value from the documented enum |
| `DOWNSTREAM_ENCOMPASS_ERROR` | Encompass origin or transaction lookup failed | Verify EPC context; retry once |
| `ORDER_FAILED` | EPC order completed in a failed state | Check `messages` for EPC-specific reason |
| `VALIDATION_FAILED` | Business-rule validation failed on the request payload | Review required fields and conditional rules |

## Guidance for AI agents

**1. Never fabricate on 404**

If a CLIP, property, or geography does not resolve, tell the user — do not invent a value or assume the closest match.

**2. Do not loop on 403**

Entitlement errors will not fix themselves by retrying. Stop immediately and surface the error to the user or escalation path.

**3. Back off on 429 and 5xx**

Use exponential backoff with jitter. Cap retries at 3. Log the full `messages` array for support.

**4. Correct 422 before retrying**

Semantic validation failures (bad dates, bad enums) will recur on retry. Read the `messages` detail to understand the correction needed.

> [!WARNING]
>
> Error codes are illustrative of the common classes. The exact codes and messages returned depend on the specific tool or API endpoint. Always log the full `messages` array.
