Skip to content

Create Knowledge Processing Task

Request

Create an asynchronous knowledge-processing task. The task can include three source types, and the system automatically processes all sources and uploads the resulting content to the Knowledge Base.

Supported source types:

  • uploaded_file: References a file previously uploaded through the /files API. Requires fileId.
  • remote_file: Provides a publicly or otherwise accessible external file URL. The system downloads and processes the file automatically.
  • raw_text: Provides text directly in the request; no file upload is required.

Design notes:

  • All input sources use a single sources[] array. A task may contain multiple sources for batch ingestion.
  • The API returns a taskId immediately. Processing continues asynchronously, and progress can be obtained through the task-query API or a callback.
  • A failure for one file does not stop the task; the remaining files continue to be processed.

Task statuses:

  • task.progress: The task is in progress.
  • task.completed: Processing has finished for all files. This status can still be returned when all individual files failed, provided there was no task-level error.
  • task.failed: The task failed because of a task-level error.

Callback example:

{
  "id": "df53ce97-2138-4898-8926-919bd7e161e8",
  "type": "file.completed",
  "createdAt": 1778050876442,
  "data": {
    "task": {
      "taskId": "07adc997-2ce8-4dc4-89b9-08ede5bd9356",
      "status": "task.progress",
      "sourceSummary": {
        "total": 1,
        "accepted": 1,
        "rejected": 0,
        "queued": 0,
        "uploading": 0,
        "parsing": 0,
        "completed": 1,
        "failed": 0
      },
      "entitlement": {
        "resourceType": "knowledge_unit",
        "estimatedConsume": 1,
        "actualConsume": 1,
        "balanceRemain": 5
      },
      "errors": [],
      "createdAt": 1778050592419,
      "updatedAt": 1778050875495
    },
    "file": {
      "sourceId": "my_sr_x1",
      "internalId": "7b06a742-8593-4246-9f74-45e4cbeebbaa",
      "type": "uploaded_file",
      "displayName": "multi-active-conversations-by-channel.pdf",
      "status": "file.completed"
    }
  }
}
Security
bearerAuth
Bodyapplication/jsonrequired
sourcesArray of any, non-emptyrequired

Knowledge source list

parseConfigobject

Document parsing configuration

chunkConfigobjectrequired

Chunking configuration

callbackobject

Callback notification settings

curl -i -X POST \
  https://threechatai.redocly.app/_mock/apis/3chat-api/api/open/v4/butler/knowledge/tasks \
  -H 'Authorization: Bearer <YOUR_Access Token_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "sources": [
      null
    ],
    "parseConfig": {
      "extractImageElements": true,
      "parseScannedDocument": false,
      "language": "zh-CN",
      "normalizeWhitespaceAndLineBreaks": false,
      "removeUrlsAndEmails": false
    },
    "chunkConfig": {
      "mode": "hierarchical",
      "hierarchical": {
        "level": 1,
        "preserveHierarchyInfo": true
      },
      "custom": {
        "separator": "\n\n",
        "maxSegmentLength": 1000,
        "overlapPercent": 10
      }
    },
    "callback": {
      "url": "https://client.example.com/webhooks/3chat/knowledge",
      "events": [
        "file.uploading",
        "file.parsing",
        "file.completed",
        "file.failed"
      ],
      "secret": "whsec_xxx"
    }
  }'

Responses

Task created successfully

Headers
any
Bodyapplication/json
codeinteger

Status code

Example:200
messagestring

Status message

Example:"success"
requestIdstring

Request ID

Example:"req_01K23P7R4M6W8Q9JAB"
dataobject
Response
{ "code": 200, "message": "success", "requestId": "req_01K23P7R4M6W8Q9JAB", "data": { "taskId": "ktask_01K23P7W8D5N2X4QYZ", "status": "task.progress", "sourceSummary": { … }, "parseConfig": { … }, "chunkConfig": { … }, "entitlement": { … }, "errors": [], "createdAt": 1776667072000 } }