Purge the deleted rows past their grace
const url = 'https://example.com/v1/retention/sweep';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"domain":"org","maxPerDomain":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/retention/sweep \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "domain": "org", "maxPerDomain": 1 }'Purges, for good, every tombstoned row past its grace (or only domain’s): the grace of the retention policy that covers its domain, or this server’s limit for the domain when no policy covers it or the policy keeps rows longer (limitApplied), up to maxPerDomain per domain; remaining counts what is left for the next call. Nothing sweeps on its own: call this (or POST /v1/retention/sweep/{domain}) from a schedule. A hold (graceSeconds: -1) keeps its domain’s rows, unless the domain has a limit. Idempotent: a second call purges nothing new. Requires admin on the workspace.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Sweep only this domain. Absent: every domain.
The most rows one call purges per domain (default 500); the rest are remaining.
Responses
Section titled “Responses”What was purged, per domain.
object
object
The kind of record a retention policy covers. * covers every domain without a policy of its own, except memory, conversation and file_version: the first two hold people’s words, and file_version holds every edit of a file, so only a policy naming them purges them. file_version covers a file’s versions other than Latest: a deleted one after the grace, and one that isn’t among its file’s newest 10, isn’t pinned, and was superseded longer ago than the grace.
Rows past grace this call left (the maxPerDomain cap); sweep again.
The retention policy that applied.
Present when this server’s retention limit set the grace (see RetentionScheduledItem.limitApplied).
Present when this deployment can’t purge the domain (no adapter).
Domains more than one retention policy covers. Absent or empty: none.
object
The kind of record a retention policy covers. * covers every domain without a policy of its own, except memory, conversation and file_version: the first two hold people’s words, and file_version holds every edit of a file, so only a policy naming them purges them. file_version covers a file’s versions other than Latest: a deleted one after the grace, and one that isn’t among its file’s newest 10, isn’t pinned, and was superseded longer ago than the grace.
Every policy id that covers the domain, sorted.
The one that applies: the policy whose latest version is highest, and on equal versions the lower policy id. Unregister the others.
Example
{ "perDomain": [ { "domain": "org", "limitApplied": true, "missingAdapter": true } ], "conflicts": [ { "domain": "org" } ]}Unknown domain, or maxPerDomain outside 1..10000.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Not a tenant admin. Without an authorization store, key-project-mismatch (details.keyProjectId): the API key or session is limited to a project, and this writes above it, to the workspace, an org or a team (with a store, that is permission-denied).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Idempotency-Key was reused with a different body, or resource-state conflict.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.
Server error (unmapped domain code or framework crash).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The authorization store couldn’t be reached (authz-backend-unavailable), or the database was too busy for the authorization check (database-busy), so the request wasn’t run; Retry-After (whole seconds) says when to try again.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.
See also
POST /v1/retention/sweep/{domain}: Purge one domain's deleted rows past their grace- Keep and purge deleted data
- Error code
authz-backend-unavailable - Error code
database-busy - Error code
key-project-mismatch - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
request-too-large - Every error code