Docs

Sweep Document Assets

POST /internal/documents/assets/sweep

POST/internal/documents/assets/sweep

Auth: Managed Identity only

This is an internal maintenance endpoint, protected by the InternalService policy (Call-Api app role on the AzureAd scheme). It is not callable with a normal Bearer API key or an event-scoped token — those are rejected. In production it is invoked by the services-tier maintenance timer's Managed Identity (see 06-infrastructure.md); this request is documentation of the contract, not a runnable call from a developer machine.

Removes orphaned DocumentAsset rows and blobs that no live document's content references (both image assetIds and the document's coverAssetId are honored), and removes the residual rows plus blob container for documents that no longer exist. Idempotent — safe to run repeatedly.

Response

FieldTypeDescription
documentsScannedintNumber of documents examined.
orphanRowsRemovedint`DocumentAsset` rows deleted.
orphanContainersRemovedintBlob containers deleted (for documents that no longer exist).