# Roll API key

Issues a new key with the same name and scopes and keeps the old one working for overlap_hours (default 24, max 168; 0 revokes it at once). Requires developer:manage and a passkey step-up; a revoked or expired key cannot be rolled. The new secret is shown once.

`POST /v1/api-keys/{key_id}/roll`

Issues a new key with the same name and scopes and keeps the old one working for overlap_hours (default 24, max 168; 0 revokes it at once). Requires developer:manage and a passkey step-up; a revoked or expired key cannot be rolled. The new secret is shown once.

Requires permission `developer:manage`.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `key_id` | path | yes | API key id (key_...). |

## Request body

```json
{
  "overlap_hours": 1
}
```

## Responses

- **200**: Success.
- **400**: Invalid request: a field is missing or malformed (VALIDATION_ERROR).
- **401**: No valid session, API key or agent credential (UNAUTHENTICATED, AGENT_CREDENTIAL_INVALID).
- **403**: Authenticated but not allowed: missing permission, passkey step-up required, or denied by policy.
- **404**: The resource does not exist or belongs to another organization.
- **409**: Conflicts with the current state, for example a reused Idempotency-Key or an illegal state change.

Example 200 response:

```json
{
  "api_key": {
    "id": "id_01jd2x3k4m5n6p7q8r9s0t1v2w",
    "name": "Example",
    "prefix": "string",
    "scopes": [
      "string"
    ],
    "status": "active",
    "created_by": "string",
    "created_by_name": "string",
    "last_used_at": "2026-11-16T12:00:00Z",
    "expires_at": "2026-11-16T12:00:00Z",
    "revoked_at": "2026-11-16T12:00:00Z",
    "created_at": "2026-11-16T12:00:00Z"
  },
  "secret": "string",
  "previous": {
    "id": "id_01jd2x3k4m5n6p7q8r9s0t1v2w",
    "name": "Example",
    "prefix": "string",
    "scopes": [
      "string"
    ],
    "status": "active",
    "created_by": "string",
    "created_by_name": "string",
    "last_used_at": "2026-11-16T12:00:00Z",
    "expires_at": "2026-11-16T12:00:00Z",
    "revoked_at": "2026-11-16T12:00:00Z",
    "created_at": "2026-11-16T12:00:00Z"
  }
}
```
