QuantaAPI
Dashboard
Guides

Data requirements

Declare the headers and body fields a request must contain, and the rules each value must satisfy.

Request validation
4 min read

Data requirements turn a mock into a contract. Open the Data requirement tab to require headers and body fields; requests that do not comply are rejected with 400 before the response is rendered.

Header requirement

Headers are always strings. You can only require a header and constrain its length.

NAMETYPEREQUIREDDESCRIPTION
NamestringYesHeader name. Matching is case-insensitive.
TypestringFixedAlways string for headers.
Min CharactersnumberNoMinimum accepted length.
Max CharactersnumberNoMaximum accepted length.

Body requirement

NAMETYPEREQUIREDDESCRIPTION
NamestringYesTop-level body field. Matching is case-insensitive.
Typestring | numberYesstring checks length; number checks value range.
Min / Max CharactersnumberFor stringMinimum and maximum accepted length.
Min / Max ValuenumberFor numberMinimum and maximum accepted value.
Top-level fields onlyValidation inspects top-level keys of the body object. Nested objects are not enforced.

How validation runs

  1. The body is read as raw text and parsed as JSON. A body that is not valid JSON is reported as an error.
  2. Only fields declared in the data requirement are checked. Extra fields in the request are allowed.
  3. Names are compared case-insensitively, so X-Tenant and x-tenant are the same header.
  4. A missing field or a value outside its rule adds an entry to the error list.

For GET, HEAD, DELETE, OPTIONS, and other methods without a request body, body rules are skipped entirely and only headers are validated.

What a failed validation returns

The status is 400. The JSON body is your response template rendered with the validation message, and the details are sent in the X-Validation-Errors header as a JSON array.

X-Validation-Errors
[
  {
    "field": "username",
    "source": "body",
    "message": "username must have at least 3 characters"
  }
]
Trigger a validation error
curl -X POST https://quanta-api-backend.vercel.app/endpoints/fetch/users \
  -H "x-collection-api-key: YOUR_COLLECTION_KEY" \
  -H "Content-Type: application/json" \
  -d '{"username":"ab"}'
Validation beats simulationIf a request fails validation, you get 400 even when the error ratio is 100 and a pool entry exists.