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

# Set session structured field values

> Set or clear Structured Field values on a session. Name each field by its ID or field key; Boolean and Number fields take JSON true/false and numbers.

```json theme={"dark"}
{
  "values": [
    { "field_key": "escalated", "value": true },
    { "field_key": "seats", "value": 12 },
    { "field_id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0e9f8d7c", "value": null }
  ]
}
```

A JSON boolean or number sent to a field of another type is rejected with 400. `null` clears a field.


## OpenAPI

````yaml put /chat/sessions/{session_id}/structured-field-values
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /chat/sessions/{session_id}/structured-field-values:
    put:
      summary: Set session structured field values
      description: >-
        Upserts Structured Field values on a session; `null` clears a field.
        Every value is validated against its live field definition (an enum leaf
        choice, a user/team/tag of the organization, or a typed scalar), and a
        bad entry rejects the whole batch. A value on a field whose "show when"
        rule is unmet after the batch is rejected with 400; set the parent field
        in the same batch instead. Values whose field stops applying because a
        parent changed are cleared automatically. Returns the full current list
        with `applicable_field_ids`.
      operationId: setSessionStructuredFieldValues
      parameters:
        - schema:
            type: string
          in: path
          name: session_id
          required: true
          description: The unique identifier of the chat session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetSessionStructuredFieldValuesDto'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionStructuredFieldValueListDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    SetSessionStructuredFieldValuesDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SetSessionStructuredFieldValuesDtoInput'
      type: object
      properties:
        values:
          maxItems: 50
          type: array
          items:
            $ref: '#/components/schemas/SessionStructuredFieldValueInputDto'
      required:
        - values
    SessionStructuredFieldValueListDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionStructuredFieldValueListDto'
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/SessionStructuredFieldValueDto'
        applicable_field_ids:
          type: array
          items:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
      required:
        - data
        - applicable_field_ids
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    SessionStructuredFieldValueInputDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionStructuredFieldValueInputDtoInput'
      type: object
      properties:
        field_id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        value:
          anyOf:
            - type: string
              maxLength: 5000
            - type: 'null'
      required:
        - field_id
        - value
    SessionStructuredFieldValueDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionStructuredFieldValueDto'
      type: object
      properties:
        org_id:
          type: string
        session_id:
          type: string
        field_id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        value:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - org_id
        - session_id
        - field_id
        - value
        - created_at
        - updated_at
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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