--- title: "Rename an API key" canonical: "https://admiral.io/docs/api/users/ApiKeyAPI_RenameApiKey" --- # Rename an API key `POST https://api.admiral.io/v1/users/{user}/apiKeys/{apiKey}/rename` - ALREADY_EXISTS when another of the caller's active, unexpired keys has the new name. - ABORTED when `etag` is set and the key changed since it was read. Scope: `apikey:write` ### Path parameters - `user` (string, required): The user id. - `apiKey` (string, required): The apiKey id. ### Request body - `new_name` (string, required): The new name, under the same rules as the key's `name`. new_name.not_uid // an API key name may not have the shape of a uid Pattern `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. Length 1 to 63. - `etag` (string): When set, the rename is refused unless it matches the key's current etag. ### Response 200 Success - `api_key` (ApiKey): The key under its new name. - `uid` (string): `key-` and twelve base36 characters. Never changes and is never reused, so it is what a reference to the key holds. Pattern `^key-[0-9a-z]+$`. Read-only. - `name` (string, required): (IMMUTABLE) The name, such as `ci-deploy`. Unique among the binding's keys that can still authenticate, set on create and changed only by RenameApiKey. Lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit, 1 to 63 characters. It may not have the shape of a uid (`key-` and twelve characters). name.not_uid // an API key name may not have the shape of a uid Pattern `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. Length 1 to 63. - `display_name` (string): A label for people, such as "CI deploy". Optional; clients show the name when it is unset. Length at most 128. - `resource_name` (string): (IDENTIFIER) The resource name, such as `users/usr-01j9t5b6c3h1/apiKeys/ci-deploy`. Its parent says whose key it is. Built from the names of the key and its parent, so it changes when either is renamed; refer to a key by `uid` to keep a reference stable. Identifies the key on update. Pattern `^(users/(usr-[0-9a-z]+|-)|serviceAccounts/([a-z]([a-z0-9-]{0,61}[a-z0-9])?|-))/apiKeys/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. - `scopes` (array of string): The scopes granted to this key, and the ceiling on any access token minted from it. Must be a subset of the caller's own scopes. Items at most 255. - `expires_at` (Timestamp): (IMMUTABLE) When the key expires. Unset never expires. Fixed at creation; organization policy may cap it. - `status` (ApiKeyStatus): ApiKeyStatus represents the lifecycle state of an API key. One of `API_KEY_STATUS_UNSPECIFIED`, `ACTIVE`, `REVOKED`. Read-only. - `last_used_at` (Timestamp): When the key was last exchanged for an access token. Minted tokens are reused for their lifetime, so this reads as "still in use" at that granularity, not as the time of the last request. Read-only. - `revoked_at` (Timestamp): Set when the key was revoked. Read-only. - `etag` (string): Changes whenever the key does. Send it back on update or rename to refuse the change if someone else changed the key first. Read-only. - `created_by` (ActorRef): ActorRef is a lightweight reference to the user or agent that performed an action. Server-populated on all resource responses. Clients should never send this. Read-only. - `id` (string): The actor's typed id: a `usr-` user id or an `sa-` service account id. - `display_name` (string): Human-readable name (e.g., "John Smith", "deploy-bot"). - `email` (string): Email address (empty for non-human actors). - `created_at` (Timestamp): A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC. Read-only.