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

# Create chat

> Create a new chat session



## OpenAPI

````yaml https://api.getcargo.io/openapi.json post /ai/chats
openapi: 3.1.0
info:
  title: Cargo API
  version: 1.0.0
  description: Cargo Platform API v1
servers:
  - url: https://api.getcargo.io/v1
    description: Cargo API
security:
  - bearerAuth: []
paths:
  /ai/chats:
    post:
      tags:
        - AI - Chats
      summary: Create chat
      description: Create a new chat session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  title: Name
                  description: Chat name.
                  type: string
                agentUuid:
                  title: Agent UUID
                  description: Agent identifier for the chat.
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                releaseUuid:
                  title: Release UUID
                  description: Release identifier for the chat.
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                trigger:
                  anyOf:
                    - type: object
                      properties:
                        type:
                          type: string
                          const: connector
                        connectorUuid:
                          type: string
                        meta:
                          type: object
                          propertyNames:
                            type: string
                          additionalProperties: {}
                      required:
                        - type
                        - connectorUuid
                        - meta
                    - type: object
                      properties:
                        type:
                          type: string
                          const: draft
                      required:
                        - type
                    - type: object
                      properties:
                        type:
                          type: string
                          const: web_extension
                        url:
                          anyOf:
                            - type: string
                              format: uri
                            - type: 'null'
                      required:
                        - type
                        - url
                    - type: object
                      properties:
                        type:
                          type: string
                          const: app
                      required:
                        - type
                    - type: object
                      properties:
                        type:
                          type: string
                          const: workflow
                        uuid:
                          type: string
                        nodeUuid:
                          type: string
                        runUuid:
                          anyOf:
                            - type: string
                            - type: 'null'
                      required:
                        - type
                        - uuid
                        - nodeUuid
                        - runUuid
                  title: Trigger
                  description: Trigger configuration for the chat.
                heartbeat:
                  title: Heartbeat
                  description: >-
                    Optional heartbeat configuration. When set, the chat keeps
                    waking itself up every intervalMinutes minutes, re-sending
                    the prompt, until it reaches maxMessages messages.
                  type: object
                  properties:
                    intervalMinutes:
                      type: integer
                      exclusiveMinimum: 0
                      maximum: 9007199254740991
                    maxMessages:
                      type: integer
                      exclusiveMinimum: 0
                      maximum: 9007199254740991
                    prompt:
                      anyOf:
                        - type: string
                          minLength: 1
                        - type: 'null'
                  required:
                    - intervalMinutes
                    - maxMessages
                    - prompt
                evaluator:
                  title: Evaluator
                  description: >-
                    Optional evaluator configuration (rubric + quality
                    threshold). When set, the heartbeat loop grades each output
                    and keeps iterating until the score reaches the threshold or
                    maxMessages is hit.
                  type: object
                  properties:
                    rubric:
                      type: string
                      minLength: 1
                    threshold:
                      type: number
                      minimum: 0
                      maximum: 1
                  required:
                    - rubric
                    - threshold
              required:
                - trigger
              additionalProperties: false
              title: Request body
              description: Request body schema.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  chat:
                    type: object
                    properties:
                      uuid:
                        type: string
                      slug:
                        type: string
                      workspaceUuid:
                        type: string
                      userUuid:
                        anyOf:
                          - type: string
                          - type: 'null'
                      agentUuid:
                        anyOf:
                          - type: string
                          - type: 'null'
                      releaseUuid:
                        anyOf:
                          - type: string
                          - type: 'null'
                      name:
                        anyOf:
                          - type: string
                          - type: 'null'
                      trigger: {}
                      heartbeat:
                        anyOf:
                          - type: object
                            properties:
                              intervalMinutes:
                                type: integer
                                exclusiveMinimum: 0
                                maximum: 9007199254740991
                              maxMessages:
                                type: integer
                                exclusiveMinimum: 0
                                maximum: 9007199254740991
                              prompt:
                                anyOf:
                                  - type: string
                                    minLength: 1
                                  - type: 'null'
                            required:
                              - intervalMinutes
                              - maxMessages
                              - prompt
                            additionalProperties: false
                          - type: 'null'
                      evaluator:
                        anyOf:
                          - type: object
                            properties:
                              rubric:
                                type: string
                                minLength: 1
                              threshold:
                                type: number
                                minimum: 0
                                maximum: 1
                            required:
                              - rubric
                              - threshold
                            additionalProperties: false
                          - type: 'null'
                      activeStreamUuid:
                        anyOf:
                          - type: string
                          - type: 'null'
                      creditsUsedCount:
                        type: number
                      createdAt:
                        type: string
                      updatedAt:
                        type: string
                      deletedAt:
                        anyOf:
                          - type: string
                          - type: 'null'
                      lastMessage:
                        anyOf:
                          - type: object
                            properties:
                              uuid:
                                type: string
                              workspaceUuid:
                                type: string
                              agentUuid:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              releaseUuid:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              chatUuid:
                                type: string
                              userUuid:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              status:
                                type: string
                                enum:
                                  - pending
                                  - generating
                                  - success
                                  - error
                                  - cancelling
                                  - cancelled
                              errorMessage:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              type:
                                type: string
                                enum:
                                  - user
                                  - assistant
                              createdAt:
                                type: string
                              updatedAt:
                                type: string
                              finishedAt:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              deletedAt:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                            required:
                              - uuid
                              - workspaceUuid
                              - agentUuid
                              - releaseUuid
                              - chatUuid
                              - userUuid
                              - status
                              - errorMessage
                              - type
                              - createdAt
                              - updatedAt
                              - finishedAt
                              - deletedAt
                            additionalProperties: false
                          - type: 'null'
                    required:
                      - uuid
                      - slug
                      - workspaceUuid
                      - userUuid
                      - agentUuid
                      - releaseUuid
                      - name
                      - trigger
                      - heartbeat
                      - evaluator
                      - activeStreamUuid
                      - creditsUsedCount
                      - createdAt
                      - updatedAt
                      - deletedAt
                      - lastMessage
                    additionalProperties: false
                    title: Chat
                    description: Created chat details.
                required:
                  - chat
                additionalProperties: false
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````