Skip to main content

Create Schema

Endpoint: POST /api/schema

Creates a new schema definition. If a schema with the same name exists, it replaces the existing schema.

Query parameters

ParameterDescriptionTypeRequired/ Optional
newVersionWhether to save a schema as a new version. Default is false.booleanOptional.

Request body

Currently, schemas can be defined in the JSON Schema format. Format the request body with the following parameters:

ParameterDescriptionTypeRequired/ Optional
nameThe name of the schema.stringRequired.
versionThe version number of the schema.stringOptional.
typeSet the schema type as JSON.stringRequired.
dataInclude the JSON Schema parameters here.objectRequired.

Example request body

{
"createTime": 1727378396701,
"updateTime": 1727378396701,
"createdBy": "user@example.com",
"updatedBy": "user@example.com",
"name": "itemSchema",
"version": 1,
"type": "JSON",
"data": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
}
},
"required": [
"productId"
]
}
}

Response

Returns 200, indicating that the schema has been created successfully.

Examples

Create a new schema

Request

curl -X 'POST' \
'https://<YOUR-SERVER-URL>/api/schema?newVersion=false' \
-H 'accept: */*' \
-H 'X-Authorization: <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"name": "itemSchema",
"version": 1,
"type": "JSON",
"data": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
}
},
"required": [
"productId"
]
}
}'

Response

Returns 200, indicating that the schema has been created successfully.

Create a schema with a new version

Request

curl -X 'POST' \
'https://<YOUR-SERVER-URL>/api/schema?newVersion=true' \
-H 'accept: */*' \
-H 'X-Authorization: <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"name": "itemSchema",
"version": 1,
"type": "JSON",
"data": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
},
"productType": {
"description": "Type of the product",
"type": "string"
}
},
"required": [
"productId"
]
}
}'

Response

Returns 200, indicating that the new schema version was created successfully.