Skip to content
Sign in Create account

Create a dashboard API key

POST /api/keys

Creates a key for the authenticated account. Requires keys.write and api-keys.create; the plaintext appears only once in api_key.key. A reuse response returns an existing active key resource with reused: true and no plaintext. A newly created key is otherwise returned as an API-key resource. Key-limit, validation, or privacy-floor failures return 422.

Authenticate with a portal session token.

Request body

application/json object

  • allowed_ips array of string

    Optional IPv4/IPv6 addresses or CIDR ranges.

    Items: at most 50 items
  • detector_overrides array of string
  • name string required

    Required key label containing non-whitespace characters, 1–100 characters. Duplicate labels are allowed.

    Length: 1 to 100 characters
  • permissions array of string

    Optional non-empty list of supported scopes; omitted values use the default scopes.

    Items: at least 1 items
  • privacy_tier_override PrivacyMode
  • rate_limit_rpm integer
    Range: 1 to 600
  • expires_at string (date)

    Optional date after today.

  • transparency_log_opt_in boolean

Example

{
  "name": "CI key",
  "permissions": [
    "messages",
    "completions"
  ],
  "rate_limit_rpm": 60
}

Responses

200 An existing active key was returned; no plaintext key is included.

application/json object

Generated sample

{
  "api_key": {
    "allowed_ips": [
      "string"
    ],
    "created_at": "2026-01-01T00:00:00Z",
    "expires_at": "2026-01-01T00:00:00Z",
    "id": 0,
    "is_active": true,
    "is_default": true,
    "last_used_at": "2026-01-01T00:00:00Z",
    "mirrors_account_settings": true,
    "name": "string",
    "permissions": [
      "string"
    ],
    "prefix": "string",
    "privacy_tier_override": "balanced",
    "rate_limit_rpm": 0
  },
  "reused": true
}
201 API key created; plaintext is included once in api_key.key.

application/json object

  • api_key any required

    All of

  • warning string required

Generated sample

{
  "api_key": {
    "allowed_ips": [
      "string"
    ],
    "created_at": "2026-01-01T00:00:00Z",
    "expires_at": "2026-01-01T00:00:00Z",
    "id": 0,
    "is_active": true,
    "is_default": true,
    "last_used_at": "2026-01-01T00:00:00Z",
    "mirrors_account_settings": true,
    "name": "string",
    "permissions": [
      "string"
    ],
    "prefix": "string",
    "privacy_tier_override": "balanced",
    "rate_limit_rpm": 0,
    "key": "string"
  },
  "warning": "string"
}
401 Missing or invalid bearer token.

application/json object

Any keys are accepted.

403 Authenticated caller lacks the required permission, ability, or role.

application/json object

Any keys are accepted.

409 The Idempotency-Key cannot be used for this request because it conflicts with another request (idempotency_key_conflict), is still in progress (idempotency_request_in_progress), or its response was not retained (idempotency_response_not_retained).

application/json IdempotencyError

  • error object required
    • code string required
      One of: "idempotency_key_conflict", "idempotency_request_in_progress", "idempotency_response_not_retained"
    • message string required
    • type string required
      Value: "idempotency_error"
422 Validation, active-key-limit, or privacy-floor check failed.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

429 The request was rate limited. API-generated responses are JSON;

Response headers

  • Retry-After string header

    Seconds to wait before retrying, when provided.

  • X-RateLimit-Scope string header

    Identifies the scope of the request limit, when provided.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string