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
| Parameter | Description | Type | Required/ Optional |
|---|---|---|---|
| newVersion | Whether to save a schema as a new version. Default is false. | boolean | Optional. |
Request body
Currently, schemas can be defined in the JSON Schema format. Format the request body with the following parameters:
| Parameter | Description | Type | Required/ Optional |
|---|---|---|---|
| name | The name of the schema. | string | Required. |
| version | The version number of the schema. | string | Optional. |
| type | Set the schema type as JSON. | string | Required. |
| data | Include the JSON Schema parameters here. | object | Required. |
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.