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

# Create a chat

> Creates a new chat conversation and returns the conversation ID along with the agent's initial response.

## Custom parameters

The Chat API supports additional parameters for advanced use cases:

<ParamField body="integration_attributes" type="object">
  Custom metadata passed from external integrations. This data is accessible in functions through `conv.integration_attributes`.

  **Example**:

  ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "integration_attributes": {
      "customer_id": "12345",
      "source": "mobile_app"
    }
  }
  ```
</ParamField>

<ParamField body="variant_id" type="string">
  Specify which variant to use for this conversation. Useful for multi-site deployments.
</ParamField>

<ParamField body="channel" type="string">
  Channel identifier for the conversation (e.g., `"webchat"`, `"sms"`).
</ParamField>

<ParamField body="asr_lang_code" type="string">
  Language code for speech recognition (e.g., `"en-US"`, `"es-ES"`).
</ParamField>

<ParamField body="tts_lang_code" type="string">
  Language code for text-to-speech (e.g., `"en-US"`, `"es-ES"`).
</ParamField>


## OpenAPI

````yaml POST /{version}/{account_id}/{project_id}/chat/create
openapi: 3.0.0
info:
  title: Chat API
  description: API endpoints for chat functionality.
  version: 1.0.0
servers:
  - url: https://api.us-1.platform.polyai.app
    description: Hostname for US-1 region
  - url: https://api.uk-1.platform.polyai.app
    description: Hostname for UK-1 region
  - url: https://api.euw-1.platform.polyai.app
    description: Hostname for EUW-1 region
security:
  - ApiKeyAuth: []
  - TokenAuth: []
paths:
  /{version}/{account_id}/{project_id}/chat/create:
    post:
      summary: Create a new chat conversation
      description: >-
        Creates a new chat conversation and returns the conversation ID along
        with the agent's initial response.
      operationId: chatCreate
      parameters:
        - $ref: '#/components/parameters/ApiKeyHeader'
        - $ref: '#/components/parameters/TokenHeader'
        - name: version
          in: path
          description: API version
          required: true
          schema:
            type: string
          example: v1
        - name: account_id
          in: path
          description: Account ID
          required: true
          schema:
            type: string
          example: ACCOUNT-xxxxxxxx
        - name: project_id
          in: path
          description: Project ID
          required: true
          schema:
            type: string
          example: PROJECT-xxxxxxxx
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateChatResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
        - TokenAuth: []
components:
  parameters:
    ApiKeyHeader:
      name: X-API-KEY
      in: header
      description: Your PolyAI API key.
      required: true
      schema:
        type: string
    TokenHeader:
      name: X-TOKEN
      in: header
      description: Agent authentication token (connector).
      required: true
      schema:
        type: string
  schemas:
    CreateChatRequest:
      type: object
      properties:
        integration_attributes:
          type: object
          description: >-
            Custom metadata passed from external integrations. Accessible in
            functions via conv.integration_attributes.
          example:
            customer_id: '12345'
            source: mobile_app
        variant_id:
          type: string
          description: >-
            Specify which variant to use for this conversation. Useful for
            multi-site deployments.
          example: VARIANT-xxxxxxxx
        channel:
          type: string
          description: Channel identifier for the conversation.
          example: webchat
          enum:
            - webchat
            - whatsapp
            - sms
            - api
        asr_lang_code:
          type: string
          description: Language code for speech recognition (ISO 639-1 with region).
          example: en-US
        tts_lang_code:
          type: string
          description: Language code for text-to-speech (ISO 639-1 with region).
          example: en-US
        initial_message:
          type: string
          description: Optional initial message from the user to start the conversation.
          example: Hello, I need help
    CreateChatResponse:
      type: object
      properties:
        conversation_id:
          type: string
          description: Unique ID for the created conversation
          example: CONV-1234567890
        response:
          type: string
          description: Initial response message from the agent
          example: Hi, how can I help?
      required:
        - conversation_id
        - response
    Error:
      type: object
      properties:
        error_message:
          type: string
          description: Reason for error
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: You must request an API Key to use PolyAI APIs.
    TokenAuth:
      type: apiKey
      in: header
      name: X-TOKEN
      description: Authentication token provisioned in Agent Studio.

````