# Ensure the workspace default key exists (secret returned only when created)

> ensure default api key: reference page for this CustomDomain™ API operation in the tenancy group. Covers parameters, request body, responses and error codes.

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

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

The workspace default key is an ordinary API key (`cd_live_…` in production) flagged `is_default`, at most one active per workspace, whose secret the customer console keeps sealed so the workspace's owner can view it more than once. It acts with admin authority, never owner: it cannot make, unmake or remove an owner, delete the workspace, or create API keys (`403`). Server to server, guarded by the provision secret like `tenants:provision`; a missing and a wrong secret get the same `401`. With no active default key this creates one and answers `201` with the full secret ONCE in `api_key`. With one, it answers `200` with its id and prefix and no secret (a caller that lost its copy rotates instead). Not subject to the billing activation gate: the key adds no capability the workspace's console key does not already hold.

### Authentication

`provisionSecret`

### Parameters

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

### Responses

| Status | Description |
| --- | --- |
| `200` | An active default key exists; no secret |
| `201` | Created; api_key is the 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`.
