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

# Validate From Schema

`POST /models/validateFromSchema`

## Request

- Base URL: `https://env.unqork.io/api/1.0`
- URL: `https://env.unqork.io/api/1.0/models/validateFromSchema`
- Auth: OAuth 2
  - Client credentials
  - Password
  - Token URL: `https://xyzfinancial.unqork.io/api/1.0/oauth2/access_token`
- TypeScript: <https://skmtc.dev/unqork/apis/unqork-customer-api/docs/models/validateFromSchema/post.ts> (a function with typed inputs; its response is checked against the schema)

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.dev/unqork/apis/unqork-customer-api.md) - [All operations](https://skmtc.dev/unqork/apis/unqork-customer-api/llms.txt) - [OpenAPI document](https://skmtc.dev/unqork/apis/unqork-customer-api/revisions/13dad4096373?raw)
