---
title: "Update an API key"
method: PATCH
path: "/v1/api-keys/{api_key_id}"
tags: ["API Keys"]
---

# Update an API key

`PATCH /v1/api-keys/{api_key_id}`

## Request

- Base URL: `https://api.naturali.ai`
- URL: `https://api.naturali.ai/v1/api-keys/{api_key_id}`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.naturali.ai/authorize`, token URL `https://api.naturali.ai/token`, scopes: `mcp:access`)

Rename an API key or replace its capability set. The scope (project vs account) is immutable.

## Request body

- ApiKeyUpdate: At least one field must be present. Scope is immutable.
  - `name` string
  - `capabilities` string[]: Replace the capability set (empty array clears all).

## Response `200`

API key updated.

- ApiKeyRecord
  - `id` string, required: Public API key ID (key_ prefix).
  - `name` string, required
  - `key_prefix` string, required: Leading characters of the raw key, for identification.
  - `scope` 'project' | 'account', required: Whether the key is scoped to one project or the whole account.
  - `project_id` string, nullable: The project this key is scoped to; null for account-scoped keys.
  - `capabilities` string[], required: Capabilities granted to this key. Empty means it inherits the creator's.
  - `created_at` string, date-time, required
  - `last_used_at` string, date-time, nullable: When the key was last presented; null if never used.

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Missing or invalid credentials.
- `403`: Authenticated, but not permitted to act on this key.
- `404`: The resource does not exist (existence is not leaked).

---

[API](https://skmtc.dev/naturali/apis/naturali-ai-api.md) · [All operations](https://skmtc.dev/naturali/apis/naturali-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/naturali/apis/naturali-ai-api/revisions/e4905b78f422?raw)
