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

# Create new chat

> Creates a new chat instance for a user based on a provided API integration. Requires a valid platform token in the headers for authentication. Ensure the apiIntegrationId corresponds to an existing integration.



## OpenAPI

````yaml /openapi.json post /create_new_chat
openapi: 3.0.3
info:
  title: Agencii Platform API
  version: 1.0.0
  description: >-
    Reference documentation for the Agencii Platform API. Provides endpoints
    allowing you to run your agents on custom backends or on other unsupported
    channels. ⚡ Live Postman Example:
    https://www.postman.com/vrsen-ai/agencii-api/overview
servers:
  - url: https://agency-swarm-app-japboyzddq-uc.a.run.app
    description: Production server
security:
  - BearerAuth: []
paths:
  /create_new_chat:
    post:
      summary: Create new chat
      description: >-
        Creates a new chat instance for a user based on a provided API
        integration. Requires a valid platform token in the headers for
        authentication. Ensure the apiIntegrationId corresponds to an existing
        integration.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateNewChatRequest'
      responses:
        '200':
          description: >-
            Chat created successfully. Returns the unique chatId for the new
            chat.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateNewChatResponse'
        '400':
          description: >-
            Bad Request. Occurs if the request body is missing required fields
            or the JSON payload is malformed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: >-
                  Your JSON payload is missing required fields. Please consult
                  the documentation.
        '401':
          description: >-
            Unauthorized. Occurs if the Authorization header is missing or
            contains an invalid token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: Invalid or missing authorization token.
        '500':
          description: >-
            Internal Server Error. Occurs if there is an issue on the server
            side while processing the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: An unexpected error occurred while processing your request.
      security:
        - BearerAuth: []
components:
  schemas:
    CreateNewChatRequest:
      type: object
      description: Request body for the /create_new_chat endpoint.
      properties:
        apiIntegrationId:
          type: string
          description: >-
            The unique identifier of the API integration for which to create the
            chat. Example: "dpCD7snQ0tCWrdtp6UhZ"
      required:
        - apiIntegrationId
    CreateNewChatResponse:
      type: object
      description: Response body for the /create_new_chat endpoint.
      properties:
        chatId:
          type: string
          description: >-
            The unique identifier for the newly created chat. Example:
            "FVfA971B3fnBH4S1OKlo"
    ErrorResponse:
      type: object
      description: Standard error response format.
      properties:
        detail:
          type: string
          description: A detailed error message.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Platform token required for authentication. Find or create one inside
        Profile Icon > API Keys. Example: Bearer sk-agencii-...

````