---
title: "Rename an API key or change its tool set"
method: PATCH
path: "/credits/tenants/me/keys/{keyId}"
tags: ["Tenants"]
---

# Rename an API key or change its tool set

`PATCH /credits/tenants/me/keys/{keyId}`

## Request

- Base URL: `https://api.paywithlocus.com/api`
- URL: `https://api.paywithlocus.com/api/credits/tenants/me/keys/{keyId}`
- Auth: HTTP bearer

The secret itself never changes. Pass name, toolSetId, or both. toolSetId moves the key to that tool set (null moves it to Main); the next request with the same key uses the new set. Only secret keys take a tool set, and binding one narrows the key to the execution audience (moving back to Main keeps it narrowed). A rename alone appends a RENAMED credential audit event; a tool set change appends UPDATED with toolSetId and previousToolSetId. Requires a workspace owner or admin with MFA step-up completed in the last ten minutes.

## Path parameters

- `keyId` string, uuid, required

## Headers

- `X-Locus-Step-Up` string, password

## Request body

- object
  - `name` string
  - `toolSetId` string, uuid, nullable: A tool set id from GET /credits/tool-sets, or null for Main.

## Response `200`

Updated key metadata under keyMetadata.

## Other responses

- `400`: Invalid name (empty, over 100 characters, or control characters), a tool set on a publishable or sandbox key, an empty body, an unknown body field, or the key is revoked.
- `403`: STEP_UP_REQUIRED or INSUFFICIENT_SCOPE.
- `404`: No such key, or no live tool set with that id, in this workspace (malformed ids included).

---

[API](https://skmtc.dev/paywithlocus/apis/locus-pro-api.md) - [All operations](https://skmtc.dev/paywithlocus/apis/locus-pro-api/llms.txt) - [OpenAPI document](https://skmtc.dev/paywithlocus/apis/locus-pro-api/revisions/aab8fa5d6cef?raw)
