# Validation Failed

The request is well-formed but contains invalid data or violates business rules. Check the `errors` array for details on each invalid field.

**HTTP Status:** `422 Unprocessable Entity`

## Error Codes

| Code | Description |
|  --- | --- |
| `missing_required_field` | A required field is missing |
| `invalid_cpf` | The CPF number is not valid |
| `invalid_cnpj` | The CNPJ number is not valid |
| `invalid_email` | The email address is not valid |
| `invalid_phone` | The phone number is not valid |
| `invalid_document_type` | The document type is not recognized |
| `invalid_file_format` | The uploaded file format is not supported |
| `invalid_amount` | The requested amount is outside the allowed range |
| `invalid_installments` | The number of installments is not valid for this offer |
| `offer_expired` | The credit offer has expired |
| `offer_already_accepted` | This credit offer has already been accepted |
| `simulation_mismatch` | Loan parameters do not match the simulation |
| `kyc_incomplete` | Customer KYC is not complete (cannot create loan) |
| `biometrics_not_required` | Biometrics verification is not required for this customer |
| `field_not_updatable` | The specified field cannot be updated |
| `invalid_url` | The provided URL is not valid |
| `invalid_events` | The webhook events list contains invalid event types |
| `invalid_status` | The provided status value is not valid |
| `invalid_expire_current_in` | The secret rotation expiration value is not valid |


## Example Response


```json
{
  "type": "https://docs.dinie.com/errors/validation-failed",
  "title": "Validation Error",
  "status": 422,
  "detail": "One or more required fields are missing.",
  "code": "missing_required_field",
  "errors": [
    {
      "code": "missing_required_field",
      "param": "cpf",
      "detail": "The cpf field is required."
    }
  ]
}
```

## How to Resolve

- **`missing_required_field`** -- Check the `errors` array for which fields are missing and include them.
- **`invalid_cpf` / `invalid_cnpj`** -- Validate the document number locally before sending. CPF has 11 digits; CNPJ has 14.
- **`invalid_email` / `invalid_phone`** -- Verify the format matches the expected pattern.
- **`invalid_document_type` / `invalid_file_format`** -- Check the API documentation for supported document types and file formats.
- **`invalid_amount`** -- Check the offer's `min_amount` and `max_amount` and adjust your request.
- **`invalid_installments`** -- Use the value from the credit offer or simulation.
- **`offer_expired`** -- Request a fresh credit offer. Offers have a limited validity window.
- **`offer_already_accepted`** -- Each offer can only be used once. Wait for a new offer.
- **`simulation_mismatch`** -- The loan amount, term, or other parameters must match the simulation exactly.
- **`kyc_incomplete`** -- Ensure the customer has completed all required KYC steps before creating a loan.
- **`biometrics_not_required`** -- Do not initiate biometrics for this customer; it is not part of their KYC flow.
- **`field_not_updatable`** -- This field cannot be changed after creation.
- **`invalid_url`** -- Ensure the webhook URL uses HTTPS and is well-formed.
- **`invalid_events`** -- Check the available webhook events list in the documentation.
- **`invalid_status`** -- Use one of the valid status values for this resource.
- **`invalid_expire_current_in`** -- Value must be between 0 and 86400 seconds (24 hours).


## See Also

- [Error Handling guide](/en-us/apis/concepts/errors) -- Full error handling patterns and code examples