Keys
Create an API key
Makes a key and returns its full value.
POST
/user/api-keysTL;DR
| Question | Answer |
|---|---|
| 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.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | at least 1 character; at most 60 characters; pattern \S. |
Responses
| Status | Meaning | Body |
|---|---|---|
| 201 | The new key, including its full value. | CreatedApiKey |
| 400 | The body is not valid. | ErrorResponse |
| 401 | Not signed in. | ErrorResponse |
| 403 | The request came from an origin that may not make changes. | ErrorResponse |
| 409 | The account already holds the most keys allowed. | ErrorResponse |
| 429 | Too many requests. | ErrorResponse |
Response body
A 201 answer has the type CreatedApiKey.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
name | string | yes | |
prefix | string | yes | |
last4 | string | yes | |
createdAt | integer | yes | Milliseconds since the epoch. |
lastUsedAt | integer | null | yes | Milliseconds since the epoch, or null if never used. |
revealable | boolean | yes | True 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. |
key | string | yes | The full key. When revealable is false this is the only time it is shown, so store it now. |
See also
| Doc | Why |
|---|---|
| API reference | Every endpoint, and the error envelope |
| Schemas | Every request and response type |
| Tool reference | The operations as callable tools |