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

# Update Preference

> Patch one or more fields of an existing preference.

Only fields supplied in the payload are updated; unset fields are left
untouched.

Args:
    payload:   Partial update — any subset of ``title``, ``subtitle``, ``kind``.
    user:      Authenticated owner.
    thread_id: Target conversation.
    pref_id:   Primary key of the preference to edit.
    db:        Database session.

Returns:
    The updated ``PreferenceSchema``.

Raises:
    HTTPException 404: If no preference with ``pref_id`` exists.



## OpenAPI

````yaml /openapi.json patch /api/workspace/{thread_id}/preferences/{pref_id}
openapi: 3.1.0
info:
  title: HAI-Co² API
  description: Human-AI Co-Construction reference implementation.
  version: 0.1.0
servers:
  - url: https://haico.gr
    description: Production
  - url: https://dev.haico.gr
    description: Development
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/workspace/{thread_id}/preferences/{pref_id}:
    patch:
      tags:
        - Workspace
      summary: Update Preference
      description: |-
        Patch one or more fields of an existing preference.

        Only fields supplied in the payload are updated; unset fields are left
        untouched.

        Args:
            payload:   Partial update — any subset of ``title``, ``subtitle``, ``kind``.
            user:      Authenticated owner.
            thread_id: Target conversation.
            pref_id:   Primary key of the preference to edit.
            db:        Database session.

        Returns:
            The updated ``PreferenceSchema``.

        Raises:
            HTTPException 404: If no preference with ``pref_id`` exists.
      operationId: update_preference_api_workspace__thread_id__preferences__pref_id__patch
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            title: Thread Id
        - name: pref_id
          in: path
          required: true
          schema:
            type: integer
            minimum: 1
            title: Pref Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreferenceUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreferenceSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    PreferenceUpdateRequest:
      properties:
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        subtitle:
          anyOf:
            - type: string
            - type: 'null'
          title: Subtitle
        kind:
          anyOf:
            - type: string
            - type: 'null'
          title: Kind
        locked:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Locked
      type: object
      title: PreferenceUpdateRequest
      description: Payload for editing an existing preference. All fields optional.
    PreferenceSchema:
      properties:
        id:
          type: integer
          title: Id
        thread_id:
          type: string
          title: Thread Id
        title:
          type: string
          title: Title
        subtitle:
          anyOf:
            - type: string
            - type: 'null'
          title: Subtitle
        kind:
          type: string
          title: Kind
        locked:
          type: boolean
          title: Locked
          default: false
        position:
          type: integer
          title: Position
      type: object
      required:
        - id
        - thread_id
        - title
        - kind
        - position
      title: PreferenceSchema
      description: Serialised preference / constraint returned by workspace endpoints.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        A personal access token (`haico_pat_...`), created under Profile → API
        keys. Send it as `Authorization: Bearer <key>`. The browser session JWT
        is also accepted but is an internal mechanism and is not part of the
        public contract.
      scheme: bearer

````