---
title: "422 Validation error"
description: "One or more fields in your request were missing or wrong. QuotaStack changed nothing."
---

# 422 Validation error

`https://api.quotastack.io/errors/validation-error`

One or more fields in your request were missing or wrong. QuotaStack changed nothing.

## Why it happened

- You left out the `Idempotency-Key` header on a POST or a PATCH. QuotaStack wants it on every write.
- A required field was missing from the body.
- A field held a value QuotaStack does not take, such as an unknown `source`.
- You sent two fields that cannot go together, such as `expires_at` and `duration_seconds`.

## How to fix it

1. Read the `validation_errors` array in the reply. Each entry names one field.
2. Fix that field, then send the request again.
3. Add the header if the field is `Idempotency-Key`. Any string you can make again will do.

### Example response 422

```json
{
  "type": "https://api.quotastack.io/errors/validation-error",
  "title": "Validation Error",
  "status": 422,
  "detail": "One or more fields failed validation.",
  "validation_errors": [
    {
      "field": "duration_seconds",
      "message": "duration_seconds and expires_at are mutually exclusive",
      "code": "invalid"
    }
  ]
}
```

## Which calls return this

- [`POST /v1/customers`](/docs/api/customers#createCustomer)
- [`PATCH /v1/customers/{id}`](/docs/api/customers#updateCustomer)
- [`PATCH /v1/customer-by-external-id/{external_id}`](/docs/api/customers#updateCustomerByExternalId)
- [`POST /v1/customers/{customer_id}/credits/grant`](/docs/api/credits#grantCustomerCredits)
- [`POST /v1/customers/{customer_id}/credits/adjust`](/docs/api/credits#adjustCustomerCredits)
- [`GET /v1/customers/{customer_id}/overage`](/docs/api/credits#getCustomerOverage)
- [`POST /v1/customer-by-external-id/{external_id}/credits/grant`](/docs/api/credits#grantCustomerCreditsByExternalId)
- [`POST /v1/customer-by-external-id/{external_id}/credits/adjust`](/docs/api/credits#adjustCustomerCreditsByExternalId)
- [`GET /v1/customer-by-external-id/{external_id}/overage`](/docs/api/credits#getCustomerOverageByExternalId)
- [`POST /v1/entitlements/consume`](/docs/api/entitlements#consumeEntitlement)
- [`POST /v1/usage`](/docs/api/usage#recordUsage)
- [`POST /v1/imports/customers`](/docs/api/imports#importCustomer)
- [`POST /v1/subscriptions`](/docs/api/subscriptions#createSubscription)
- [`POST /v1/subscriptions/{id}/upgrade`](/docs/api/subscriptions#upgradeSubscription)
- [`POST /v1/subscriptions/{id}/downgrade`](/docs/api/subscriptions#downgradeSubscription)
- [`POST /v1/plans`](/docs/api/plans#createPlan)
- [`POST /v1/plans/{id}/variants/{vid}/entitlements`](/docs/api/plans#attachVariantEntitlement)
- [`PATCH /v1/plans/{id}/variants/{vid}/entitlements/{billable_metric_key}`](/docs/api/plans#updateVariantEntitlement)
- [`POST /v1/metering-rules`](/docs/api/metering-rules#createMeteringRule)
- [`POST /v1/billable-metrics`](/docs/api/billable-metrics#createBillableMetric)
- [`PATCH /v1/billable-metrics/{key}`](/docs/api/billable-metrics#updateBillableMetric)
- [`POST /v1/webhooks/events/{id}/redeliver`](/docs/api/webhooks#redeliverWebhookEvent)
- [`POST /v1/webhooks/test`](/docs/api/webhooks#sendTestWebhook)

## See also

- [Idempotency](/docs/concepts/idempotency)
