> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openinary.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Update API Key

> Rename or enable/disable an existing API key

**Self-hosted only.** Cloud keys are managed in the dashboard, not through the API.

Patch a key by its ID to rename it, or to disable it without deleting it. Send only the fields you want to change.

```bash theme={null}
curl -X PATCH https://media.example.com/api-keys/key_abc123 \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name": "production-v2"}'
```

```
PATCH /api-keys/{keyId}
```

**Auth:** API Key or Session · **Content-Type:** `application/json`

Get `keyId` from [List API Keys](https://docs.openinary.dev/api-reference/api-keys/list.md).

## Parameters

| Field | In | Type | Notes |
| - | - | - | - |
| `keyId` | path | string | Required. ID of the key to update |
| `name` | body | string | New display name |
| `enabled` | body | boolean | `false` disables the key, `true` re-enables it |

## Disable a key

```bash theme={null}
curl -X PATCH https://media.example.com/api-keys/key_abc123 \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'
```

## Response

```json theme={null}
{
  "success": true,
  "key": {
    "id": "key_abc123",
    "name": "production-v2",
    "enabled": true
  },
  "message": "API key updated successfully"
}
```

**Status codes:** `200` success · `401` unauthorized · `403` forbidden · `404` not found · `500` error

## Related

> [card] [List API Keys](https://docs.openinary.dev/api-reference/api-keys/list.md)
>
> Find the key ID.

> [card] [Delete API Key](https://docs.openinary.dev/api-reference/api-keys/delete.md)
>
> Permanently revoke a key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.