---
title: "overlane api-key rotate"
description: "Rotate an API key: a new secret with the same settings, the old key revoked at once"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.overlane.app/llms.txt
> Use this file to discover all available pages before exploring further.

# overlane api-key rotate

{/* Generated by apps/docs/scripts/generate.mjs (CLI pages from the command registry in packages/cli). Do not edit; run `pnpm --filter @overlane/docs gen`. */}

Issues a new key with the old key's label, scopes, project, cap and remaining lifetime, and revokes the old key in the same step: the next call with the old key fails. The new secret is shown once. Rotating is in the secrets autonomy class.

## Usage

```sh
overlane api-key rotate key-id [--service URL] [--team TENANT_ID] [--dry-run]
```

## Arguments

| Argument | Required | Description |
| --- | --- | --- |
| `key-id` | yes | The key ID from `overlane api-key list` |

## Flags

| Flag | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `--service` | string | no |  | The service address (default: OVERLANE_SERVICE_URL, then the project's binding, then the hosted service) |
| `--team` | string | no |  | The team (tenant) to act on (default: the one your token belongs to) |
| `--dry-run` | boolean | no |  | Print the requests and file changes this command would make, then stop. Needs no credentials. |

## Examples

```sh
overlane api-key rotate key_0123456789abcdef
overlane api-key rotate key_0123456789abcdef --dry-run
```

## Behavior

- Effect: `write` (changes local or hosted state).
- Needs credentials: yes. Uses the network: yes.
- Supports `--dry-run`: yes. Accepts `--force`: no.
- Machine-readable description: `overlane schema api-key rotate`.

## Result

With `--json` (the default when stdout is not a terminal) the command prints this JSON Schema's shape on stdout.

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "tenantId": {
          "type": "string"
        },
        "key": {
          "type": "object",
          "properties": {
            "keyId": {
              "type": "string"
            },
            "label": {
              "type": "string"
            },
            "prefix": {
              "type": "string"
            },
            "scopes": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "project": {
              "type": "string"
            },
            "rateLimitPerMinute": {
              "type": "number"
            },
            "expiresAt": {
              "type": "string"
            },
            "lastUsedAt": {
              "type": "string"
            },
            "revokedAt": {
              "type": "string"
            },
            "rotatedFrom": {
              "type": "string"
            }
          },
          "required": [
            "keyId",
            "label",
            "prefix",
            "scopes",
            "expiresAt"
          ],
          "additionalProperties": false
        },
        "secret": {
          "type": "string"
        },
        "next": {
          "type": "string"
        }
      },
      "required": [
        "tenantId",
        "key",
        "secret",
        "next"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "dryRun": {
          "type": "boolean",
          "const": true
        },
        "service": {
          "type": "string"
        },
        "requests": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "method": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "body": {},
              "note": {
                "type": "string"
              }
            },
            "required": [
              "method",
              "path"
            ],
            "additionalProperties": false
          }
        },
        "commands": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "writes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string"
              },
              "action": {
                "type": "string",
                "enum": [
                  "write",
                  "append",
                  "delete"
                ]
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "path",
              "action",
              "description"
            ],
            "additionalProperties": false
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "dryRun",
        "requests",
        "commands",
        "writes",
        "notes"
      ],
      "additionalProperties": false
    }
  ]
}
```

See [exit codes](/cli/#exit-codes) for the status the process returns.

Source: https://docs.overlane.app/cli/api-key-rotate/index.mdx
