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.
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| Name | string | Yes | Header name. Matching is case-insensitive. |
| Type | string | Fixed | Always string for headers. |
| Min Characters | number | No | Minimum accepted length. |
| Max Characters | number | No | Maximum accepted length. |
Body requirement
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| Name | string | Yes | Top-level body field. Matching is case-insensitive. |
| Type | string | number | Yes | string checks length; number checks value range. |
| Min / Max Characters | number | For string | Minimum and maximum accepted length. |
| Min / Max Value | number | For number | Minimum and maximum accepted value. |
Top-level fields onlyValidation inspects top-level keys of the body object. Nested objects are not enforced.
How validation runs
- The body is read as raw text and parsed as JSON. A body that is not valid JSON is reported as an error.
- Only fields declared in the data requirement are checked. Extra fields in the request are allowed.
- Names are compared case-insensitively, so
X-Tenantandx-tenantare the same header. - 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.