Update file schema

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

ParameterTypeRequiredDescription
schemaIdstringYesUnique identifier of the schema to be updated

Request Body

The request body must contain a JSON object with the following structure:

Root Properties

PropertyTypeRequiredDescription
schemaIdstringYesMust match the schema ID in the URL path
fieldsarrayYesArray of field objects to update or add to the schema

Field Object Properties

Each field object in the fields array supports the following properties:

PropertyTypeRequiredDescription
idstringNoUnique identifier for the field. If omitted, a new field will be created
titlestringYesHuman-readable display name for the field
descriptionstringNoDetailed description explaining the field's purpose
typestringYesData type of the field. Valid values: STRING, NUMBER, BOOLEAN, DATE, OBJECT
formatstringNoSpecific format hint for the field type (e.g., "email", "url", "text")
hiddenbooleanNoWhether the field should be hidden in UI displays. Default: false
internet_contextbooleanNoIndicates if the field contains internet-sourced data. Default: false
fieldSuggestionobjectNoConfiguration for field auto-suggestions
itemsarrayNoFor array-type fields, defines the structure of array elements
valueanyNoDefault value for the field
enumValuesarray[string]NoFor fields with predefined options, list of valid values
inlineListTypestringNoFor list fields, specifies display type. Valid values: SINGLE, MULTIPLE

Field Suggestion Object

When providing fieldSuggestion, include:

PropertyTypeRequiredDescription
idstringYesUnique identifier for the suggestion configuration
namestringYesDisplay 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 field type should typically be STRING.
  • 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
Language
Credentials
Header
Click Try It! to start a request and see the response here!