Skip to main content
API keys are deprecated. The SDK can manage them for CLI and direct backend integrations, but cannot use them as its own client credential. New integrations should use private keys instead.
Create an API key. The secret key value is returned only once; store it immediately. Required scope: admin

Options

string | undefined
Organization override.
string | undefined
Human-readable key name.
Array<'read' | 'write' | 'admin'> | undefined
Scopes granted to the key.
string[] | undefined
Restrict the key to specific repository IDs. Omit for organization-wide access.
number | undefined
Expiration between 100 seconds and 31536000 seconds.
Record<string, string> | undefined
String key-value metadata. Keys cannot start with $ (reserved for tag filter operators).

Response

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