Skip to main content
Glama

create_api_key

Create a new API key. The secret key value is returned ONLY in this response — store it securely. Note: the secret will be visible in the AI conversation context. Optionally bind the key to a sub-account via profile_id — outbound messages sent with the key are then branded as that sub-account. Optionally give it an end date with expires_at (ISO 8601 with offset, at least 5 minutes ahead); leave it out and the key never expires. Ask the user when the key should stop working rather than choosing for them. A date in the past or less than 5 minutes ahead is refused (validation_error) and nothing is created.

Agent usage: This operation requires 2FA bound to the key it creates — its environment, scopes, sub-account and end date: a code confirmed for one key does not create another. (1) Call create_api_key with what the user chose; nothing is created, and its 2fa_required refusal lists the exact targets for that key. (2) Call start_2fa with action_type "api_key_create" and exactly those targets (none if the refusal lists none); the user is shown the key they are approving. (3) Wait for the user to verify the code and poll get_2fa_status until "verified". (4) Call create_api_key again with the SAME arguments. One code creates one key.

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

This tool declares no required parameters. Add optional parameters from the input schema as needed.

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

Input Schema

NameRequiredDescriptionDefault
nameNoHuman-readable key name
scopesNoPermission scopes for the key
expires_atNoWhen the key stops working, ISO 8601 with offset (e.g. 2027-02-13T23:59:59+01:00), at least 5 minutes ahead. Omit for a key that never expires.
profile_idNoBind the new key to a sub-account you own (24-hex id). Immutable after creation; omit for an unbound account-wide key.
environmentNoKey environment (default: production)

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 key stops working, ISO 8601 with offset (e.g. 2027-02-13T23:59:59+01:00), at least 5 minutes ahead. Omit for a key that never expires.",
      +  "type": "string"
      +}
    • 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. Changed2 schema fields changed
    • changedInput schema / properties / profile_id / description
      Previous value: -"Bind the new key to a sub-account (PublicProfile) project you own (24-hex id). Immutable after creation; omit for an unbound account-wide key."New value: +"Bind the new key to a sub-account you own (24-hex id). Immutable after creation; omit for an unbound account-wide key."
    • 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.6/5.0
Behavior4/5

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

Annotations only say readOnlyHint=false and destructiveHint=false; the description goes well beyond that by disclosing that the secret is visible in conversation context, that validation failures create nothing, that profile_id is immutable, and that 2FA codes are scoped per key target set. It does not cover rate limits or what happens to existing keys, but for a create tool with annotations present this is strong added context.

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

Conciseness4/5

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

Long, but front-loaded and organized into purpose, secret-handling warning, optional-parameter notes, then a clearly enumerated 2FA workflow and an access block. Some redundancy exists, notably the 5-minute expires_at rule repeated from the schema, which keeps it from a 5.

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?

An output schema exists so return values need no explanation, yet the description still flags the single most important return property (the secret appears only in this response). Combined with auth and 2FA prerequisites, an agent has everything needed to invoke this correctly on the first attempt.

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%, so the baseline is 3; the description still adds real meaning by explaining the downstream consequence of profile_id (outbound messages branded as that sub-account) and by restating the expires_at validation threshold and the never-expires default. It adds marginal value on name and scopes but compensates on the two parameters with non-obvious effects.

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 ('Create a new API key') and immediately distinguishes it from lifecycle siblings (regenerate_api_key, revoke_api_key) by making clear this is the initial creation path. The added note that the secret is returned only once further pins down what this call uniquely produces.

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?

Gives an explicit prerequisite chain (start_login → wait_for_login → retry this tool) and a numbered 4-step 2FA procedure including which sibling to call (start_2fa, get_2fa_status) and the exact re-invocation rule. It also states a preference decision the agent should defer to the user ('Ask the user when the key should stop working rather than choosing for them'), which is genuine when-to-use guidance.

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.