Ana içeriğe geç

Reindex Knowledge Document

Endpoint

POST /apiops/projects/{projectName}/knowledge-bases/{kbName}/documents/{documentId}/reindex/

Authentication

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer {token}Yes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
kbNamestringYesKnowledge base name (parent, resolved by name)
documentIdstringYesDocument id (documents are referenced by id, not name — must belong to kbName)

Query Parameters

None

Request Body

None. This endpoint does not require a request body.

Response

Success Response (200 OK)

{
"status": "SUCCESS",
"deploymentResult": {
"success": true
}
}

The reindex runs asynchronously. A success response means the job was accepted, not that indexing has completed. Poll Get Document (status transitions PENDINGCHUNKEDINDEXED) or the knowledge base (status transitions back to ACTIVE once the job finishes).

Error Response (400 Bad Request) — Validation

{
"status": "FAILURE",
"resultMessage": "Document id can not be empty!"
}

or

{
"status": "FAILURE",
"resultMessage": "Knowledge base (name: product-docs) was not found!"
}

Error Response (404 Not Found) — Document Not In This Knowledge Base

Returned when documentId does not exist at all, or exists but belongs to a different knowledge base (a two-layer ownership check, the same IDOR guard used by Get Document and Delete Document):

{
"status": "FAILURE",
"resultMessage": "404 NOT_FOUND \"Document not found\""
}

or

{
"status": "FAILURE",
"resultMessage": "404 NOT_FOUND \"Document does not belong to this knowledge base\""
}

Error Response (409 Conflict) — Knowledge Base Busy

Returned when the parent knowledge base is currently indexing — a concurrency guard shared with Reindex Knowledge Base:

{
"status": "FAILURE",
"resultMessage": "409 CONFLICT \"Knowledge base is currently indexing. Wait for completion before reindexing a document.\""
}

Error Response (400 Bad Request) — No VectorDB Configured

{
"status": "FAILURE",
"resultMessage": "400 BAD_REQUEST \"Knowledge base has no VectorDB configured\""
}

Error Response (401 Unauthorized)

{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}

cURL Example

curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/knowledge-bases/product-docs/documents/6651b3c4e4b0c3a2d1f0aaaa/reindex/" \
-H "Authorization: Bearer YOUR_TOKEN"

Notes and Warnings

  • Single-Document Scope — The Key Difference From Reindex Knowledge Base: The knowledge-base-level reindex drops the entire VectorDB collection and resets every document to PENDING. This endpoint instead calls a targeted deleteByDocumentId (removing only this document's vectors) and resets only this one document — the other documents in the knowledge base keep their existing chunks and stay queryable while this document reprocesses.
  • Knowledge Base Still Goes To INDEXING: The parent knowledge base's status is set to INDEXING for the duration (so the concurrency guard blocks a second reindex from starting), but — unlike the full reindex — its chunkCount and embeddingModelId are left untouched, since the index job recomputes the KB-wide total from all documents once this one finishes.
  • Real HTTP Status Codes: Unlike most other endpoints in this file (which flatten "not found" into a 400), this one surfaces the underlying service's real status: 404 for a document that doesn't exist or belongs to a different knowledge base, 409 for a knowledge base that is currently indexing, 400 when the knowledge base has no VectorDB configured.
  • Ownership Enforcement (IDOR): The document must belong to kbName, which itself must belong to the caller's project — a document id from a different knowledge base or project is unreachable (404).
  • Asynchronous: The endpoint returns immediately once the job is accepted; indexing continues in the background.
  • Permissions: Requires AI_DEVELOPMENT + MANAGE permission in the project.