Appearance
Validation API
Ask whether POST /content would accept a payload, without writing anything. Needs the validation.read ability (or the bare read ability).
This is the write path's own validator, run against your project: a $ref to a component, slot, library, image or file resolves exactly as it would on a create, and required, additionalProperties, every JSON Schema constraint and the storage checks (a plain string fits 255 characters, a library pick names a real entry, an image field holds an image) all apply. A valid: true here is a promise that POST /content accepts the same data right now, against the same schema.
Validate Data
Endpoint: POST /api/v1/validation
Request Body:
| Field | Type | Notes |
|---|---|---|
configuration | object | The component's JSON Schema - the same document POST /component takes. One of configuration or component is required. |
component | string | The uuid of one of your components; the payload is checked against its published schema. |
componentVersion | integer | Optional, with component only: check against that version instead of the published one. |
data | object | Required, may be empty - an empty {} is judged by the schema's required like any other payload. |
Use component when you are about to write to a component that exists: you then validate against the schema the write will use, references and all. Use configuration while you are still designing one - a schema builder checking its work, or a form that has not been saved as a component yet.
bash
curl -X POST "https://admin.flatnode.net/api/v1/validation" \
-H "Authorization: Bearer your-token-here" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"title": "Person",
"type": "object",
"required": ["firstName"],
"properties": {
"firstName": { "type": "string", "minLength": 5 }
}
},
"data": { "firstName": "Chuck" }
}'Response: 200 OK
json
{
"message": "Validation complete.",
"data": { "valid": true, "errors": [] }
}A payload the write path would refuse is also 200 - valid is the answer, the status code is not. The same request with "firstName": "ab":
json
{
"message": "Validation complete.",
"data": {
"valid": false,
"errors": {
"data": [["Minimum string length is 5, found 2"]]
}
}
}errors is exactly the errors object POST /content would have returned in its 422 for the same payload, so a client can handle both with one piece of code. When valid is true, errors is an empty array.
The shape under errors.data is the write path's, warts included: a schema violation arrives as a nested list (one list per violated constraint), while a storage check - a string too long for its column, a library pick naming no entry - arrives as a plain string. Treat each element as either a string or a list of strings.
When the question cannot be answered
A 422 from this endpoint never means "the data is invalid". It means the question itself could not be put, and the key under errors says why:
| What happened | Status | errors key |
|---|---|---|
data is missing, or neither configuration nor component was given | 422 | data, or both configuration and component |
The configuration is not one this API can run - a field without one storage kind, such as a oneOf of a string and an integer (see One kind per field), or a non-object configuration | 422 | configuration |
| The component uuid is not one of your project's components | 422 | component |
| The component has no such version | 422 | componentVersion |
The configuration check is the same one POST /component runs, so a configuration that passes here can be saved as a component.
Example: a component by uuid
bash
curl -X POST "https://admin.flatnode.net/api/v1/validation" \
-H "Authorization: Bearer your-token-here" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"component": "0f2b8c1e-3d4a-4b5c-9e6f-7a8b9c0d1e2f",
"data": {
"title": "Home",
"intro": "…a 300 character introduction…"
}
}'json
{
"message": "Validation complete.",
"data": {
"valid": false,
"errors": {
"data": ["intro is 300 characters. A Text field holds up to 255; for longer values declare the field as Long text (\"format\": \"text\") or Rich text (\"format\": \"richtext\")."]
}
}
}That refusal comes from the storage check behind POST /content, not from JSON Schema - the schema said "type": "string" and was satisfied. It is the kind of answer only the write path's own validator can give, and the reason this endpoint runs it.
What it is useful for
- Showing a form's errors before the editor presses save, with the same messages the save would produce.
- Checking a schema you are designing is one this API can run, before saving it as a component.
- Validating content a script is about to import, against the component it will be imported into, without creating a draft per attempt.
For the full set of what a configuration may contain, see Components.