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

# Update session

> Update an existing session. A field the body leaves out keeps its value. See [Sessions](https://docs.galtea.ai/concepts/product/version/session).

> [!WARNING]
>
> You are reading the docs of Galtea 5.22. [Read this page in the latest version](https://docs.galtea.ai/api-reference/sessions/update-session.md).


## OpenAPI

````yaml /v5.22/openapi.json patch /sessions/{id}
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /sessions/{id}:
    patch:
      tags:
        - sessions
      summary: Update session
      description: >-
        Update an existing session. A field the body leaves out keeps its value.
        See [Sessions](https://docs.galtea.ai/concepts/product/version/session).
      operationId: updateSession
      parameters:
        - schema:
            type: string
            description: Session ID
            example: session_123
          required: true
          description: Session ID
          name: id
          in: path
        - $ref: '#/components/parameters/Prefer'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionUpdate'
      responses:
        '200':
          description: >-
            Session updated successfully. The body is the resource as its GET
            answers it.
          headers:
            Content-Location:
              schema:
                type: string
                description: >-
                  The path of the resource in the body; absent when there is no
                  body
              required: false
              description: >-
                The path of the resource in the body; absent when there is no
                body
            Preference-Applied:
              schema:
                type: string
                enum:
                  - return=minimal
                description: 'Present when the API honored `Prefer: return=minimal`'
              required: false
              description: 'Present when the API honored `Prefer: return=minimal`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '204':
          description: >-
            No body: the client sent `Prefer: return=minimal`, or the read after
            the write failed.
          headers:
            Preference-Applied:
              schema:
                type: string
                enum:
                  - return=minimal
                description: 'Present when the API honored `Prefer: return=minimal`'
              required: false
              description: 'Present when the API honored `Prefer: return=minimal`'
        '400':
          description: >-
            Invalid request: a malformed field, or a status outside the session
            statuses
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    Prefer:
      schema:
        $ref: '#/components/schemas/Prefer'
      required: false
      description: >-
        Send `return=minimal` to get no body back from a write and skip reading
        the resource: a create answers `201` with only `Location`, and an update
        answers `204`.
      name: Prefer
      in: header
  schemas:
    SessionUpdate:
      type: object
      properties:
        customId:
          type: string
          nullable: true
          example: custom_session_123
        stoppingReason:
          type: string
          nullable: true
          example: GOAL_ACHIEVED
        error:
          type: string
          nullable: true
          example: External API responded with HTTP 422
        recordingUri:
          type: string
          nullable: true
          example: audio/org_123/session_abc-recording.mp3
        status:
          type: string
          enum:
            - PENDING
            - COMPLETED
            - FAILED
          example: COMPLETED
        metadata:
          nullable: true
          description: Arbitrary metadata, stored as sent.
          example:
            key: value
        id:
          type: string
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        versionId:
          type: string
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        userId:
          type: string
          nullable: true
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        testCaseId:
          type: string
          nullable: true
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        context:
          type: object
          nullable: true
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        isProduction:
          type: boolean
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        runId:
          type: string
          nullable: true
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        createdAt:
          type: string
          format: date-time
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
        deletedAt:
          type: string
          nullable: true
          format: date-time
          description: 'Deprecated and ignored: an update never wrote this field.'
          deprecated: true
          x-sunset: '2028-01-17'
          x-replacement: null
    Session:
      type: object
      properties:
        id:
          type: string
          example: session_123
        customId:
          type: string
          nullable: true
          example: custom_session_123
        versionId:
          type: string
          example: ver_123
        userId:
          type: string
          nullable: true
          example: user_123
        testCaseId:
          type: string
          nullable: true
          example: tc_123
        context:
          type: object
          nullable: true
          additionalProperties:
            nullable: true
          description: >-
            Structured context data. For plain text context, format is { value:
            "..." }
          example:
            value: Session context information
        stoppingReason:
          type: string
          nullable: true
          example: GOAL_ACHIEVED
        recordingUri:
          type: string
          nullable: true
          description: >-
            Storage URI of the full-call recording for a telephony-evaluation
            session, returned under `STORAGE_PUBLIC_BASE_URL` when the
            deployment configures one. Null for non-telephony sessions or before
            the recording is processed. Resolve to a playable URL via GET
            /storage?uri=.
          example: https://files.galtea.ai/audio/org_123/session_abc-recording.mp3
        error:
          type: string
          nullable: true
          example: >-
            External API responded with HTTP 422: Unprocessable Entity —
            {"detail":"model not found"}
        status:
          type: string
          enum:
            - PENDING
            - COMPLETED
            - FAILED
          example: PENDING
        isProduction:
          type: boolean
          description: >-
            True when the session represents real production traffic (no
            associated test case).
          example: false
        isSeed:
          type: boolean
          readOnly: true
          description: >-
            True when the session holds the predefined conversation of a test
            case and is never executed. Server-managed and read-only.
          example: false
        metadata:
          nullable: true
          description: >-
            Arbitrary metadata, returned as stored. Usually an object, but any
            JSON value is accepted.
          example:
            key: value
        runId:
          type: string
          nullable: true
          description: >-
            The run that created this session. Null for a session created
            outside a launch (production traffic, an imported trace). A session
            a run only scored names no run here; filter with `involvedInRunIds`
            to reach those too.
          example: run_123
        endUser:
          type: string
          nullable: true
          readOnly: true
          description: >-
            The end user of the session, set by OTel ingest from the first trace
            that names one. Read-only.
          example: customer_42
        createdAt:
          type: string
          format: date-time
        deletedAt:
          type: string
          format: date-time
          nullable: true
      required:
        - id
        - customId
        - versionId
        - userId
        - testCaseId
        - context
        - stoppingReason
        - recordingUri
        - error
        - status
        - isProduction
        - isSeed
        - runId
        - endUser
        - deletedAt
    Error:
      type: object
      properties:
        error:
          type: string
          example: NotFound
          description: >-
            The HTTP status name in PascalCase, such as `BadRequest` or
            `NotFound`.
        message:
          type: string
          example: Product not found
          description: What went wrong, for a person.
      required:
        - error
        - message
    Prefer:
      type: string
      description: >-
        Send `return=minimal` to get no body back from a write and skip reading
        the resource: a create answers `201` with only `Location`, and an update
        answers `204`.
      example: return=minimal
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.