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

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

Upload Resource

post

Upload a file directly and start indexing; poll the resource GET for 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. Read successful resource payloads under data when a body is returned.

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
response_codestring · nullableOptional

Machine-readable response code, when provided.

post/v2/knowledge-bases/{knowledge_base_id}/resources
curl
curl --fail-with-body -sS \
  "$STACKAI_BASE_URL/v2/knowledge-bases/${KNOWLEDGE_BASE_ID}/resources" \
  -H "Authorization: Bearer $STACKAI_API_KEY" \
  -F 'file=@document.pdf'
{
  "response_code": "text",
  "meta": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "data": {
    "message": "text",
    "resource_id": "123e4567-e89b-12d3-a456-426614174000"
  }
}

Last updated

Was this helpful?