---
title: Update an API key
description: Edits the name or role.
doc_version: 0.1.0-preview
last_updated: 2026-09-14
---

# Update an API key

`PATCH /v1/workspaces/{workspaceId}/api-keys/{keyId}`

Edits the name or role. The key stays the same.

## Authentication

Send `Authorization: Bearer <GRAPHON_API_KEY>`. Read the key from the
GRAPHON_API_KEY environment variable. Never print it.

## Path parameters

- `workspaceId` (string) — The workspace id.
- `keyId` (string) — The API key id.

## Request body

- `name` (string (optional)) — Display name.
- `role` (string (optional)) — New role. It cannot exceed the key owner's role or your role. One of: viewer, editor, admin.

## Example request

```bash
curl --request PATCH \
  --url "https://api.graphon.ai/v1/workspaces/wspq7ws2np5l8z4/api-keys/keyE5f6G7h8I9" \
  --header "Authorization: Bearer $GRAPHON_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"name":"Local CLI","role":"editor"}'
```

## CLI

```bash
graphon api-keys update gak_1a8Xk2mQ --role viewer
```

## Example response

```json
{
  "id": "apkE5f6G7h8I9",
  "workspaceId": "wspq7ws2np5l8z4",
  "name": "Local CLI",
  "maskedKey": "gak_GAK1a8Xk2mQ9pL0vT4cZ.••••",
  "ownerKind": "user",
  "ownerUserId": "usrB2c3D4e5F6",
  "createdByUserId": "usrB2c3D4e5F6",
  "role": "viewer",
  "createdAt": "2026-09-14T18:00:00.000Z",
  "lastUsedAt": null,
  "expiresAt": null,
  "revokedAt": null,
  "revision": 1
}
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
