---
title: "Validate From Schema"
method: POST
path: "/models/validateFromSchema"
tags: ["Data Model Records"]
---

# Validate From Schema

`POST /models/validateFromSchema`

Requires `enable-data-models-feature` feature flag. Validate data against a json schema, either by schema definition or schema ID. `jsonSchema` or `schemaId` are required parameters.
### Authorization Required:
  - Authenticated

## Query parameters

- `validateRequiredFields` boolean

## Request body

- object
  - `data` object, required — Data to validate against
  - `draftVersion` 'draft-06' | 'draft-07' | 'draft-2019-09' | 'draft-2020-12' — JSON Schema draft version. For more information on JSON Schema draft versions - https://json-schema.org/specification-links
  - `fieldMapping` object[] — Field map to validate against e.g. `[{ field: 'name', model: 'modelId', type: 'string', connectedTo: 'name1' }, { field: 'price', model: 'modelId', type: 'number', connectedTo: 'price1' }]`
    - `connectedTo` string — Property ID of the component that is mapped to the data property
    - `field` string — Property ID of the data property
    - `model` string — ID of the data model the field belongs to
    - `type` string — Type of the data property
  - `jsonSchema` object — Schema to validate data
  - `schemaId` string — Schema ID to validate data

## Response `200`

Successful

- object — An object with a key of `data`, with a value that is an object. That object has keys that are the `fieldMapping` `field` with the matching data property as the value. If no `fieldMapping` is passed, then the passed `data` is returned if no errors are encountered. e.g. Given the data below plus the `fieldMapping` example - **data:** `{ name1: 'shirt', price1: 1, addProp: 'extra' }` **jsonSchema:** `{ title: 'Sample Schema', type: 'object', properties: { name: { type: 'string' }, price: { type: 'number' } }, required: ['name'] }` **Response:** `{ data: { 'modelId': { name: 'shirt', price: 1 } } }`

## Other responses

- `default` — Error

---

[API](https://skmtc.net/unqork/apis/unqork-customer-api.md) · [All operations](https://skmtc.net/unqork/apis/unqork-customer-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/unqork/unqork-customer-api/revisions/112399a67ebb/schema)
