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

# Update API key

`PATCH /api/v3/keys/{id}`

Update an existing API key.

Supports renaming and replacing the workspace scope:
- Pass `scopes` with a non-empty list of `{workspace_id, permission}` entries to replace the full scope set. Existing scope rows not in the new list are dropped.
- Pass `scopes: []` to unscope the key entirely.
- The permission ceiling on each scoped workspace is re-validated against your current role there.

## Path parameters

- `id` string, required

## Request body

- PatchedUpdateAPIKeyV3Request — Reject any request fields not declared on the serializer.
  - `name` string
  - `scopes` APIKeyScopeRequest[] — Replace the key's full scope set. Pass an empty list to unscope the key. Each entry's role is re-validated against your current role on the workspace.
    - `workspace_id` integer, required
    - `role` 'viewer' | 'editor' | 'owner', required — * `viewer` - viewer * `editor` - editor * `owner` - owner

## Response `200`

The updated API key.

- APIKeyV3Response
  - `id` string, required
  - `name` string, required
  - `prefix` string, required
  - `created_at` string, date-time, required
  - `expires_at` string, date-time, nullable, required
  - `scopes` APIKeyScope[], required
    - `workspace_id` integer, required
    - `workspace_name` string, required
    - `workspace_upload_method` string, required
    - `workspace_datasource_type` string, nullable, required
    - `role` string, required
    - `scope_type` 'workspace' | 'global', required — * `workspace` - workspace * `global` - global

## Other responses

- `400` — Bad Request — invalid fields or permission ceiling exceeded.
- `401` — Authentication credentials were not provided or are invalid
- `404` — The requested resource was not found

---

[API](https://skmtc.dev/lighton/apis/lighton-api.md) · [All operations](https://skmtc.dev/lighton/apis/lighton-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/lighton/lighton-api/revisions/86c57e94ef15/schema)
