# Rotate the workspace default key (new secret returned once)

> Rotate the workspace default key (new secret returned once): CustomDomain™ API reference in the tenancy group. Covers parameters, request body and responses.

Source: https://docs.customdomain.ai/docs/api-reference/tenancy/rotateDefaultApiKey

## `POST https://api.customdomain.ai/v1/tenants/{tenant_id}/default-key:rotate`

Mints a new default key and revokes the old active one in one transaction: the old key stops authenticating at once, and there is never a moment with two active default keys or none. The workspace's other keys are untouched. With no active default key it simply creates one. Same provision secret guard as `POST /tenants/{tenant_id}/default-key`.

### Authentication

`provisionSecret`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `tenant_id` | path | string | yes |  |

### Responses

| Status | Description |
| --- | --- |
| `200` | Rotated; api_key is the new full secret, shown once |
| `401` | Error envelope: {code, title, details}. |
| `404` | Error envelope: {code, title, details}. |
| `409` | Error envelope: {code, title, details}. |
| `503` | Error envelope: {code, title, details}. |

### `200` response body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key_id` | string | yes |  |
| `prefix` | string | yes | The stored, non-secret prefix, for example cd_live_ab12cd34. |
| `created` | boolean | yes | true when this call minted the key; api_key is present only then. |
| `api_key` | string | no | The full secret, cd_live_… or cd_test_…; shown once. |

The full specification is served at `GET https://api.customdomain.ai/v1/openapi.json`.
