> ## Documentation Index
> Fetch the complete documentation index at: https://docs.file.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update file schema

> This endpoint is used to patch the schema fields that are associated with the file types in the workspace.

The response will contain a list of schemas that are associated with the file types in the workspace.

The `fileId` field is used to specify the file that should be changed to the new schema version.

The `schemaId` field is used to specify the schema that should be updated.

The `shouldCreateCustomIfNotExists` field is used to specify whether a custom schema should be created if it does not exist.

The `schemaVersionType` field is used to specify the type of schema version to be create. The allowed values are `MAJOR`, `MINOR`, and `PATCH`.

The `shouldChangeDocumentToNewSchemaVersion` field is used to specify whether the document should be changed to the new schema version.

The `fieldPaths` field is used to specify the fields that should be updated.

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.


## OpenAPI

````yaml patch /prod/v1/files/schema
openapi: 3.0.0
info:
  title: Public API
  description: >-

    ### Welcome to fileAI’s Public API Documentation.

    This API allows users to check the health of the system, upload and manage
    files, and manage AI Schemas.

    Should you have any questions, please reach out to fileAI via the “Contact a
    Developer” link below.



    [Contact a Developer](mailto:support@file.ai)



    ### Prerequisites


    Before using our API, please ensure you complete the following prerequisites

    - You must have a fileAI account. Sign up or login
    [here](https://orion.file.ai/en/sign-up)

    - You must have an API Key. After creating your fileAI account, you can
    generate your API Key. Refer to the Authentication section below for more
    details.



    ### Authentication

    All API requests require an API key for authentication.

    - To obtain your API key, please log in to your fileAI account and navigate
    to Project Settings in your dashboard

    - Keep your API key secure and do not share it publicly.


    ![Authentication](https://fileai-static-assets.s3.us-west-2.amazonaws.com/public-api-service/authentication.png)


    ### How to Use Your API Key

    Once you have your API key:

    - Click the Authorize button on the top-right of this page

    - Enter your API Key under Value

    - Click Authorize to start making authenticated requests directly from the
    documentation


    ![How to Use Your API
    Key](https://fileai-static-assets.s3.us-west-2.amazonaws.com/public-api-service/how-to-use-api-keys.png)
        
  version: '1.0'
  contact: {}
servers:
  - url: https://api.orion.file.ai
security: []
tags:
  - name: Public API V1
paths:
  /prod/v1/files/schema:
    patch:
      tags:
        - Public API V1
      summary: Update file schema
      description: >-
        This endpoint is used to patch the schema fields that are associated
        with the file types in the workspace.


        The response will contain a list of schemas that are associated with the
        file types in the workspace.


        The `fileId` field is used to specify the file that should be changed to
        the new schema version.


        The `schemaId` field is used to specify the schema that should be
        updated.


        The `shouldCreateCustomIfNotExists` field is used to specify whether a
        custom schema should be created if it does not exist.


        The `schemaVersionType` field is used to specify the type of schema
        version to be create. The allowed values are `MAJOR`, `MINOR`, and
        `PATCH`.


        The `shouldChangeDocumentToNewSchemaVersion` field is used to specify
        whether the document should be changed to the new schema version.


        The `fieldPaths` field is used to specify the fields that should be
        updated.
      operationId: PublicAPIController_updateSchemaFieldsPartial
      parameters: []
      requestBody:
        required: true
        description: Update file schema
        content:
          application/json:
            schema:
              type: string
            examples:
              example1:
                value:
                  fileId: f739da3b-d8cb-4f62-8174-4d387c28a5ac
                  schemaId: 689eaa87aea205bcfc0f0201
                  shouldCreateCustomIfNotExists: true
                  schemaVersionType: MINOR
                  shouldChangeDocumentToNewSchemaVersion: true
                  fieldPaths:
                    - path: /Receipt Number
                      mode: CREATE
                      attributes:
                        type: string
                        format: null
                        title: Receipt Number
                        hidden: false
                        internet_context: false
                        enumValues: []
                        description: Receipt Number
      responses:
        '200':
          description: The schema is patched
          content:
            application/json:
              example:
                id: 689eaa87aea205bcfc0f0201
                fields:
                  - id: 689eaa87aea205bcfc0f0201
                    name: Receipt Number
                    type: string
                    format: null
                    title: Receipt Number
                    hidden: false
                    internet_context: false
                    enumValues: []
                    description: Receipt Number
                blueprintId: 689eaa87aea205bcfc0f0201
                originalSchemaId: 689eaa87aea205bcfc0f0201
                schemaHistoryId: 689eaa87aea205bcfc0f0201
                schemaHistoryVersionNumber: 1
                fileId: 689eaa87aea205bcfc0f0201
                blueprintMode: USER
                schemaType: SYSTEM
                state: ACTIVE
                usageApprovalState: DRAFT
                schemaOverrideType: NONE
                aiSchemaVersion: v3
                createdAt: '2025-03-31T09:50:56.068Z'
                updatedAt: '2025-03-31T09:50:56.068Z'
                deletedAt: null
                deletedBy: null
              schema:
                type: object
                properties:
                  id:
                    type: string
                  fields:
                    type: array
                    items:
                      type: object
                  blueprintId:
                    type: string
                  originalSchemaId:
                    type: string
                  schemaHistoryId:
                    type: string
                  schemaHistoryVersionNumber:
                    type: number
                  fileId:
                    type: string
                  blueprintMode:
                    type: string
                  schemaType:
                    type: string
                  state:
                    type: string
                  usageApprovalState:
                    type: string
                  schemaOverrideType:
                    type: string
                  aiSchemaVersion:
                    type: string
                  createdAt:
                    type: string
                  updatedAt:
                    type: string
                  deletedAt:
                    type: string
                  deletedBy:
                    type: string
        '401':
          description: Invalid API key | API key is missing
          content:
            application/json:
              example:
                message: Invalid API key | API key is missing
                error: Unauthorized
                statusCode: 401
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '403':
          description: Access denied. You are in readonly mode.
          content:
            application/json:
              example:
                message: Access denied. You are in readonly mode.
                error: Forbidden
                statusCode: 403
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '422':
          description: Invalid schemaId | Invalid field paths
          content:
            application/json:
              example:
                message: Invalid schemaId | Invalid field paths
                error: Unprocessable Entity
                statusCode: 422
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                statusCode: 429
                message: Too Many Requests
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                  message:
                    type: string
      security:
        - x-api-key: []
components:
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````