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_ipsarray of stringOptional IPv4/IPv6 addresses or CIDR ranges.
Items: at most 50 itemsdetector_overridesarray of stringnamestring requiredRequired key label containing non-whitespace characters, 1–100 characters. Duplicate labels are allowed.
Length: 1 to 100 characterspermissionsarray of stringOptional non-empty list of supported scopes; omitted values use the default scopes.
Items: at least 1 itemsprivacy_tier_overridePrivacyModerate_limit_rpmintegerRange: 1 to 600expires_atstring (date)Optional date after today.
transparency_log_opt_inboolean
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
api_keyApiKeyResourceC6b requiredreusedboolean requiredValue:true
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_keyany requiredAll of
- ApiKeyResourceC6b
- object
keystring requiredWrite only
warningstring 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
errorobject requiredcodestring requiredOne of:"idempotency_key_conflict","idempotency_request_in_progress","idempotency_response_not_retained"messagestring requiredtypestring requiredValue:"idempotency_error"
422 Validation, active-key-limit, or privacy-floor check failed.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
429 The request was rate limited. API-generated responses are JSON;
Response headers
Retry-Afterstring headerSeconds to wait before retrying, when provided.
X-RateLimit-Scopestring headerIdentifies the scope of the request limit, when provided.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string