Skip to main content
Glama

regenerate_api_key

Destructive

Regenerate an API key: issues a new key (a new id and secret) with the same name, environment, scopes and sub-account. Pass expires_at to choose when the new key stops working — a date, or null for never; leave it out and the new key keeps the old key's end date (or none). Ask the user rather than choosing. The answer's expires_at is when the new key stops working (carried from the old key when you send none); with no expires_at the new key never expires. A key whose expires_at has passed (see list_api_keys) is refused (api_key_expired) and a new date does not revive it, so check it before starting 2FA: for a key an MCP sign-in minted the message reads "This key stopped working on and can't be turned back on. Connect your AI client again to get a new one."; for any other key, "This key stopped working on and can't be turned back on. Create a new key." The old key stops working immediately; use the id in this response from now on. The new key lists the old one in replaced_key_ids, so its requests and usage stay with it. The new secret is returned ONLY in this response. Note: the secret will be visible in the AI conversation context.

Agent usage: This operation requires 2FA bound to this key and to the end date sent (none sent, a date, and null are three different confirmations). (1) Call regenerate_api_key with the end date the user chose, or none; its 2fa_required refusal lists the exact targets — [""] with no expires_at, ["", "act:expires_at:<the instant as UTC ISO 8601 with milliseconds>"] for a date, "act:expires_at:never" for null. (2) Call start_2fa with action_type "api_key_regenerate" and exactly those targets; the user is shown the new end date (or "never") they are approving. (3) Wait for the user to verify the code and poll get_2fa_status until "verified". (4) Call regenerate_api_key again with the SAME expires_at.

ACCESS: needs a Proof account, signed in: call start_login, show the user its challenge, then wait_for_login, then call this tool again. Authenticating this client alone does NOT open this tool.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "id": "<id>"
    },
    "name": "regenerate_api_key"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYesAPI key ID to regenerate
expires_atNoWhen the new key stops working, ISO 8601 with offset, at least 5 minutes ahead — or null for a key that never expires. Leave it out to keep the old key's end date.

Output Schema

NameRequiredDescriptionDefault
idYesMongoDB ObjectId
keyYesThe full API key. Returned only in this response; it cannot be read again.
nameYes
prefixYes
scopesYes
warningYes
created_atYes
expires_atNoWhen the key stops working. Present when the key has an expiry: the one asked for at creation; on a regenerated key the one asked for while regenerating, else the old key's instant, carried over. Absent on a key that never expires.
profile_idYesSub-account (PublicProfile) the key is bound to; null for unbound keys.
environmentYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / expires_at
      Added value: +{
      +  "description": "When the new key stops working, ISO 8601 with offset, at least 5 minutes ahead — or null for a key that never expires. Leave it out to keep the old key's end date.",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • changedOutput schema / properties / expires_at / description
      Previous value: -"When the key stops working. Present only on a regenerated key that has an expiry (the old key's instant, carried over); absent on a key that never expires."New value: +"When the key stops working. Present when the key has an expiry: the one asked for at creation; on a regenerated key the one asked for while regenerating, else the old key's instant, carried over. Absent on a key that never expires."
  2. Changed1 schema field changed
    • addedOutput schema / properties / expires_at
      Added value: +{
      +  "description": "When the key stops working. Present only on a regenerated key that has an expiry (the old key's instant, carried over); absent on a key that never expires.",
      +  "type": "string"
      +}
  3. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": {},
      +  "description": "A newly created or regenerated API key, with its full value — the one response that carries it.",
      +  "properties": {
      +    "created_at": {
      +      "type": "string"
      +    },
      +    "environment": {
      +      "type": "string"
      +    },
      +    "id": {
      +      "description": "MongoDB ObjectId",
      +      "type": "string"
      +    },
      +    "key": {
      +      "description": "The full API key. Returned only in this response; it cannot be read again.",
      +      "type": "string"
      +    },
      +    "name": {
      +      "type": "string"
      +    },
      +    "prefix": {
      +      "type": "string"
      +    },
      +    "profile_id": {
      +      "description": "Sub-account (PublicProfile) the key is bound to; null for unbound keys.",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "scopes": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "warning": {
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "id",
      +    "key",
      +    "name",
      +    "prefix",
      +    "environment",
      +    "scopes",
      +    "profile_id",
      +    "created_at",
      +    "warning"
      +  ],
      +  "type": "object"
      +}
  4. Changed1 schema field changed
    • removedInput schema / additionalProperties
      Removed value: -false
  5. First observed

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the destructiveHint=true annotation: the old key stops working immediately, the new key must be addressed by the returned id, the old key is recorded under replaced_key_ids, and the new secret appears only in this response and will be visible in the AI conversation context. It also spells out the exact 2FA confirmation targets for the three expires_at variants and the exact refusal messages, which is genuinely useful behavioral disclosure for an irreversible operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action, but it restates the expires_at inheritance rule twice ('leave it out and the new key keeps the old key's end date' and later 'carried from the old key when you send none') and quotes two full user-facing error strings verbatim. The numbered 2FA procedure earns its place; the duplication and quoted prose do not.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given a destructive mutation with 2FA, an output schema present for return values, and an auth precondition (Proof account via start_login/wait_for_login), the description covers everything an agent needs: preconditions, the four-step confirmation flow, failure modes, and post-call obligations. Nothing material is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the schema already documents id and the three-way expires_at behavior, so the baseline is 3. The description adds meaning the schema does not carry — that the three cases (omitted, date, null) are three distinct 2FA confirmations with different action targets, and that the response's expires_at is what the new key will actually adopt.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Regenerate an API key') and immediately defines the result: a new id and secret that inherit the same name, environment, scopes and sub-account. This is enough to separate it from create_api_key, revoke_api_key or set_api_key_expiry without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to guidance: ask the user rather than choosing an end date, check the existing expires_at via list_api_keys before starting 2FA, and abort if the key has already expired since a new date will not revive it. It also warns that an expired key is refused with api_key_expired, so the agent knows the precondition and the failure path.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.