Skip to main content
Glama

update_api_key

Modify an existing API key's name, description, scopes, credit limit, rate limit, defaults, or expiration. Changes apply immediately without revoking the key.

Instructions

Update an API key's name, description, scopes, defaults, or limits, unlike delete_api_key which revokes it or create_api_key which issues a new one. Changes take effect immediately for downstream callers, type and sub-type stay fixed after creation, and the call returns success without rotating the secret.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe UUID of the API key to update
nameNoNew display name for the key
descriptionNoNew description for the key
scopesNoNew permission scopes for the key
credit_limitNoNew credit limit for usage
alert_thresholdNoNew alert threshold percentage (0-100)
rate_limit_rpmNoNew rate limit in requests per minute
default_config_idNoNew default configuration ID
default_metadataNoNew default metadata key-value pairs
alert_emailsNoNew email addresses for alerts
expires_atNoNew expiration date in ISO 8601 format, or null to remove expiration

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the tool call succeeded and returned structured data
dataNoStructured success payload when ok is true
errorNoStructured error payload when ok is false

Implementation Reference

  • Tool handler for 'update_api_key' — MCP tool registration and callback that accepts params, calls the service layer, and returns success response.
    // Phase 2: Update API key tool
    server.tool(
    	"update_api_key",
    	"Update an API key's name, description, scopes, defaults, or limits, unlike delete_api_key which revokes it or create_api_key which issues a new one. Changes take effect immediately for downstream callers, type and sub-type stay fixed after creation, and the call returns success without rotating the secret.",
    	KEYS_TOOL_SCHEMAS.updateApiKey,
    	async (params) => {
    		const result = await service.keys.updateApiKey(params.id, {
    			name: params.name,
    			description: params.description,
    			scopes: params.scopes,
    			usage_limits: buildUsageLimits({
    				credit_limit: params.credit_limit,
    				alert_threshold: params.alert_threshold,
    			}),
    			rate_limits: buildRateLimitsRpm(params.rate_limit_rpm),
    			defaults:
    				params.default_config_id !== undefined ||
    				params.default_metadata !== undefined
    					? {
    							config_id: params.default_config_id,
    							metadata: params.default_metadata,
    						}
    					: undefined,
    			alert_emails: params.alert_emails,
    			expires_at: params.expires_at,
    		});
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(
    						{
    							message: `Successfully updated API key "${params.id}"`,
    							success: result.success,
    						},
    						null,
    						2,
    					),
    				},
    			],
    		};
    	},
    );
  • Input schema (Zod) for the update_api_key tool — defines all optional fields: id, name, description, scopes, credit_limit, alert_threshold, rate_limit_rpm, default_config_id, default_metadata, alert_emails, expires_at.
    updateApiKey: {
    	id: z.string().uuid().describe("The UUID of the API key to update"),
    	name: z.string().optional().describe("New display name for the key"),
    	description: z.string().optional().describe("New description for the key"),
    	scopes: z
    		.array(z.string())
    		.optional()
    		.describe("New permission scopes for the key"),
    	credit_limit: z.coerce
    		.number()
    		.positive()
    		.optional()
    		.describe("New credit limit for usage"),
    	alert_threshold: z.coerce
    		.number()
    		.min(0)
    		.max(100)
    		.optional()
    		.describe("New alert threshold percentage (0-100)"),
    	rate_limit_rpm: z.coerce
    		.number()
    		.positive()
    		.optional()
    		.describe("New rate limit in requests per minute"),
    	default_config_id: z
    		.string()
    		.optional()
    		.describe("New default configuration ID"),
    	default_metadata: z
    		.record(z.string(), z.string())
    		.optional()
    		.describe("New default metadata key-value pairs"),
    	alert_emails: z
    		.array(z.string())
    		.optional()
    		.describe("New email addresses for alerts"),
    	expires_at: z
    		.string()
    		.nullable()
    		.optional()
    		.describe(
    			"New expiration date in ISO 8601 format, or null to remove expiration",
    		),
    },
  • Registration of the 'update_api_key' tool via server.tool() — the same block that registers the handler also registers the tool name and schema.
    // Phase 2: Update API key tool
    server.tool(
    	"update_api_key",
    	"Update an API key's name, description, scopes, defaults, or limits, unlike delete_api_key which revokes it or create_api_key which issues a new one. Changes take effect immediately for downstream callers, type and sub-type stay fixed after creation, and the call returns success without rotating the secret.",
    	KEYS_TOOL_SCHEMAS.updateApiKey,
    	async (params) => {
    		const result = await service.keys.updateApiKey(params.id, {
    			name: params.name,
    			description: params.description,
    			scopes: params.scopes,
    			usage_limits: buildUsageLimits({
    				credit_limit: params.credit_limit,
    				alert_threshold: params.alert_threshold,
    			}),
    			rate_limits: buildRateLimitsRpm(params.rate_limit_rpm),
    			defaults:
    				params.default_config_id !== undefined ||
    				params.default_metadata !== undefined
    					? {
    							config_id: params.default_config_id,
    							metadata: params.default_metadata,
    						}
    					: undefined,
    			alert_emails: params.alert_emails,
    			expires_at: params.expires_at,
    		});
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(
    						{
    							message: `Successfully updated API key "${params.id}"`,
    							success: result.success,
    						},
    						null,
    						2,
    					),
    				},
    			],
    		};
    	},
    );
  • TypeScript interface UpdateApiKeyRequest — defines the structured data passed to the service's updateApiKey method.
    export interface UpdateApiKeyRequest {
    	name?: string;
    	description?: string;
    	rate_limits?: ApiKeyRateLimit[];
    	usage_limits?: Partial<ApiKeyUsageLimits>;
    	scopes?: string[];
    	defaults?: ApiKeyDefaults;
    	alert_emails?: string[];
    	expires_at?: string | null;
    }
  • Service-layer method KeysService.updateApiKey — executes PUT /api-keys/{id} with the update data and returns { success: true }.
    async updateApiKey(
    	id: string,
    	data: UpdateApiKeyRequest,
    ): Promise<{ success: boolean }> {
    	await this.put(`/api-keys/${this.encodePathSegment(id)}`, data);
    	return { success: true };
    }
Behavior4/5

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

Discloses immediate effect for downstream callers, no secret rotation, and immutability of type/sub-type, adding valuable context beyond annotations. Annotations already indicate non-read-only and non-destructive, but description enriches these with specifics.

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

Conciseness5/5

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

Two efficient sentences cover purpose, differentiation, and key behavioral traits with no redundancy or unnecessary words.

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

Completeness4/5

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

Covers the main behavior and constraints for a moderately complex tool with full schema coverage and output schema present. Could mention required id or error conditions, but overall sufficient.

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

Parameters3/5

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

Schema coverage is 100%, so baseline is 3. Description mentions field categories but does not add extra parameter-specific details beyond what the schema provides.

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?

The description clearly states the tool updates an API key's attributes (name, description, scopes, defaults, or limits) and distinguishes it from delete_api_key and create_api_key, making the purpose unambiguous.

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?

Explicitly contrasts with delete and create siblings, and notes that type and sub-type stay fixed after creation, providing clear guidance on when to use this tool and what fields are immutable.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/s-b-e-n-s-o-n/portkey-admin-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server