Add a training file
Adds a document the AI agent can learn from. Provide exactly one source:
- Inline text —
{ "name": "refund-policy.md", "content": "..." }. Markdown or plain text is stored as-is and indexing is attempted before the response returns; checkindexStatus(statusiscompleted). Best for content you generate yourself, such as an SOP compiled from resolved conversations. - Remote file —
{ "url": "https://..." }(optionalname). The file (PDF, DOCX, PPTX, XLSX, TXT, HTML, …; max 50 MB) is downloaded and converted to text in the background. The response returns immediately withstatus: "processing"; poll the file until it iscompletedorfailed. - Multipart upload — send
multipart/form-datawith the document in afilepart and, optionally, a JSONdatafield such as{"name": "..."}. Converted in the background like a remote file.
Keeping files in sync (create-or-update). Pass your own externalId (unique per workspace) and the same request becomes idempotent: a new ID creates the file (201), a known ID with different content updates that file in place and re-indexes it (200), and a known ID with identical content is a no-op (200, no embedding work). Add a source label to group everything one pipeline owns, then list by source to find entries to remove. Every response carries contentHash so you can diff a whole library from the list endpoint.
Without externalId, uploading a file whose name and bytes match an existing file returns the existing file with status 200 instead of creating a duplicate. Multipart uploads over 50 MB are rejected with 413.
Body ParametersJSON
Text or markdown to train on. Stored as-is; indexing is attempted before returning. Check indexStatus. Cannot be combined with url.
Your own identifier for this entry (unique per workspace). When provided, the request creates the entry if the ID is new and otherwise updates the existing entry in place — an unchanged payload is a no-op. Use it to keep the AI agent in sync with a system of record without tracking Featurebase IDs.
Display name of the file. Required with content; optional with url (defaults to the downloaded file name) or a multipart upload (defaults to the uploaded file name).
Add a training file
curl https://do.featurebase.app/v2/training_data/files \
-X POST \
-H "Authorization: Bearer $FEATUREBASE_API_KEY"{
"id": "67ec1234abcd5678ef901234",
"characterCount": 12840,
"contentHash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentPreview": "# Refund policy\n\nCustomers can request a refund within 30 days…",
"createdAt": "2026-09-03T10:15:00.000Z",
"externalId": "kb-article-1842",
"fileSize": 48213,
"indexStatus": "indexed",
"mimeType": "application/pdf",
"name": "refund-policy.pdf",
"object": "training_file",
"processingError": null,
"source": "resolved-conversations",
"status": "completed",
"updatedAt": "2026-09-03T10:15:30.000Z",
"wordCount": 2130,
"content": "# Refund policy\n\nCustomers can request a refund within 30 days of purchase…",
"outcome": "created"
}Returns Examples
{
"id": "67ec1234abcd5678ef901234",
"characterCount": 12840,
"contentHash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentPreview": "# Refund policy\n\nCustomers can request a refund within 30 days…",
"createdAt": "2026-09-03T10:15:00.000Z",
"externalId": "kb-article-1842",
"fileSize": 48213,
"indexStatus": "indexed",
"mimeType": "application/pdf",
"name": "refund-policy.pdf",
"object": "training_file",
"processingError": null,
"source": "resolved-conversations",
"status": "completed",
"updatedAt": "2026-09-03T10:15:30.000Z",
"wordCount": 2130,
"content": "# Refund policy\n\nCustomers can request a refund within 30 days of purchase…",
"outcome": "created"
}