---
title: PATCH /user/api-keys
description: "Revoke, archive or move several API keys — Applies one action to up to 50 of your keys at once. revoke and archive both set the status to revoked…"
full: true
---

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

Applies one action to up to 50 of your keys at once. `revoke` and `archive` both set the status to `revoked`; `move` replaces each key's project restriction. If any key belongs to someone else, or the batch includes a key the action can't touch, nothing is changed: `revoke` and `archive` refuse the key .bloom* manages for job callbacks, and `move` refuses that key and every other key .bloom* manages. Requires a signed-in session; an `ivy_` key is answered with `401`.

## Request

### Request body

- `action` (enum (&quot;revoke&quot; | &quot;archive&quot; | &quot;move&quot;)) —

- `keyIds` (string (uuid)[]) —

- `allowedProjectIds` (string[]) —
Required for `move`. An empty array removes the project restriction.

## Responses

### `200` OK

The action was applied

Response shape:

- `success` (boolean) —

- `action` (enum (&quot;revoke&quot; | &quot;archive&quot; | &quot;move&quot;)) —

- `affected` (integer) —
Number of keys in the request that the action was applied to.

### `400` Bad Request

`keyIds` is empty or longer than 50, `action` is not recognised, or `allowedProjectIds` is missing for `move`

Response shape: `object`

### `401` Unauthorized

A signed-in session is required

Response shape: `object`

### `403` Forbidden

Some keys are not yours (`unauthorizedIds`), a project is not accessible to you, or the batch includes a managed key the action refuses (`managedKeyIds`). If a key becomes managed while the request runs, the other keys are still changed: read `affected` and `refused`

Response shape: `object`

### `429` Too Many Requests

Rate limit exceeded

Response shape: `object`

**curl**

```bash
curl -X PATCH 'https://ivybiosciences.com/api/user/api-keys' \
  -H "Authorization: Bearer $IVY_SESSION_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "action": "revoke",
  "keyIds": [
    "00000000-0000-0000-0000-000000000000"
  ]
}'
```

**JavaScript**

```js
const res = await fetch('https://ivybiosciences.com/api/user/api-keys', {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${process.env.IVY_SESSION_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "action": "revoke",
  "keyIds": [
    "00000000-0000-0000-0000-000000000000"
  ]
}),
});
const data = await res.json();
```

**Python**

```python
import os, requests

res = requests.patch(
    "https://ivybiosciences.com/api/user/api-keys",
    headers={"Authorization": f"Bearer {os.environ['IVY_SESSION_TOKEN']}"},
    json={
  "action": "revoke",
  "keyIds": [
    "00000000-0000-0000-0000-000000000000"
  ]
},
)
data = res.json()
```
