---
title: POST /user/api-keys
description: Create an API key — Creates an ivy_ API key for your account and returns the full key in apiKey.
full: true
---

**Auth:** required. Send a signed-in session token (`Authorization: Bearer …`) or the session cookie (browser sessions). See [Authentication](/docs/api/authentication).

Creates an `ivy_` API key for your account and returns the full key in `apiKey`. This is the only time the secret is shown, so store it immediately. An API key cannot create other keys: this route needs a signed-in session, and an `ivy_` key is answered with `401`.

## Request

### Request body

- `name` (string) —
Display name. Must not be blank.

- `description` (string) —

- `scopes` (string[]) —
Capabilities to grant (`read`, `write`, `manage`). Defaults to the standard set when omitted. Scopes reserved for .bloom* are rejected.

- `expiresInDays` (integer) —
Days until the key expires. The key never expires when omitted.

- `rateLimitPerHour` (integer) —

- `rateLimitPerDay` (integer) —

- `maxConcurrentJobs` (integer) —

- `allowedProjectIds` (string[]) —
Limit the key to these projects. You must have access to each one. The key covers all your projects when omitted.

## Responses

### `201` Created

The key was created

Response shape:

- `id` (string (uuid)) —
Key id. Pass it as `keyId` to read usage.

- `keyId` (string) —
Public key identifier.

- `keyPrefix` (string) —
First characters of the key, for recognising it.

- `name` (string) —

- `description` (string) —

- `status` (enum (&quot;active&quot; | &quot;revoked&quot; | &quot;expired&quot;)) —

- `scopes` (string[]) —

- `allowedProjectIds` (string[]) —
Projects the key is limited to; null means all of your projects.

- `rateLimitPerHour` (integer) —

- `rateLimitPerDay` (integer) —

- `maxConcurrentJobs` (integer) —

- `totalRequests` (integer) —

- `lastUsedAt` (string (date-time)) —

- `expiresAt` (string (date-time)) —

- `createdAt` (string (date-time)) —

- `apiKey` (string) —
The full `ivy_` key. Shown once and never returned again.

### `400` Bad Request

The name is missing, a limit is not a positive bounded integer, or a requested scope is reserved for .bloom*

Response shape: `object`

### `401` Unauthorized

A signed-in session is required

Response shape: `object`

### `403` Forbidden

The key would be limited to projects you cannot access (`unauthorizedProjectIds` lists them)

Response shape: `object`

### `404` Not Found

Your profile was not found

Response shape: `object`

### `429` Too Many Requests

Rate limit exceeded

Response shape: `object`

**curl**

```bash
curl -X POST 'https://ivybiosciences.com/api/user/api-keys' \
  -H "Authorization: Bearer $IVY_SESSION_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": ""
}'
```

**JavaScript**

```js
const res = await fetch('https://ivybiosciences.com/api/user/api-keys', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.IVY_SESSION_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": ""
}),
});
const data = await res.json();
```

**Python**

```python
import os, requests

res = requests.post(
    "https://ivybiosciences.com/api/user/api-keys",
    headers={"Authorization": f"Bearer {os.environ['IVY_SESSION_TOKEN']}"},
    json={
  "name": ""
},
)
data = res.json()
```
