← Back to APIs
RAG PIPELINE — DOCUMENT CLEANUP

Delete Indexed Documents

Remove all Azure AI Search index chunks for a given document_id without needing to track individual chunk keys. The Lowcademy Labs endpoint queries your Azure AI Search index for all chunks matching the document_id, then issues a bulk delete. This is the clean way to remove a document from your RAG index when it becomes outdated or needs to be re-indexed.

POST · Lowcademy Hosted Destructive — Deletes Index Data Variables: azureAISearch_Endpoint, azureAISearch_Key, azureAISearch_IndexName
01

Endpoint

POST https://labs.lowcademy.com/apis/delete-indexed-document.php
PropertyValue
MethodPOST
BodyEmpty — all parameters are passed as request headers
ServiceLowcademy hosted — proxies deletion to your Azure AI Search index
Destructive Operation — Cannot be undone This permanently removes all chunks for the given document_id from your Azure AI Search index. To re-add the document, run the full ingestion pipeline again (Steps 1–2).
02

Postman Collection Variables Required

Set these variables in the Postman collection before calling this API azureAISearch_Endpoint — Your Azure AI Search endpoint URL, e.g. https://my-search.search.windows.net
azureAISearch_Key — Your Azure AI Search admin API key
azureAISearch_IndexName — The name of your Azure AI Search index
03

Authentication Headers

Two sets of credentials are required

Header: api-keyankitg.in
Header: azureAISearchKey{{azureAISearch_Key}}
HeaderTypeRequiredDescription
api-key String Required Fixed Lowcademy lab API key. Value: ankitg.in
azureAISearchEndpoint String (URL) Required Your Azure AI Search endpoint. Maps to {{azureAISearch_Endpoint}}.
azureAISearchKey String Required Your Azure AI Search admin key. Maps to {{azureAISearch_Key}}.
indexName String Required Name of the index to delete from. Maps to {{azureAISearch_IndexName}}.
document_id Integer Required The numeric document_id whose chunks should be deleted. All chunks with this ID are removed.
04

Sample Request

cURL

curl -X POST \
  -H "api-key: ankitg.in" \
  -H "azureAISearchEndpoint: https://my-search.search.windows.net" \
  -H "azureAISearchKey: <your-azure-search-admin-key>" \
  -H "indexName: my-rag-index" \
  -H "document_id: 42" \
  https://labs.lowcademy.com/apis/delete-indexed-document.php
05

Response — 200 OK

Successful Delete Response

{
  "success"      : true,
  "deleted"      : 14,
  "document_id"  : 42,
  "message"      : "14 chunks deleted for document_id 42."
}
Zero deleted is not an error If no chunks are found for the given document_id, the response will still be 200 with "deleted": 0. This means the document was never indexed or was already deleted.
06

Error Responses

200
OK — Delete operation completed. Check deleted count.
401
Unauthorized — Lowcademy api-key header missing or wrong.
400
Bad Request — Required header missing (azureAISearchEndpoint, azureAISearchKey, indexName, or document_id).
404
Not Found — Index not found in the Azure AI Search resource (upstream error from Azure).
405
Method Not Allowed — Request was not POST.