---
title: "Update key"
method: PATCH
path: "/v1/organizations/{organizationId}/keys/{keyId}"
tags: ["API keys"]
---

# Update key

`PATCH /v1/organizations/{organizationId}/keys/{keyId}`

## Request

- Base URL: `https://api.clickhouse.cloud`
- URL: `https://api.clickhouse.cloud/v1/organizations/{organizationId}/keys/{keyId}`
- Auth: HTTP basic

Updates API key properties.

## Path parameters

- `organizationId` string, uuid, required
- `keyId` string, uuid, required

## Request body

- ApiKeyPatchRequest
  - `name` string: Name of the key
  - `roles` string[]: DEPRECATED. Use `assignedRoleIds` instead. List of roles assigned to the key.
  - `assignedRoleIds` string[]: Array of role UUIDs to assign to the API key
  - `expireAt` string, date-time, nullable: Timestamp the key expires. If `null` or is empty the key never expires. ISO-8601.
  - `state` 'enabled' | 'disabled': State of the key: 'enabled', 'disabled'.
  - `ipAccessList` IpAccessListEntry[]: List of IP addresses allowed to access the API using this key
    - `source` string: IP or CIDR
    - `description` string: Optional description of IPv4 address or IPv4 CIDR to allow access from

## Response `200`

Successful response

- object
  - `status` number: HTTP status code.
  - `requestId` string, uuid: Unique id assigned to every request. UUIDv4
  - `result` ApiKey
    - `id` string, uuid: Unique API key ID.
    - `name` string: Name of the key
    - `state` 'enabled' | 'disabled': State of the key: 'enabled', 'disabled'.
    - `roles` string[]: DEPRECATED. Use `assignedRoles` instead. List of roles assigned to the key. For organizations that have migrated to custom roles, this field is frozen at the pre-migration value and does not reflect current role assignments.
    - `assignedRoles` AssignedRole[]: Custom roles and System roles assigned to this API key
      - `roleId` string, uuid: Unique identifier of the role
      - `roleName` string: Human-readable name of the role
      - `roleType` 'system' | 'custom': Type of role: system (predefined) or custom (organization-defined)
    - `keySuffix` string: Last 4 letters of the key.
    - `createdAt` string, date-time: Timestamp the key was created. ISO-8601.
    - `expireAt` string, date-time, nullable: Timestamp the key expires. If not present, `null` or is empty the key never expires. ISO-8601.
    - `usedAt` string, date-time: Timestamp the key was used last time, with one-minute precision. If not present the key was never used. ISO-8601.
    - `ipAccessList` IpAccessListEntry[]: List of IP addresses allowed to access the API using this key
      - `source` string: IP or CIDR
      - `description` string: Optional description of IPv4 address or IPv4 CIDR to allow access from

## Other responses

- `400`: The request cannot be processed due to a client error. Please verify your request parameters and try again.
- `500`: An internal server error has occurred. If this issue persists, please contact ClickHouse Cloud support for assistance.

---

[API](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud.md) - [All operations](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud/llms.txt) - [OpenAPI document](https://skmtc.dev/clickhouse/apis/openapi-spec-for-clickhouse-cloud/revisions/eac345053548?raw)
