---
title: "Update Api Key"
method: PATCH
path: "/api/v1/config/api-keys/{key_id}"
tags: ["api-keys"]
---

# Update Api Key

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

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/config/api-keys/{key_id}`
- Auth: none declared

Set or clear the key's MCP default context (#2129).

The only field this route changes. A context-scoped MCP tool called with
this key and without ``context_id`` runs in the default (``?context=``
on the URL wins). The context must be readable by the key's owner now,
within the key's workspace scope; otherwise 404 ``Context not found``
(the same answer for a context that does not exist). Public-bound and
agent-bound keys cannot carry one (422): an agent key's default is its
agent's default binding.

Raises:
    NotFoundException: The key is not the caller's, or the context is not
        readable (404).
    BadRequestError: The key is revoked (400).
    ValidationError: The key is public-bound, agent-bound or a connector's
        shared key (422).

## Path parameters

- `key_id` string, required: Public id of the API key (`akey_` + 22 base62 characters).

## Headers

- `authorization` string, nullable

## Request body

- APIKeyUpdate: Request model for ``PATCH /config/api-keys/{key_id}`` (#2129).
  - `default_context_id` string, uuid, nullable, required: The key's MCP default context; null clears it.

## Response `200`

Successful Response

- APIKeyResponse: Response model for API key metadata.
  - `id` unknown, required
  - `key_prefix` unknown, required
  - `name` unknown, required
  - `user_id` unknown, required
  - `created_at` unknown, required
  - `last_used_at` unknown
  - `revoked_at` unknown
  - `expires_at` unknown
  - `status` unknown, required
  - `default_context_id` unknown
  - `default_context_name` unknown

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-20** `09f17f5ada29`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/changes/api/v1/config/api-keys/:key_id/patch.md)

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/09f17f5ada29?raw)
