# Recycle bin API

## GET /api/v1/admin/recycle-bin

`GET /api/v1/admin/recycle-bin` · operation `listRecycleBin`

Tombstones of soft-deleted keys, teams and workloads and of disabled console users, newest first, with the actor and request ID of the deletion audit row. Requires recycle_bin and recycle_bin:read (admin, viewer, and an organization admin for its organization only). Read-only unless trash_restore is on (restore true); then keys, teams and users inside trash.retention_days carry restorable_until and are restored by an explicit, audited POST (T168).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `kind` | query | string, one of `"key"`, `"team"`, `"workload"`, `"user"` | Only tombstones of keys, teams, workloads or users. |
| `limit` | query | integer, default `50`, min 1, max 100 | Most rows on this page, 1-100 (50 by default). |
| `offset` | query | integer, default `0`, min 0, max 10000 | Rows to skip before this page, for pagination (0-10000). |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Page of tombstones | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `items` (array of object, required)
    - `kind` (string, required, one of `"key"`, `"team"`, `"workload"`, `"user"`)
    - `id` (string, required)
    - `name` (string, required)
    - `team_id` (string)
    - `deleted_at` (string (date-time), required)
    - `deleted_by` (string)
    - `request_id` (string)
    - `restorable_until` (string (date-time))
  - `has_more` (boolean, required)
  - `next_offset` (integer, required)
  - `restore` (boolean, required)
  - `trash` ([TrashSettings](/docs/api/schemas/t/#trashsettings))


## POST /api/v1/admin/recycle-bin/{kind}/{id}/restore

`POST /api/v1/admin/recycle-bin/{kind}/{id}/restore` · operation `restoreFromRecycleBin`

Requires recycle_bin:restore (global admin, or an organization admin inside its organization), CSRF, trash_restore and recycle_bin. Restores a deleted key (with a new secret shown once; every earlier credential is revoked), a deleted console team (the keys deleted with it stay deleted) or a disabled user (as an enable), within trash.retention_days. Audited as key.restore, team.restore or console_user.enable.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `kind` | path | string, required, one of `"key"`, `"team"`, `"user"` |  |
| `id` | path | string, required, max length 128 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | A restored key and its new secret, shown once. | `application/json`: object |
| `204` | Team or user restored | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or nothing to restore with that ID in the caller's scope | — |
| `409` | Restore window passed, parent deleted, name taken, YAML-owned or SCIM-managed | — |
| `503` | Storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `key` (object, required)
  - `secret` (string, required)

