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

# Update Collection

> Update collection schema.

Allows adding new fields and modifying field properties (except type changes).
Only superadmins (users in the system account) can update collections.



## OpenAPI

````yaml put /api/v1/collections/{collection_id}
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/collections/{collection_id}:
    put:
      tags:
        - collections
      summary: Update Collection
      description: >-
        Update collection schema.


        Allows adding new fields and modifying field properties (except type
        changes).

        Only superadmins (users in the system account) can update collections.
      operationId: update_collection_api_v1_collections__collection_id__put
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            title: Collection Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCollectionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionResponse'
        '400':
          description: Validation error
        '403':
          description: Superadmin access required
        '404':
          description: Collection not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UpdateCollectionRequest:
      properties:
        schema:
          items:
            $ref: '#/components/schemas/FieldDefinition'
          type: array
          minItems: 1
          title: Schema
          description: Updated list of field definitions (at least one required)
      type: object
      required:
        - schema
      title: UpdateCollectionRequest
      description: Request body for updating a collection schema.
    CollectionResponse:
      properties:
        id:
          type: string
          title: Id
          description: Collection ID (UUID)
        name:
          type: string
          title: Name
          description: Collection name
        table_name:
          type: string
          title: Table Name
          description: Physical table name in database
        schema:
          items:
            $ref: '#/components/schemas/SchemaFieldResponse'
          type: array
          title: Schema
          description: Collection schema
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the collection was created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When the collection was last updated
      type: object
      required:
        - id
        - name
        - table_name
        - schema
        - created_at
        - updated_at
      title: CollectionResponse
      description: Response for a created collection.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FieldDefinition:
      properties:
        name:
          type: string
          maxLength: 64
          minLength: 1
          title: Name
          description: Field name (alphanumeric + underscores, starts with letter)
        type:
          type: string
          title: Type
          description: >-
            Field type: text, number, boolean, datetime, email, url, json,
            reference, file, date
        required:
          type: boolean
          title: Required
          description: Whether the field is required
          default: false
        default:
          title: Default
          description: Default value for the field
        unique:
          type: boolean
          title: Unique
          description: Whether the field value must be unique
          default: false
        options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Options
          description: Additional field options
        collection:
          anyOf:
            - type: string
            - type: 'null'
          title: Collection
          description: Target collection name (required for reference type)
        on_delete:
          anyOf:
            - type: string
            - type: 'null'
          title: On Delete
          description: >-
            On delete action: cascade, set_null, restrict (required for
            reference type)
        pii:
          type: boolean
          title: Pii
          description: Whether this field contains PII data
          default: false
        mask_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mask Type
          description: 'Mask type for PII fields: email, ssn, phone, name, full, custom'
        expression:
          anyOf:
            - type: string
            - type: 'null'
          title: Expression
          description: >-
            SQL expression for computed fields (e.g., 'concat(first_name,
            last_name)')
        return_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Return Type
          description: 'Return type for computed fields: text, number, boolean, datetime'
      type: object
      required:
        - name
        - type
      title: FieldDefinition
      description: Definition of a single field in a collection schema.
    SchemaFieldResponse:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
        required:
          type: boolean
          title: Required
          default: false
        default:
          title: Default
        unique:
          type: boolean
          title: Unique
          default: false
        options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Options
        collection:
          anyOf:
            - type: string
            - type: 'null'
          title: Collection
        on_delete:
          anyOf:
            - type: string
            - type: 'null'
          title: On Delete
        pii:
          type: boolean
          title: Pii
          default: false
        mask_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mask Type
        expression:
          anyOf:
            - type: string
            - type: 'null'
          title: Expression
        return_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Return Type
      type: object
      required:
        - name
        - type
      title: SchemaFieldResponse
      description: Schema field in collection response.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````