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

# Send message to agent

> Send a message to the agent and receive a streaming SSE response. Each event is a JSON object with `type` and `conversationId`. Types: `user_message` (your message saved), `chunk` (text token in `content`), `completed` (reply saved), `tool_call`, `action_started`, `action_completed`, `handover_initiated`, `widget`, or `error`. Pass `conversationId` back to continue the conversation. Each API key may send 1000 messages a day and each agent 2000 across all keys; past that the API answers 429 until 00:00 UTC.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/chat
openapi: 3.0.0
info:
  title: Totebot Public API
  description: >-
    Manage your agents (settings, instructions, widget, skills, actions, MCP
    connections, integrations), their knowledge, test questions, the help desk,
    customers and your team from code, read conversations and analytics, and
    analyse which knowledge each answer used.


    Authenticate with a Bearer token: a team API key (`tb_live_…`, created by a
    team owner in Team settings → API keys) or a legacy per-agent key.

    New keys can only read. Write access is opt-in per area (`agents:write`,
    `plugins:write`, `knowledge:write`, `conversations:write`, `helpdesk:write`,
    `team:write`, `members:write`, `chat:write`, `customers:delete`,
    `quality:write`, `experiments:write`, `sales:write`). Provider cost in USD
    needs the opt-in `billing:read` scope. A key may also be limited to some
    agents.

    Routes that act on one agent take it from the `agentId` path parameter or,
    on the older `/v1/<resource>` routes, from the `X-Agent-Id` header.

    Write routes accept an `Idempotency-Key` header. Over the rate limit you get
    429 with `Retry-After`. Errors share one shape: `{ status: "error", error: {
    code, message, details } }`.

    Not available through the API, on purpose: billing and plan changes,
    deleting the team, creating or changing API keys, and OAuth connect flows.


    This spec is public at https://api.totebot.ai/v1/openapi.json (and .yaml).
  version: '2.0'
  contact: {}
servers:
  - url: https://api.totebot.ai
security: []
tags: []
paths:
  /v1/chat:
    post:
      tags:
        - Chat
      summary: Send message to agent
      description: >-
        Send a message to the agent and receive a streaming SSE response. Each
        event is a JSON object with `type` and `conversationId`. Types:
        `user_message` (your message saved), `chunk` (text token in `content`),
        `completed` (reply saved), `tool_call`, `action_started`,
        `action_completed`, `handover_initiated`, `widget`, or `error`. Pass
        `conversationId` back to continue the conversation. Each API key may
        send 1000 messages a day and each agent 2000 across all keys; past that
        the API answers 429 until 00:00 UTC.
      operationId: PublicApiChatController_chat
      parameters:
        - name: X-Agent-Id
          in: header
          description: >-
            The agent to act on. Required for team API keys that cover more than
            one agent; ignored for per-agent keys.
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicApiChatDto'
      responses:
        '200':
          description: >-
            Server-Sent Events. Each event is `data: <json>` followed by a blank
            line; the JSON has a `type` field.
          content:
            text/event-stream:
              schema:
                type: string
                example: >+
                  data:
                  {"type":"user_message","conversationId":"clx1conv","messageId":"clx1msg"}


                  data:
                  {"type":"chunk","conversationId":"clx1conv","content":"Hi"}


                  data:
                  {"type":"completed","conversationId":"clx1conv","messageId":"clx2msg"}

        '400':
          description: Invalid request, or rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '401':
          description: Missing, invalid, revoked or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '403':
          description: >-
            The plan lacks the feature, or the key lacks a scope
            (`error.details.missingScopes`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '404':
          description: Not found, or not an agent this key can access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '429':
          description: Rate limit or daily chat limit reached
      security:
        - api-key: []
components:
  schemas:
    PublicApiChatDto:
      type: object
      properties:
        conversationId:
          type: string
          description: Conversation ID to continue. Omit to start a new conversation.
          example: clxyz123
        message:
          type: string
          description: User message
          example: What products do you have?
          maxLength: 8000
        identity:
          type: object
          description: User identity for personalization and tracking
          example:
            userId: user_123
      required:
        - message
    ApiErrorDto:
      type: object
      properties:
        status:
          type: string
          example: error
        error:
          $ref: '#/components/schemas/ApiErrorBodyDto'
        path:
          type: string
          example: /v1/agents/clx123
        timestamp:
          type: string
          example: '2026-11-24T10:00:00.000Z'
      required:
        - status
        - error
        - path
        - timestamp
    ApiErrorBodyDto:
      type: object
      properties:
        code:
          type: string
          example: NotFoundException
        message:
          type: string
          example: Agent not found
        details:
          type: object
          description: >-
            Extra fields, e.g. `missingScopes` on 403 or `secondsRemaining` on a
            training cooldown.
          additionalProperties: true
      required:
        - code
        - message
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.