For the complete documentation index, see llms.txt. This page is also available as Markdown.

POST /v1/knowledge-bases/{knowledge_base_id}/resources

Create Resource

post

Upload a file directly to a knowledge base and start indexing.

This endpoint allows API users to upload files directly without needing to use presigned URLs. The file is uploaded to storage and indexing is started automatically. Returns the resource ID so callers can poll for indexing status.

How to use

Upload multipart field file (singular). Indexing starts automatically. Save the resource_id from the 202 response and poll resource GET until indexed or error. Do not set the multipart boundary yourself or re-upload while waiting.

Authentication and permissions

Required permissions: kbs.index. Resource and owner access checks also apply.

Authorizations
AuthorizationstringRequired

Personal API key (sk_...) or supported user access JWT. See Authentication and authorization for endpoint restrictions and scopes. Use exactly one Authorization header.

Path parameters
knowledge_base_idstring · uuidRequired
Body
filestring · binaryRequired

The file to upload to the knowledge base

Responses
202

Successful Response

application/json

Result of a file upload, including the resource ID for status polling.

messagestringRequired
resource_idstring · uuidRequired
post/v1/knowledge-bases/{knowledge_base_id}/resources
curl
curl --fail-with-body -sS \
  "$STACKAI_BASE_URL/v1/knowledge-bases/${KNOWLEDGE_BASE_ID}/resources" \
  -H "Authorization: Bearer $STACKAI_API_KEY" \
  -F 'file=@document.pdf'
{
  "message": "text",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000"
}

Last updated

Was this helpful?