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

# Create Api Key V1

> Create a new API key for the calling tenant. Requires the admin scope on the calling key — non-admin keys can only read and use keys, not mint new ones…

Create a new API key for the calling tenant.

Requires the `admin` scope on the calling key — non-admin keys can
only read and use keys, not mint new ones. The plaintext is returned
once in this response and never again; lose it and the only path
forward is to delete and re-create.

### Request body

`CreateAPIKeyRequest`

<ParamField body="name" type="string" required>
  Human-readable label, e.g. 'CI bot' or 'Slack integration'.
</ParamField>

<ParamField body="scopes" type="string[]">
  Allowed scopes. Empty list = full-access (back-compat). Otherwise must be a subset of: trigger:write, jobs:read, jobs:write, admin.
</ParamField>

<ParamField body="rate_limit_per_minute" type="integer">
  Per-key request budget. Range 1..10000.
</ParamField>

### Response

`CreateAPIKeyResponse`

<ResponseField name="id" type="string" required />

<ResponseField name="name" type="string" required />

<ResponseField name="key" type="string" required>
  Plaintext API key — store it now. The platform only retains the SHA-256 hash; this is the one and only time the secret is exposed.
</ResponseField>

<ResponseField name="key_prefix" type="string" required />

<ResponseField name="scopes" type="string[]" required />

<ResponseField name="rate_limit_per_minute" type="integer" required />

<ResponseField name="created_at" type="string" required />

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `201` | Successful Response |
| `422` | Validation Error    |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.computer.stateset.app/api/v1/keys' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "name": "Two-Person Tent",
    "scopes": [
      "string"
    ],
    "rate_limit_per_minute": 60
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "Two-Person Tent",
    "key": "string",
    "key_prefix": "string",
    "scopes": [
      "string"
    ],
    "rate_limit_per_minute": 8,
    "created_at": "2026-08-31T14:22:05Z"
  }
  ```
</ResponseExample>
