Skip to content
Connect an agent
Keys

Create an API key

Makes a key and returns its full value.

POST/user/api-keys

TL;DR

QuestionAnswer
What does it do?Create an API key.
What does it take?A JSON body of type CreateApiKeyBody.
What does it return?Status 201 with a body of type CreatedApiKey.
What can go wrong?400 the body is not valid; 401 not signed in; 403 the request came from an origin that may not make changes; 409 the account already holds the most keys allowed; 429 too many requests. Every failure uses the one error envelope.

What it does

Makes a key and returns its full value. A sealed copy is kept when the server can, so the key can be revealed again; otherwise this answer is the only time it is shown.

Request body

The body has the type CreateApiKeyBody.

FieldTypeRequiredDescription
namestringyesat least 1 character; at most 60 characters; pattern \S.

Responses

StatusMeaningBody
201The new key, including its full value.CreatedApiKey
400The body is not valid.ErrorResponse
401Not signed in.ErrorResponse
403The request came from an origin that may not make changes.ErrorResponse
409The account already holds the most keys allowed.ErrorResponse
429Too many requests.ErrorResponse

Response body

A 201 answer has the type CreatedApiKey.

FieldTypeRequiredDescription
idstringyes
namestringyes
prefixstringyes
last4stringyes
createdAtintegeryesMilliseconds since the epoch.
lastUsedAtinteger | nullyesMilliseconds since the epoch, or null if never used.
revealablebooleanyesTrue when the full key can be shown again with the reveal route. False for a key made before that was possible, or on a server that cannot seal keys.
keystringyesThe full key. When revealable is false this is the only time it is shown, so store it now.

See also

DocWhy
API referenceEvery endpoint, and the error envelope
SchemasEvery request and response type
Tool referenceThe operations as callable tools