> ## 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.

# Preview one reply (spot check)

> Asks the agent one question like the dashboard playground and returns the reply with the steps it took (knowledge searches, product lookups). With `systemPrompt` or `modelId` (needs `agents:write` or `quality:write` as well) it answers with that change for this turn only; nothing is saved. No conversation is created, so customers and the inbox never see it. Actions, MCP tools, bookings and store cart changes are switched off; product and order lookups still work. Billed like a dashboard preview message. At most 200 per API key per day (429 after).



## OpenAPI

````yaml /api-reference/openapi.json post /v1/agents/{agentId}/chat-preview
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/agents/{agentId}/chat-preview:
    post:
      tags:
        - Chat
      summary: Preview one reply (spot check)
      description: >-
        Asks the agent one question like the dashboard playground and returns
        the reply with the steps it took (knowledge searches, product lookups).
        With `systemPrompt` or `modelId` (needs `agents:write` or
        `quality:write` as well) it answers with that change for this turn only;
        nothing is saved. No conversation is created, so customers and the inbox
        never see it. Actions, MCP tools, bookings and store cart changes are
        switched off; product and order lookups still work. Billed like a
        dashboard preview message. At most 200 per API key per day (429 after).
      operationId: PublicApiChatPreviewController_chat
      parameters:
        - name: Idempotency-Key
          in: header
          description: >-
            Any unique string (e.g. a UUID). Retrying with the same key within
            24 hours replays the first response instead of repeating the change.
          required: false
          schema:
            type: string
        - name: agentId
          required: true
          in: path
          schema: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatPreviewDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatPreviewResponseDto'
        '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'
        '409':
          description: >-
            The same Idempotency-Key is still in progress, or the resource
            conflicts (e.g. the link already exists, or the source is being
            trained).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '422':
          description: Idempotency-Key reused with a different request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
        '429':
          description: Daily preview limit for this API key reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorDto'
      security:
        - api-key: []
components:
  schemas:
    ChatPreviewDto:
      type: object
      properties:
        message:
          type: string
          maxLength: 4000
          example: Do you deliver on Saturdays?
        systemPrompt:
          type: string
          maxLength: 10000
          description: >-
            Answer with these instructions instead of the saved ones, for this
            turn only.
        modelId:
          type: string
          description: >-
            Answer with this model id (from GET /v1/agents/{agentId}/models),
            for this turn only.
      required:
        - message
    ChatPreviewResponseDto:
      type: object
      properties:
        reply:
          type: string
        preview:
          $ref: '#/components/schemas/ChatPreviewOverridesDto'
        steps:
          description: What the agent did before answering, in order.
          type: array
          items:
            $ref: '#/components/schemas/ChatPreviewStepDto'
        model:
          $ref: '#/components/schemas/ChatPreviewModelDto'
        durationMs:
          type: number
        usage:
          $ref: '#/components/schemas/ChatPreviewUsageDto'
        messagesCharged:
          type: number
          description: Messages billed, as for a dashboard preview.
      required:
        - reply
        - preview
        - steps
        - model
        - durationMs
        - usage
        - messagesCharged
    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
    ChatPreviewOverridesDto:
      type: object
      properties:
        systemPrompt:
          type: boolean
          description: True when `systemPrompt` was overridden.
        modelId:
          type: string
          description: The model that answered.
      required:
        - systemPrompt
        - modelId
    ChatPreviewStepDto:
      type: object
      properties:
        text:
          type: string
          example: >-
            Searched your knowledge for "weekend delivery" → found 2 answers:
            Delivery FAQ, Shipping policy
        kind:
          type: string
          enum:
            - knowledge_search
            - knowledge_prefetch
            - tool
        status:
          type: string
          enum:
            - succeeded
            - empty
            - failed
            - skipped
        name:
          type: string
        durationMs:
          type: number
          nullable: true
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatPreviewSourceDto'
      required:
        - text
        - kind
        - status
        - name
        - durationMs
        - sources
    ChatPreviewModelDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        provider:
          type: string
      required:
        - id
        - name
        - provider
    ChatPreviewUsageDto:
      type: object
      properties:
        modelCalls:
          type: number
        inputTokens:
          type: number
        outputTokens:
          type: number
        totalTokens:
          type: number
      required:
        - modelCalls
        - inputTokens
        - outputTokens
        - totalTokens
    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
    ChatPreviewSourceDto:
      type: object
      properties:
        knowledgeSourceId:
          type: string
          nullable: true
        title:
          type: string
        type:
          type: string
        score:
          type: number
      required:
        - knowledgeSourceId
        - title
        - type
        - score
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

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