Skip to main content

Upload documents for context-aware conversations

Get your documents into the knowledge bank and confirm the avatar can actually find them.

This guide covers the practical side of loading documents: what is accepted, how to confirm extraction worked, and how to check retrieval before a user does it for you.

For how retrieval fits into a conversation, see Knowledge bank.

Every request needs your API key. Set it once:

export GOLDENENGINE_API_KEY="<YOUR_API_KEY>"

What is accepted​

ConstraintValue
FormatsPDF and DOCX
Maximum size50 MB per file
Files per request1 with file; up to 5 with the batch endpoints below

Other formats are rejected at upload. Convert Markdown, HTML, or plain text to PDF first — export from whatever tool owns the content rather than hand-converting, so headings survive.

The check looks at both the extension and the file part's content type. If a content type is sent it must be application/pdf or application/vnd.openxmlformats-officedocument.wordprocessingml.document; a generic application/octet-stream gets a 400 reading Unsupported file content type. That is what a Node.js Blob without a type sends, and what cURL sends for a .docx unless you name the type — the samples below set it explicitly.

Upload​

Two endpoints, depending on which avatars should see the document. For how that scoping works, see Which avatars see a document.

Attach to one avatar as you upload — only that avatar will use it:

cURL
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \

Upload to the account bank — no avatar uses it yet. Check the extraction, then attach it to the avatar it is for:

cURL
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank/upload" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \

Upload several at once​

Both upload endpoints have a batch form that takes up to five files in one request. Send them as repeated files fields — plural, unlike the single-file file — and the same format and size limits apply to each one.

RuleValue
Files per request1 to 5
Any file invalid (type or extension, empty, over 50 MB) or the wrong countThe whole request fails with 400, and nothing is uploaded or queued
All files queued201
Some files not queued207, with the failures listed per file
cURL
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge/batch" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-F "[email protected];type=application/vnd.openxmlformats-officedocument.wordprocessingml.document"

To upload to the account bank instead, send the same form to /v1/knowledge-bank/upload/batch.

The response carries one entry per file, in the order you sent them:

{
"results": [
{
"index": 0,
"filename": "policy.pdf",
"item": {
"id": "b71f...",
"filename": "policy.pdf",
"file_type": "pdf",
"file_size_bytes": 482113,
"status": "uploaded",
"chunk_count": null,
"total_tokens": null
},
"error": null
},
{
"index": 1,
"filename": "manual.docx",
"item": null,
"error": { "code": "upload_failed", "message": "Could not store document" }
}
],
"submitted": 2,
"queued": 1,
"failed": 1
}
FieldMeaning
itemThe stored document, with the same id and status a single upload returns. Poll it as below
errorWhy this file was not queued — code and message, shaped like the error envelope. Null when the file was queued
submitted, queued, failedCounts across the batch. failed above zero is what makes the status 207

Two error codes appear per file:

codeMeaningitem
upload_failedThe file could not be storednull
queue_unavailableThe file was stored but extraction could not be queuedSet, with status: "failed" and the reason in error_message

Either way, upload that file again.

Attach a bank document to an avatar​

A document in the account bank is used by no avatar until you attach it. Attach it to the avatar that should answer from it:

cURL
curl -s -X POST "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge/attach" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"knowledge_base_id\": \"$ITEM_ID\"}"

The document must have finished extracting first — attaching one that is still processing fails with 409, and so does attaching one that already belongs to another of your avatars. Attaching to one of your avatars moves the document out of the bank rather than copying it, which is why the one-avatar limit above applies. Attaching to a stock avatar leaves it in the bank, so one bank document can be attached to several stock avatars.

PATCH /v1/avatars/{avatar_id} with knowledge_base_ids is the other way to manage attachments. It replaces the avatar's full set: documents you leave out go back to the account bank, where no avatar uses them, and documents you list move to this avatar. It skips both 409 checks — it will move a document that is still processing, or take one from another avatar, silently — so check status and where each document is attached before using it.

Confirm extraction​

Uploading is not the same as being searchable. Extraction runs asynchronously:

uploaded → processing → completed
↘ failed

Documents in the account bank are listed by GET /v1/knowledge-bank:

cURL
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"

That list leaves out anything attached to an avatar, and GET /v1/knowledge-bank/{item_id} returns 404 for those. Check an avatar's documents with GET /v1/avatars/{avatar_id}/knowledge, which returns the same fields:

cURL
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"

A rough sanity check: a text-heavy page produces a few hundred tokens. If a 40-page document reports a few hundred tokens in total, something went wrong in extraction.

Test retrieval​

POST /v1/knowledge-bank/search runs a similarity search over the account bank, so you can check that a document's text is in the index before putting it in front of anyone:

cURL
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank/search" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "what is the return window", "limit": 5}'

limit defaults to 5 and caps at 20.

Two limits on what this tells you. It searches only documents in the account bank — so test a document here before you attach it to one of your avatars, or ask the avatar directly once it is attached. And it is not the avatar's own search: it returns the nearest chunks as they are, while the avatar's search drops weak matches, removes duplicate passages, and falls back to a keyword match when nothing matches by meaning. Treat good results as proof the text was extracted, not as a promise of what the avatar will retrieve.

Build a short list of real user questions and run all of them. This separates two failures that look identical in conversation:

SymptomCauseFix
Search returns nothing relevantDocuments missing, empty, or wrongFix the documents
Search is good, avatar still vagueModel is not calling the tool, or the prompt overrides itFix the system prompt

Structure documents for retrieval​

Documents are chunked, and chunks are matched individually — so each chunk needs to make sense on its own.

Use real headings. They give chunks boundaries that follow meaning rather than page breaks.

Keep answers near their questions. A policy stated on page 3 and its exceptions on page 40 may retrieve separately, and an answer built from one without the other is wrong.

Prefer several focused documents over one large one. A 300-page manual retrieves worse than a dozen topic-scoped files, and it is far easier to tell which file is stale.

Drop the boilerplate. Cover pages, revision histories, and legal footers compete with real content for retrieval slots.

Keeping documents current​

cURL
# Remove a stale document from the account bank
curl -s -X DELETE "https://backend.goldenengine.ai/v1/knowledge-bank/$ITEM_ID" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"

# Remove a stale document attached to an avatar (deletes the document and its file)
curl -s -X DELETE "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge/$KNOWLEDGE_ID" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"

Use the endpoint that matches where the document is: /v1/knowledge-bank/{item_id} returns 404 for a document attached to an avatar. Neither call detaches without deleting — for that, PATCH the avatar's knowledge_base_ids as described above.

There is no versioning — updating means deleting the old document and uploading the new one. Deleting first avoids a window where both versions are searchable and the avatar answers from the wrong one.