This endpoint is used to update the schema of a file.
It is used to change the file schema to a new version, and update the file fields accordingly.
The shouldChangeDocumentToNewSchemaVersion flag is used to determine whether the file should be updated to the new schema version.
If set to true, the file will be updated to the new schema version. If set to false, the file will not be updated, and the new schema version will be created as a new schema version.
The shouldCreateCustomIfNotExists flag is used to determine whether a custom schema should be created if the file does not have a custom schema. If set to true, a custom schema will be created if the file does not have a custom schema.
If set to false, no custom schema will be created.
The schemaVersionType field is used to determine the type of schema version that should be created. The allowed values are MAJOR
, MINOR
, and PATCH
.
The fieldPaths field is used to specify the fields that should be updated in the file. The fields that are specified in the fieldPaths field will be updated with the new schema fields.
If a field is not specified in the fieldPaths field, the field will not be updated.
PATCH Schema Endpoint
Overview
Updates an existing schema by modifying its field definitions. This endpoint allows you to add, update, or reconfigure fields within a schema structure.
Endpoint
PATCH /api/schemas/{schemaId}
Request Parameters
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
schemaId | string | Yes | Unique identifier of the schema to be updated |
Request Body
The request body must contain a JSON object with the following structure:
Root Properties
Property | Type | Required | Description |
---|---|---|---|
schemaId | string | Yes | Must match the schema ID in the URL path |
fields | array | Yes | Array of field objects to update or add to the schema |
Field Object Properties
Each field object in the fields
array supports the following properties:
Property | Type | Required | Description |
---|---|---|---|
id | string | No | Unique identifier for the field. If omitted, a new field will be created |
title | string | Yes | Human-readable display name for the field |
description | string | No | Detailed description explaining the field's purpose |
type | string | Yes | Data type of the field. Valid values: STRING , NUMBER , BOOLEAN , DATE , OBJECT |
format | string | No | Specific format hint for the field type (e.g., "email", "url", "text") |
hidden | boolean | No | Whether the field should be hidden in UI displays. Default: false |
internet_context | boolean | No | Indicates if the field contains internet-sourced data. Default: false |
fieldSuggestion | object | No | Configuration for field auto-suggestions |
items | array | No | For array-type fields, defines the structure of array elements |
value | any | No | Default value for the field |
enumValues | array[string] | No | For fields with predefined options, list of valid values |
inlineListType | string | No | For list fields, specifies display type. Valid values: SINGLE , MULTIPLE |
Field Suggestion Object
When providing fieldSuggestion
, include:
Property | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the suggestion configuration |
name | string | Yes | Display name for the suggestion feature |
Request Example
{
"schemaId": "5f5f726eea75272d54e1e1e1",
"fields": [
{
"id": "5f5f726eea75272d54e1e1e2",
"title": "Product Name",
"description": "The display name of the product",
"type": "STRING",
"format": "text",
"hidden": false,
"internet_context": false,
"fieldSuggestion": {
"id": "5f5f726eea75272d54e1e1e3",
"name": "Product Name Suggestions"
},
"items": [],
"value": "Default Product",
"enumValues": [],
"inlineListType": "SINGLE"
},
{
"title": "Price",
"description": "Product price in USD",
"type": "NUMBER",
"format": "currency",
"hidden": false,
"value": 0.00
},
{
"title": "Category",
"description": "Product category selection",
"type": "STRING",
"enumValues": ["Electronics", "Clothing", "Books", "Home & Garden"],
"inlineListType": "SINGLE"
}
]
}
Response
Returns the updated schema object with all modified fields.
Success Response (200 OK)
{
"id": "5f5f726eea75272d54e1e1e1",
"name": "Product Schema",
"fields": [
// Updated field objects with their current configuration
],
"updatedAt": "2024-01-15T10:30:00Z"
}
Error Responses
400 Bad Request
{
"error": "Invalid field type",
"message": "Field type must be one of: STRING, NUMBER, BOOLEAN, DATE, OBJECT"
}
404 Not Found
{
"error": "Schema not found",
"message": "No schema found with ID: 5f5f726eea75272d54e1e1e1"
}
Important Notes
- Field IDs: Include the
id
property to update existing fields. Omit it to create new fields. - Type Validation: The
type
field is strictly validated against the allowed values. - Enum Values: When using
enumValues
, the fieldtype
should typically beSTRING
. - Array Fields: Use the
items
property to define the structure of array elements for complex data types. - Default Values: The
value
property sets the default value when creating new records with this schema.
Use Cases
- Adding new fields to an existing schema
- Updating field metadata (title, description, format)
- Modifying field validation (enum values, type constraints)
- Configuring field display (hidden status, suggestions)
- Setting default values for new records