---
title: "Rename a key or change its limit"
method: PATCH
path: "/api_keys/{id}"
tags: ["API Keys"]
---

# Rename a key or change its limit

`PATCH /api_keys/{id}`

## Request

- Base URL: `https://alttext.ai/api/v1`
- URL: `https://alttext.ai/api/v1/api_keys/{id}`
- Auth: API key in header `X-API-Key`

Changes `name` and `usage_limit`. Fields you leave out are unchanged; `usage_limit: null` removes the limit.
A revoked key can't be changed (`409` `key_revoked`). Changes are recorded in the audit trail.

## Path parameters

- `id` integer, required

## Request body

- ApiKeyUpdate
  - `name` string
  - `usage_limit` integer, nullable: The recorded-usage threshold that stops new requests this billing period. In-flight work can still be charged beyond it. `null` removes the limit.

## Response `200`

The updated key.

- ApiKey: An API key. The API Keys endpoints list and manage `site` keys. Full-access keys, MCP connection keys and the Webflow Designer key are never returned.
  - `id` integer
  - `name` string
  - `kind` 'site': Always `site` here. Full-access keys are created and managed in the dashboard only.
  - `origin` 'unknown' | 'dashboard' | 'api' | 'shopify' | 'bigcommerce' | 'wordpress_connect': Where the key was created.
  - `integration` 'shopify' | 'bigcommerce' | 'wordpress_connect' | 'null', nullable: The integration that created and uses this key, or `null`. Rotating or revoking an integration key stops that integration until it reconnects.
  - `status` 'active' | 'revoked'
  - `token` string, nullable: The key's token, or `null` once the key is revoked or when an assistant connection without write access reads it. Tokens begin with `atai_`. Keys created before that format existed keep their original tokens, which stay valid. Treat the token as a secret.
  - `token_hint` string, nullable: The last four characters of the token, or `null` once the key is revoked.
  - `usage_limit` integer, nullable: The recorded-usage threshold that stops new requests this billing period. In-flight work can still be charged beyond it. `null` means no limit.
  - `credits_used` integer: Credits this key has used this period, counted against `usage_limit`.
  - `billable_credits` integer: Every credit charged to the account through this key this period, whether or not the charge crossed the key's limit.
  - `billable_complete` boolean: Whether every charge in the current period was tracked by the billing-aware release after the operator's verified old-task drain cutoff. False when tracking is incomplete or the cutoff is absent.
  - `period_start` string, date-time, nullable: When the current period started, if the key has been reset.
  - `resets_at` string, date-time, nullable: When the account's current billing period ends, or `null` when it has no active subscription with a renewal date.
  - `previous_period` ApiKeyPreviousPeriod: The credits billed through the key in its last closed period. `null` until the key has had a reset or been revoked.
    - `billable_credits` integer: Every credit charged to the account through this key during that period, whether or not the charge crossed the key's limit.
    - `billable_complete` boolean: `false` when the period started or was recorded before billable credits were tracked, so the number can be low.
    - `recorded_at` string, date-time: When the period closed.
  - `created_by` ApiKeyCreator: Who created the key, from the audit trail. `null` for keys that predate the audit trail.
    - `type` 'user' | 'api_key' | 'mcp_connection' | 'system'
    - `name` string, nullable
  - `created_at` string, date-time
  - `last_used_at` string, date-time, nullable
  - `revoked_at` string, date-time, nullable

## Other responses

- `403`: The request was refused. `error_code` is one of: - `invalid_api_key`: the `X-API-Key` header is missing or doesn't match a key. - `api_key_revoked`: the key was revoked. Create a new key. - `full_access_required`: managing keys needs a full-access key. Create one in the dashboard under Account > API Keys. - `insufficient_scope`: an assistant connection lacks the Manage API keys permission (`required_scope` is `mcp:keys`), or read-only access when changing keys or revealing a token (`mcp:write`). Reconnect with the permission. - `credential_no_longer_authorized`: the account closed or the calling credential lost authority before the mutation acquired its lock. Reconnect or use a current full-access key. - `out_of_scope`: this key can't be used for this request.
- `404`: No manageable key with that ID on this account. `error_code` is `not_found`. Full-access keys, MCP connection keys and the Webflow Designer key are never found here.
- `409`: The key is revoked. `error_code` is `key_revoked`. Create a new key instead.
- `422`: `error_code` is `invalid_params` (blank or too long name, negative limit, or `kind` sent) or `reserved_name`.
- `429`: Too many key requests for this account. The limit is 120 reads and 30 changes per minute, counted per account across all the API Keys endpoints. Wait `Retry-After` seconds. `error_code` is `rate_limited`.

---

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