> ## 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 new training scenario. Use when pushing training scenarios or knowledge into the AI training index from an external pipeline.

# Create a training



## OpenAPI

````yaml post /training
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: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /training:
    post:
      summary: Create a training
      description: >-
        Create a new training scenario. Use type "BEHAVIORAL" for always-active
        instructions (tone, guardrails) or "SCENARIO_SPECIFIC" (default) for
        question-triggered scenarios.
      operationId: createTraining
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTrainingPublicDto'
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingPublicResponseDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    CreateTrainingPublicDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/CreateTrainingPublicDtoInput'
      type: object
      properties:
        title:
          type: string
          description: The scenario title or trigger phrase
        content:
          type: string
          description: The instruction body — how the AI should respond
        type:
          description: >-
            BEHAVIORAL (always active) or SCENARIO_SPECIFIC (semantic match,
            default)
          type: string
          enum:
            - BEHAVIORAL
            - SCENARIO_SPECIFIC
        is_draft:
          description: If true, saved as draft and not used by the AI
          type: boolean
        directory_id:
          description: Directory ID to organize into
          anyOf:
            - type: string
            - type: 'null'
        restricted_to_channels:
          description: Limit to specific channels (empty = all)
          type: array
          items:
            $ref: '#/components/schemas/SessionChannel'
        restricted_to_segments:
          description: Limit to specific segments (empty = all)
          type: array
          items:
            type: string
        metadata:
          description: Arbitrary key-value metadata for external integrations
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        start_time:
          description: >-
            ISO 8601 instant (UTC) when the AI may start using this instruction.
            Null clears the start bound.
          anyOf:
            - type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
            - type: 'null'
        end_time:
          description: >-
            ISO 8601 instant (UTC) when the AI stops using this instruction.
            Null clears the end bound.
          anyOf:
            - type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
            - type: 'null'
      required:
        - title
        - content
    TrainingPublicResponseDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/TrainingPublicResponseDto'
      type: object
      properties:
        id:
          type: string
          description: Unique training ID
        title:
          type: string
          description: The scenario title or trigger phrase (last published version)
        content:
          type: string
          description: >-
            The instruction body — how the AI should respond (last published
            version)
        draft_title:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Draft title being edited (null if no draft exists). Use draft_title
            ?? title.
        draft_content:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Draft body being edited (null if no draft exists). Use draft_content
            ?? content.
        type:
          type: string
          enum:
            - BEHAVIORAL
            - SCENARIO_SPECIFIC
          description: BEHAVIORAL (always active) or SCENARIO_SPECIFIC (semantic match)
        is_draft:
          type: boolean
          description: Draft trainings are saved but not used by the AI
        directory_id:
          anyOf:
            - type: string
            - type: 'null'
          description: Directory this training belongs to
        restricted_to_channels:
          type: array
          items:
            $ref: '#/components/schemas/SessionChannel'
          description: Channels this applies to (empty = all)
        restricted_to_segments:
          type: array
          items:
            type: string
          description: Contact segments this applies to (empty = all)
        current_version:
          anyOf:
            - type: number
            - type: 'null'
          description: Active published version number (null if unpublished draft)
        metadata:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties: {}
            - type: 'null'
          description: Arbitrary key-value metadata for external integrations
        published_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: When the current version was published
        start_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: Active window start (UTC). Null = no start bound.
        end_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: Active window end (UTC). Null = no end bound.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - title
        - content
        - draft_title
        - draft_content
        - type
        - is_draft
        - directory_id
        - restricted_to_channels
        - restricted_to_segments
        - current_version
        - metadata
        - published_at
        - start_time
        - end_time
        - created_at
        - updated_at
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    SessionChannel:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SessionChannel'
      type: string
      enum:
        - web
        - email
        - phone_voice
        - slack
        - sms
        - whatsapp
        - instagram
        - messenger
        - api
        - web_voice
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````