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

# Create or replace a text source on several agents

> Matches an existing text source by its exact title. Omitted validFrom / validUntil keep the current dates; when only the dates change, the source is updated in place. Runs once per agent and returns one result per agent; a failure on one agent does not stop the others. Omit agentIds to target every agent the key can access.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/bulk/knowledge/text
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/bulk/knowledge/text:
    post:
      tags:
        - Bulk
      summary: Create or replace a text source on several agents
      description: >-
        Matches an existing text source by its exact title. Omitted validFrom /
        validUntil keep the current dates; when only the dates change, the
        source is updated in place. Runs once per agent and returns one result
        per agent; a failure on one agent does not stop the others. Omit
        agentIds to target every agent the key can access.
      operationId: PublicApiBulkController_upsertText
      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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkUpsertTextDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkUpsertResponse'
        '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'
      security:
        - api-key: []
components:
  schemas:
    BulkUpsertTextDto:
      type: object
      properties:
        agentIds:
          maxItems: 100
          description: >-
            Agents to apply the operation to. Omit to use every agent the API
            key can access.
          type: array
          items:
            type: string
        train:
          type: boolean
          default: false
          description: >-
            Start training on each agent the change affects, so it goes live
            without a separate call.
        title:
          type: string
          maxLength: 100
          example: Shipping policy
        text:
          type: string
          maxLength: 10000
        validFrom:
          type: string
          format: date-time
          nullable: true
          example: '2026-11-24T00:00:00.000Z'
          description: >-
            ISO 8601. The agent uses the source only from this time. null clears
            it. When editing, an omitted field keeps the current value.
        validUntil:
          type: string
          format: date-time
          nullable: true
          example: '2026-11-30T23:59:59.000Z'
          description: >-
            ISO 8601, after validFrom. The agent stops using the source after
            this time. null clears it. When editing, an omitted field keeps the
            current value.
      required:
        - title
        - text
    BulkUpsertResponse:
      type: object
      properties:
        succeeded:
          type: number
        failed:
          type: number
        results:
          type: array
          items:
            $ref: '#/components/schemas/BulkUpsertAgentResult'
      required:
        - succeeded
        - failed
        - results
    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
    BulkUpsertAgentResult:
      type: object
      properties:
        agentId:
          type: string
        ok:
          type: boolean
          description: False when this agent failed.
        status:
          type: number
          example: 200
          description: The HTTP status this agent would have had on its own.
        data:
          allOf:
            - $ref: '#/components/schemas/UpsertResultDto'
          description: Present when ok is true.
        error:
          description: Present when ok is false.
          allOf:
            - $ref: '#/components/schemas/BulkErrorDto'
      required:
        - agentId
        - ok
        - status
    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
    UpsertResultDto:
      type: object
      properties:
        training:
          description: 'Present when `train: true` started a training run.'
          allOf:
            - $ref: '#/components/schemas/TrainingStatusDto'
        trainingError:
          type: string
          description: >-
            Present when `train: true` could not start training (e.g. already
            training). The write itself succeeded.
        action:
          type: string
          enum:
            - created
            - replaced
            - updated
            - unchanged
          description: '`updated`: only the dates changed, in place (no training needed).'
        source:
          $ref: '#/components/schemas/KnowledgeSourceDto'
        trainingRequired:
          type: boolean
      required:
        - action
        - source
        - trainingRequired
    BulkErrorDto:
      type: object
      properties:
        message:
          type: string
          example: Agent not found
      required:
        - message
    TrainingStatusDto:
      type: object
      properties:
        status:
          type: string
          enum:
            - not_trained
            - training
            - completed
        lastTrainedAt:
          type: string
          nullable: true
          format: date-time
        isTrainingRequired:
          type: boolean
          description: Pending additions or removals are waiting for training.
        hasFailedKnowledgeSources:
          type: boolean
        hasOverLimitKnowledgeSources:
          type: boolean
          description: Some sources did not fit the plan knowledge limit and are not live.
        isOverBudget:
          type: boolean
          description: The agent is over its plan knowledge limit.
      required:
        - status
        - lastTrainedAt
        - isTrainingRequired
        - hasFailedKnowledgeSources
        - hasOverLimitKnowledgeSources
        - isOverBudget
    KnowledgeSourceDto:
      type: object
      properties:
        id:
          type: string
          example: clx1source
        type:
          allOf:
            - $ref: '#/components/schemas/KnowledgeSourceType'
        status:
          description: >-
            PENDING: waiting for training. PROCESSING: being trained. COMPLETED:
            live. FAILED: see processingError. OVERLIMIT: over the plan
            knowledge limit. PENDING_DELETE: leaves on the next training.
          allOf:
            - $ref: '#/components/schemas/KnowledgeSourceStatus'
        processingError:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
          description: Text sources.
        question:
          type: string
          nullable: true
          description: Q&A sources.
        url:
          type: string
          nullable: true
          description: Link and sitemap sources.
        parentSourceId:
          type: string
          nullable: true
          description: 'For links found through a sitemap: the sitemap source.'
        managedByIntegration:
          type: boolean
          description: >-
            Created by an integration (e.g. product sync). Read-only through the
            API.
        characterCount:
          type: number
        lastCrawledAt:
          type: string
          format: date-time
          nullable: true
          description: 'Link and sitemap sources: when the page was last fetched.'
        contentHash:
          type: string
          nullable: true
          description: Hash of the fetched content; it changes when the page changes.
        validFrom:
          type: string
          format: date-time
          nullable: true
          description: The agent uses the source only from this time.
        validUntil:
          type: string
          format: date-time
          nullable: true
          description: The agent stops using the source after this time.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - type
        - status
        - processingError
        - title
        - question
        - url
        - parentSourceId
        - managedByIntegration
        - characterCount
        - lastCrawledAt
        - contentHash
        - validFrom
        - validUntil
        - createdAt
        - updatedAt
    KnowledgeSourceType:
      type: string
      enum:
        - DOC
        - QA
        - LINK
        - TEXT
        - SITEMAP
        - NOTION
    KnowledgeSourceStatus:
      type: string
      enum:
        - PENDING
        - PROCESSING
        - COMPLETED
        - FAILED
        - PENDING_DELETE
        - OVERLIMIT
      description: >-
        PENDING: waiting for training. PROCESSING: being trained. COMPLETED:
        live. FAILED: see processingError. OVERLIMIT: over the plan knowledge
        limit. PENDING_DELETE: leaves on the next training.
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

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