---
title: "Update API key"
method: PATCH
path: "/api/api-keys/{key_id}"
tags: ["api-keys"]
---

# Update API key

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

Updates the name of a specific API key

## Path parameters

- `key_id` string, required — ID of the API key to update

## Request body

- APIKeyUpdateRequest
  - `name` string, required — New name for the API key

## Response `200`

Successful Response

- APIKeyResponse — Represents an API key for authentication (without exposing the actual key).
  - `id` string, required — Unique API key identifier with 'apikey_' prefix
  - `name` string, nullable — Optional descriptive name for this API key
  - `created_at` string, date-time, required — When this API key was created
  - `last_used_at` string, date-time, nullable — When this API key was last used for authentication
  - `is_active` boolean, required — Whether this API key is currently valid and can be used
  - `actions` GrantAction[], nullable — Action verbs this key's grant allows; null for legacy keys
  - `library_scope_mode` 'all_libraries' | 'selected_libraries' — Which of the owner's libraries a credential covers. `all_libraries` means all current and future live libraries owned by the user. `selected_libraries` means only explicitly selected libraries, with no automatic expansion.
  - `selected_library_count` integer, nullable — Number of libraries a 'selected_libraries' grant covers; null unless library_scope_mode is 'selected_libraries'

## Other responses

- `401` — Missing, invalid, or expired credentials.
- `403` — The credentials are valid but not authorized for this operation — for example an API key whose action or library scope excludes it, or a credential type this operation does not accept.
- `404` — Not found
- `422` — Validation Error
- `429` — Rate limit exceeded. Retry after the interval in the `Retry-After` header.

---

[API](https://skmtc.net/gumnut-ai/apis/gumnut-api.md) · [All operations](https://skmtc.net/gumnut-ai/apis/gumnut-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gumnut-ai/gumnut-api/versions/e71db45f5d4a/schema)
