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

# Update Schema

> Updates an existing schema.
Automatically increments the version number.
Only description and schema_string can be updated.


## Path Parameters

<ParamField path="schema_id" type="string" required>
  The unique identifier of the schema to update.
</ParamField>

## Request Body

```json Request theme={null}
{
  "description": "Updated schema with more fields",
  "schema_string": {
    "fields": [
      "invoice_number",
      "date",
      "total",
      "customer_name",
      "items",
      "tax",
      "currency",
      "payment_terms"
    ]
  }
}
```

## Response

```json Success Response (200) theme={null}
{
  "success": true,
  "data": {
    "id": "b3376c85-86e0-476e-aee9-5f05afaa05ea",
    "name": "invoice_schema_v1",
    "type": "invoice",
    "description": "Updated schema with more fields",
    "schema_string": "{\"fields\": [...]}",
    "version": 2,
    "is_active": true,
    "created_at": "2024-01-18T12:34:56Z",
    "updated_at": "2024-01-18T12:35:56Z"
  }
}
```

## Examples

### Update a Schema

```bash Curl theme={null}
curl -X PUT "https://api.invaro.ai/api/v1/schemas/id/b3376c85-86e0-476e-aee9-5f05afaa05ea" \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Updated invoice schema with additional fields",
    "schema_string": {
      "fields": [
        "invoice_number",
        "date",
        "total",
        "customer_name",
        "items",
        "tax",
        "gst_number",
        "payment_terms",
        "currency",
        "due_date"
      ]
    }
  }'
```


## OpenAPI

````yaml PUT /api/v1/schemas/id/{schema_id}
openapi: 3.0.0
info:
  title: Invaro Document Processing API
  description: API for processing bank statements and invoices using OCR and AI
  version: 1.0.0
  contact:
    name: Invaro Support
    email: support@invaro.ai
    url: https://docs.invaro.ai
servers:
  - url: https://api.invaro.ai/api/v1
    description: Production API
security:
  - bearerAuth: []
paths:
  /api/v1/schemas/id/{schema_id}:
    parameters:
      - name: schema_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: The unique identifier of the schema.
    put:
      tags:
        - Schema Management
      summary: Update Schema
      description: |-
        Updates an existing schema.
        Automatically increments the version number.
        Only description and schema_string can be updated.
      operationId: updateSchema
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                description:
                  type: string
                  description: Updated description for the schema
                  example: Updated schema with more fields
                schema_string:
                  type: object
                  description: The updated schema definition itself
                  properties:
                    fields:
                      type: array
                      items:
                        type: string
                      example:
                        - invoice_number
                        - date
                        - total
                        - currency
      responses:
        '200':
          description: Schema updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/SchemaObject'
components:
  schemas:
    SchemaObject:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: b3376c85-86e0-476e-aee9-5f05afaa05ea
        user_id:
          type: string
          format: uuid
          example: b4825725-605b-4374-a64e-c40896b5a0e8
        name:
          type: string
          example: invoice_schema_v1
        type:
          type: string
          enum:
            - invoice
            - bank_statement
          example: invoice
        description:
          type: string
          example: Schema for parsing standard invoices
        schema_string:
          type: string
          description: JSON string representation of the schema fields
          example: '{"fields": [...]} Gzip Base64 format'
        version:
          type: integer
          example: 1
        is_active:
          type: boolean
          example: true
        created_at:
          type: string
          format: date-time
          example: '2024-01-18T12:34:56Z'
        updated_at:
          type: string
          format: date-time
          example: '2024-01-18T12:34:56Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````