POST /v1/knowledge-bases/{knowledge_base_id}/resources
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.
Personal API key (sk_...) or supported user access JWT. See Authentication and authorization for endpoint restrictions and scopes. Use exactly one Authorization header.
The file to upload to the knowledge base
Successful Response
Result of a file upload, including the resource ID for status polling.
Validation Error
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?

