# Purge one domain's deleted rows past their grace

POST

/v1/retention/sweep/{domain}

```sh
curl --request POST \
  --url https://example.com/v1/retention/sweep/org \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "maxPerDomain": 1 }'
```

As `POST /v1/retention/sweep`, for one domain. Requires `admin` on the workspace.

## Authorizations

- **[bearerAuth](https://docs.kindgi.com/v0.8.1/reference/api.md#bearerauth)**

## Parameters

### Path Parameters

**domain**

required

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.

string

Allowed values: org agent flow tool test_set guardrail mcp_endpoint env secret run artifact policy correction corrector_group provider memory conversation file_version api_key service_account \*

The domain to sweep (not `*`).

## Request Body

application/json

object

**maxPerDomain**

The most rows this call purges (default 500); the rest are `remaining`.

integer

\>= 1 <= 10000

##### Examplegenerated

```json
{
  "maxPerDomain": 1
}
```

## Responses

### 200

What was purged.

application/json

object

**perDomain**

required

Array\<object>

object

**domain**

required

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.

string

Allowed values: org agent flow tool test_set guardrail mcp_endpoint env secret run artifact policy correction corrector_group provider memory conversation file_version api_key service_account \*

**purged**

required

integer

**remaining**

required

Rows past grace this call left (the `maxPerDomain` cap); sweep again.

integer

**policyId**

The retention policy that applied.

string

**limitApplied**

Present when this server’s retention limit set the grace (see `RetentionScheduledItem.limitApplied`).

boolean

**missingAdapter**

Present when this deployment can’t purge the domain (no adapter).

boolean

**totalPurged**

required

integer

**conflicts**

Domains more than one retention policy covers. Absent or empty: none.

Array\<object>

object

**domain**

required

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.

string

Allowed values: org agent flow tool test_set guardrail mcp_endpoint env secret run artifact policy correction corrector_group provider memory conversation file_version api_key service_account \*

**policyIds**

required

Every policy id that covers the domain, sorted.

Array\<string>

\>= 2 items

**appliedPolicyId**

required

The one that applies: the policy whose latest version is highest, and on equal versions the lower policy id. Unregister the others.

string

##### Example

```json
{
  "perDomain": [
    {
      "domain": "org",
      "limitApplied": true,
      "missingAdapter": true
    }
  ],
  "conflicts": [
    {
      "domain": "org"
    }
  ]
}
```

### 400

Unknown `domain` (or `*`), or `maxPerDomain` outside 1..10000.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 401

Missing / malformed / expired / revoked bearer token.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 403

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`).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 409

Idempotency-Key was reused with a different body, or resource-state conflict.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 413

The request body is over the API’s limit (`request-too-large`; `details.maxBytes` says how much).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 429

`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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

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.

### 500

Server error (unmapped domain code or framework crash).

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 503

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.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

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`: Purge the deleted rows past their grace](https://docs.kindgi.com/v0.8.1/reference/api/operations/retentionsweep.md)
- [Error code `authz-backend-unavailable`](https://docs.kindgi.com/v0.8.1/reference/errors.md#authz-backend-unavailable)
- [Error code `database-busy`](https://docs.kindgi.com/v0.8.1/reference/errors.md#database-busy)
- [Error code `key-project-mismatch`](https://docs.kindgi.com/v0.8.1/reference/errors.md#key-project-mismatch)
- [Error code `permission-denied`](https://docs.kindgi.com/v0.8.1/reference/errors.md#permission-denied)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.8.1/reference/errors.md#rate-limit-exceeded)
- [Error code `request-too-large`](https://docs.kindgi.com/v0.8.1/reference/errors.md#request-too-large)
- [Every error code](https://docs.kindgi.com/v0.8.1/reference/errors.md)
