Create (or replace) an API key
PUT
/v1/user/{user}/apikey/{name}
const url = 'https://example.com/v1/user/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/apikey/example';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"label":"example","expiry":"2026-04-15T12:00:00Z"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://example.com/v1/user/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/apikey/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "label": "example", "expiry": "2026-04-15T12:00:00Z" }'Mints a new API key under the given name and returns the plaintext once. A user may manage their own keys; acting on another user requires user:credential:write on their owner scope.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”user
required
string format: uuid
Target user UUID (use your own, from GET /v1/me, to manage your keys).
name
required
string
Credential id for the key; reusing a name overwrites that key.
Request Body
Section titled “Request Body”Media typeapplication/json
object
label
string
expiry
Optional expiry; omit for a non-expiring key.
string format: date-time
Examplegenerated
{ "label": "example", "expiry": "2026-04-15T12:00:00Z"}Responses
Section titled “Responses”Key minted; plaintext returned once
Media typeapplication/json
The plaintext api_key is returned only here, exactly once.
object
success
required
boolean
credential_id
required
Echoes the {name} path segment.
string
api_key
required
string
label
string
expiry
string format: date-time
Examplegenerated
{ "success": true, "credential_id": "example", "api_key": "example", "label": "example", "expiry": "2026-04-15T12:00:00Z"}default
Section titled “default”Error response
Media typeapplication/problem+json
RFC 7807 Problem Details
object
type
Problem type slug URI
string
title
string
status
integer
detail
string
key
additional properties
any
Examplegenerated
{ "type": "example", "title": "example", "status": 1, "detail": "example"}