> ## 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 a new API key for the current org.

> **Required scope:** admin

**Required scope:** `admin`

### Request body

`ApiKeyCreateRequest`

<ParamField body="name" type="string" required>
  Friendly name for the key.
</ParamField>

<ParamField body="org_id" type="string">
  Optional org id. Must match the authenticated org when provided.
</ParamField>

<ParamField body="rate_limit_per_minute" type="integer (int32)">
  Optional rate limit override for this key. · `0` disables rate limiting for this key. · positive values cap requests per minute. · values that are not positive are treated as unset.
</ParamField>

<ParamField body="scopes" type="ApiScope[]">
  Scopes for the key (defaults to admin).
</ParamField>

### Response

`ApiKeyCreateResponse`

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

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

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

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

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

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

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

<ResponseField name="rate_limit_per_minute" type="integer (int32)" />

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

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `201` | API key created                                    |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/auth/keys' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "name": "Two-Person Tent",
    "org_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "rate_limit_per_minute": 8,
    "scopes": [
      "read"
    ]
  }'
  ```
</RequestExample>

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