Add a file source

add a file source to a knowledge base (multipart).

POST https://api.centerfy.ai/webhooks/inbound/knowledge-bases/:id/file

Headers

HeaderRequiredValueDescription
x-api-keyYesyour sub-account API key (cfy_…)Authenticates the request; or Authorization: Bearer <key>.
Content-TypeYesmultipart/form-dataThe request body must be multipart/form-data with the file under the field name file.

Path parameters

NameTypeRequiredDescription
idstring (uuid)YesThe knowledge base id.

Form fields (multipart/form-data)

NameTypeRequiredDefaultDescription
filefileYes—The file to add, sent as a multipart/form-data part under the field name file. Allowed extensions:.pdf.docx.xlsx.txt.csv. txt, csv, docx, and pdf are extracted and embedded inline; xlsx is queued and embedded asynchronously.

Example

curl -X POST "https://api.centerfy.ai/webhooks/inbound/knowledge-bases/{id}/file" \
  -H "x-api-key: $CENTERFY_API_KEY" \
  -F "[email protected]"
import { CenterfyClient } from "@centerfy/sdk";
import { readFileSync } from "node:fs";

const centerfy = new CenterfyClient({ apiKey: process.env.CENTERFY_API_KEY! });

const result = await centerfy.knowledgeBases.addFile("<knowledgeBaseId>", new Blob([readFileSync("faq.pdf")]), "faq.pdf");
console.log(result);
centerfy knowledgeBases add-file <knowledgeBaseId> '{"path":"./faq.pdf"}'

MCP tool: centerfy_knowledge_bases_add_file (see MCP server)

Response

{
  "status": "success",
  "added": true,
  "processed": true,
  "knowledge_base_id": "<knowledge_base_id>",
  "document": {
    "id": "a1b2c3d4-0000-4000-8000-000000000001",
    "title": "company-handbook.pdf",
    "filename": "company-handbook.pdf",
    "file_type": "pdf",
    "file_size_bytes": 482190,
    "status": "completed",
    "total_chunks": 42,
    "vector_count": 42,
    "created_at": "2026-06-12T10:15:00.000Z",
    "updated_at": "2026-06-12T10:15:08.000Z"
  }
}

Errors

  • 201 — on success.

Notes

txt, csv, docx, and pdf files are extracted and embedded inline (processed=true, status ‘completed’); xlsx files are queued (processed=false, status ‘queued’) and embedded asynchronously. Errors: 400 (invalid knowledge base id, not multipart, no file field, unsupported file type — allowed.pdf.docx.xlsx.txt.csv, or could not read file), 401 (unauthenticated), 404 (knowledge base not found), 500 (insert error), 502 (file uploaded but inline processing failed — includes document_id and marks the source failed).

© 2026 Centerfy AI. All rights reserved.