Purge a closed tenant, for good
const url = 'https://example.com/v1/system/tenants/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/purge';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"confirm":"example"}'};
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/system/tenants/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/purge \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "confirm": "example" }'Deletes a closing tenant whose 30-day export window has passed: every row of it, its artifacts’ bytes and its authorization store. Once nothing of it is left, its purge record is written, so a restore from an older backup purges it again, and it’s marked purged: its tenants row stays, and nothing of it signs in or is served. Then, once each server has seen the mark, it deletes again what work under way at the mark wrote meanwhile. Irreversible. confirm is the tenant’s slug, a second check on the id. It answers when done. Safe to run again: a run that stopped part-way (complete: false, or a request that ended before its answer) is finished by the next, and on a tenant already purged it deletes what was written after its mark, leaving its mark and its record as they were. A run again is a new request: a new Idempotency-Key, or none. Takes its own scope, system:tenants:purge, which no other scope includes, or kindgi:system.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Examplegenerated
{ "confirm": "example"}Responses
Section titled “Responses”What it deleted, and what of it is left.
object
Examplegenerated
{ "tenantId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "complete": true, "alreadyPurged": true, "purgedAt": "2026-04-15T12:00:00Z", "deleted": [ { "table": "example", "rows": 1 } ], "objectsDeleted": 1, "authzStoreDeleted": true, "left": [ { "table": "example", "rows": 1 } ], "objectsLeft": 1, "leftBecause": "example"}No confirm, or one that isn’t the tenant’s slug (tenant-slug-mismatch). Nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}A tenant’s key or session (system-principal-required), or a system key without system:tenants:purge (system-scope-missing).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No tenant with that id (tenant-not-found). A purged one is found, for a run again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Nothing was changed: the tenant isn’t closing (tenant-not-closing), or its export window is still open (tenant-export-window-open); the runtime has nowhere set to keep purge records (purge-record-unset), or lacks the setting that reaches what the tenant holds (purge-setting-missing); or an Idempotency-Key reused with another body. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}This runtime doesn’t purge tenants (tenant-purge-unsupported).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Deleting the tenant’s authorization store failed (authz-store-delete-failed): the message says what that left. Run it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The operator’s access record can’t be written, so nothing was done (access-record-unavailable), or the Idempotency-Key store couldn’t be read before the request ran (idempotency-store-unavailable, with Retry-After). Or the authorization store couldn’t be reached (authz-backend-unavailable, with Retry-After), or the database was too busy for the authorization check (database-busy, with Retry-After), so the request wasn’t run.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/system/tenants: List tenantsPOST /v1/system/tenants: Create a tenantGET /v1/system/tenants/{tenantId}: Read a tenantPATCH /v1/system/tenants/{tenantId}: Rename a tenant- Serve many tenants
- Kindgi 0.1.10
- Error code
access-record-unavailable - Error code
authz-backend-unavailable - Error code
authz-store-delete-failed - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
purge-record-unset - Error code
purge-setting-missing - Error code
request-too-large - Error code
system-principal-required - Error code
system-scope-missing - Error code
tenant-export-window-open - Error code
tenant-not-closing - Error code
tenant-not-found - Error code
tenant-purge-unsupported - Error code
tenant-slug-mismatch - Every error code