> ## 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.

# Create a structured field

> Create a new structured field definition. Use when managing the fields agents fill in on sessions from an external system.



## OpenAPI

````yaml post /structured-fields
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:
  /structured-fields:
    post:
      summary: Create a structured field
      description: >-
        Create a new structured field definition. `key` is its immutable,
        API-safe identifier (lowercase letters, numbers, underscores) —
        workflows reference it by this key, so choose carefully; neither `key`
        nor `type` can be changed after creation. Enum choices are authored
        separately. Field definitions never accept a default value. Pass
        `group_id` to file it under a structured field group; a `show_when`
        parent must be in the same group.
      operationId: createStructuredField
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateStructuredFieldDto'
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StructuredFieldTreeDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    CreateStructuredFieldDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/CreateStructuredFieldDtoInput'
      type: object
      properties:
        key:
          type: string
          pattern: ^[a-z0-9_]{1,100}$
        name:
          type: string
          minLength: 1
          maxLength: 100
        description:
          type: string
          minLength: 1
          maxLength: 1000
        type:
          $ref: '#/components/schemas/StructuredFieldTypeDto'
        show_when:
          anyOf:
            - $ref: '#/components/schemas/StructuredFieldShowWhenDto'
            - type: 'null'
        group_id:
          anyOf:
            - 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)$
            - type: 'null'
      required:
        - key
        - name
        - description
      additionalProperties: false
    StructuredFieldTreeDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/StructuredFieldTreeDto'
      type: object
      properties:
        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)$
        org_id:
          type: string
        key:
          type: string
        name:
          type: string
        description:
          type: string
        type:
          $ref: '#/components/schemas/StructuredFieldTypeDto'
        value:
          type:
            - string
            - 'null'
        position:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        archived_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        show_when_field_id:
          anyOf:
            - 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)$
            - type: 'null'
        show_when_values:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
        group_id:
          anyOf:
            - 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)$
            - type: 'null'
        variants:
          type: array
          items:
            $ref: '#/components/schemas/StructuredFieldVariantTreeDto'
        system_options:
          type: array
          items:
            $ref: '#/components/schemas/StructuredFieldSystemOptionDto'
      required:
        - id
        - org_id
        - key
        - name
        - description
        - type
        - value
        - position
        - archived_at
        - created_at
        - updated_at
        - show_when_field_id
        - show_when_values
        - group_id
        - variants
        - system_options
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    StructuredFieldTypeDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/StructuredFieldTypeDto'
      type: string
      enum:
        - enum
        - text
        - number
        - boolean
        - date
        - user
        - team
        - tag
    StructuredFieldShowWhenDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/StructuredFieldShowWhenDtoInput'
      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)$
        values:
          minItems: 1
          maxItems: 100
          type: array
          items:
            type: string
            minLength: 1
      required:
        - field_id
        - values
    StructuredFieldVariantTreeDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/StructuredFieldVariantTreeDto'
      type: object
      properties:
        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)$
        org_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)$
        parent_id:
          anyOf:
            - 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)$
            - type: 'null'
        value:
          type: string
        variant_display_name:
          type: string
        variant_description:
          type: string
        position:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        archived_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        children:
          type: array
          items:
            $ref: '#/components/schemas/StructuredFieldVariantTreeDto'
      required:
        - id
        - org_id
        - field_id
        - parent_id
        - value
        - variant_display_name
        - variant_description
        - position
        - archived_at
        - created_at
        - updated_at
        - children
      additionalProperties: false
    StructuredFieldSystemOptionDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/StructuredFieldSystemOptionDto'
      type: object
      properties:
        value:
          type: string
        label:
          type: string
        description:
          type:
            - string
            - 'null'
      required:
        - value
        - label
        - description
      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.