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

# Update Api Key

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

## Request

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

Update an API key. Requires a Pro plan or higher.

Gated because a PATCH can widen `scopes` (read -> write/admin) and flip
`is_active` back on — the same capability grant `create` charges for. A
free caller who wants a key switched off can still DELETE it, which stays
ungated, so this gate cannot strand anyone with a key they cannot revoke.

## Path parameters

- `key_id` string, required

## Request body

- APIKeyUpdate
  - `name` string, nullable
  - `scopes` string[], nullable
  - `is_active` boolean, nullable
  - `allowed_ips` string[], nullable
  - `allowed_rankings` string[], nullable
  - `rate_limit` integer, nullable

## Response `200`

Successful Response

- APIKeyResponse
  - `id` string, required
  - `name` string, required
  - `key_prefix` string, required
  - `scopes` string[], required
  - `rate_limit` integer, required
  - `is_active` boolean, required
  - `expires_at` string, date-time, nullable, required
  - `last_used_at` string, date-time, nullable, required
  - `usage_count` integer, required
  - `created_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

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