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

# Update an API key

`PUT /api/api-keys/{api_key_id}`

# Errors
Returns error if API key not found, access denied, or database update error

## Path parameters

- `api_key_id` string, uuid, required

## Request body

- UpdateApiKeyRequest — Request payload for updating an API key
  - `expiresAt` string, date-time, nullable — Update the expiration date
  - `isActive` boolean, nullable — Change the active status of the key
  - `name` string, nullable — New name for the API key (optional)
  - `permissions` string[], nullable — Updated permissions array (optional)

## Response `200`

API key updated successfully

- ApiKeyResponse — API response model for API keys (excludes sensitive hash)
  - `createdAt` string, date-time, nullable — When this API key was originally created
  - `expiresAt` string, date-time, nullable — Expiration timestamp after which key becomes invalid
  - `id` string, uuid, required — Unique identifier for this API key in responses
  - `isActive` boolean, required — Current activation status of this API key
  - `keyPrefix` string, required — Key prefix for visual identification in API key lists
  - `lastUsedAt` string, date-time, nullable — Timestamp when the key was last used
  - `name` string, required — Descriptive name for this API key
  - `permissions` string[], required — Permissions granted to this API key for resource access
  - `updatedAt` string, date-time, nullable — API key last update timestamp
  - `userId` string, uuid, required — Owner user identifier

## Other responses

- `401` — Authentication required to update API keys
- `403` — Access denied - cannot update API key owned by different user
- `404` — API key not found for update
- `500` — Server error during API key update

---

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