Skip to main content
Create an API key. The secret key value is returned only once; store it immediately. Required scope: admin
const key = await mesa.apiKeys.create({
  name: 'agent-runner',
  scopes: ['read', 'write'],
  repo_ids: ['repo_123'],
  expires_in_seconds: 3600,
});

console.log(key.key);

Options

org
string | undefined
Organization override.
name
string | undefined
Human-readable key name.
scopes
Array<'read' | 'write' | 'admin'> | undefined
Scopes granted to the key.
repo_ids
string[] | undefined
Restrict the key to specific repository IDs. Omit for organization-wide access.
expires_in_seconds
number | undefined
Expiration between 100 seconds and 31536000 seconds.
tags
Record<string, string> | undefined
String key-value metadata.

Response

id
string
API key ID.
key
string
Plaintext API key. Store it immediately; it is shown only once.
name
string | null
API key name, or null when unnamed.
scopes
string[]
Scopes granted to this key.
repo_ids
string[] | null
Repository allowlist, or null when the key is not repo-scoped.
tags
Record<string, string>
User-defined API key tags.
created_at
string
Creation time.