> ## Documentation Index
> Fetch the complete documentation index at: https://docs.capcells.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mint a key

> Issue an API key for the Tenancy. The key appears in this response and nowhere else.

Mints one of the API keys your systems sign requests with. [API keys](https://docs.capcells.com/authentication/api-keys.md) covers the form of a key and how to sign.

The key routes exist at the Console alone. A tenant API key cannot mint, list or revoke anything.

There is no idempotency key. A double submit mints two keys; both are listed, and either is revoked in one call.

## Who may call

An administrator of the organization, as a person. The agent is refused on live and sandbox Tenancies alike.

## Path parameters

**tenant\_id** `string` *required*

The Tenancy acting. It comes from [Read the tenancy](https://docs.capcells.com/api-reference/console/tenancy/read.md); your organization must be bound to it.

## Body

**scope** `string` *required*

`read` or `write`. `read` covers reads; `write` covers everything.

**lifetime** `string` *required*

How long the key lives: a duration such as `720h` or `30m`, or the word `never`. There is no default.

## Response

Answers `201`.

**key** `string` *required*

The key itself. This is the only time it exists outside your own storage: show it once and mint a replacement if it is lost.

**credential** `object` *required*

The key's record, as [List the keys](https://docs.capcells.com/api-reference/console/keys/list.md) answers it.

## Refusals

| Status | Code | When |
| - | - | - |
| `401` | `unauthenticated` | The token is missing or cannot be used |
| `403` | `not_permitted_tenant` | Your organization does not act for the Tenancy in the path |
| `403` | `not_permitted_role` | The caller is not an administrator |
| `403` | `not_permitted_actor` | The caller is the agent |
| `400` | `malformed_request` | The body has an unknown field, a field stated twice, or more than one JSON value |
| `415` | `unsupported_media_type` | The body is not declared `application/json` |
| `413` | `body_too_large` | The body is longer than the route reads |
| `422` | `invalid_lifetime` | No lifetime was stated, or it is neither a duration nor `never` |
| `422` | | The scope is outside the set the Platform issues under |

Every refusal carries the [error shape](https://docs.capcells.com/api-reference/overview.md#the-error-shape). `429` and `503` answer as at the signing door.

```bash Request theme={null}
curl -X POST https://api.capcells.com/console/v1/tenants/capyplazo/keys \
  -H "Authorization: Bearer $CONSOLE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"scope": "write", "lifetime": "720h"}'
```

```json 422 No lifetime theme={null}
{
  "error": "access: no lifetime was stated for the credential: state a duration such as 720h, or the word never",
  "code": "invalid_lifetime"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.