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

# validation_error

> HTTP 422 — Pydantic / FastAPI request validation failed. The detail field lists the offending fields.

|                 |                                    |
| --------------- | ---------------------------------- |
| **HTTP status** | `422 Unprocessable Entity`         |
| **Code**        | `validation_error`                 |
| **Retry?**      | No — fix the request and re-issue. |

## When this happens

The request matched the route but the body or query parameters failed
schema validation. Examples:

* A required field is missing.
* A field has the wrong type.
* An enum field has a value not in the allowed set.
* A numeric field is out of range.
* `limit` exceeds the per-endpoint cap (see
  [Pagination](/api-reference/pagination)).

## Example response

For a missing required field:

```json theme={null}
{
  "detail": [
    {
      "loc": ["body", "policy_slug"],
      "msg": "Field required",
      "type": "missing"
    }
  ],
  "code": "validation_error",
  "request_id": "5b3f6c7e-7d24-4d40-9b12-3a59c01c6e91",
  "doc_url": "https://docs.lasscyber.com/errors/validation_error"
}
```

`detail` is an **array** of items, each shaped
`{ loc, msg, type }`:

| Field  | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| `loc`  | Path to the offending field. `body.policy_slug` means the JSON body's top-level `policy_slug`. |
| `msg`  | Human-readable message.                                                                        |
| `type` | Pydantic / FastAPI error type, e.g. `missing`, `value_error`, `type_error.integer`.            |

## How to fix

1. Read the `loc` of every item in `detail`.
2. Compare with the auto-generated schema in the
   [API reference](/api-reference/overview).
3. Fix the request and re-send.

## SDK behaviour

| SDK        | Exception                                                                                  |
| ---------- | ------------------------------------------------------------------------------------------ |
| Python     | `agnes.ValidationError` with `field_errors: dict[str, str]` mapping dotted-path → message. |
| TypeScript | `ValidationError` with `fieldErrors: Record<string, string>`.                              |

Both SDKs walk the `detail` array for you so you can branch on
specific fields without re-parsing JSON.
