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 a new API key for programmatic access. Required scope: admin

Options

str | None
Human-readable key name.
list[str] | None
Permission scopes. Supported scopes are read, write, and admin. When omitted, the API defaults to ['read', 'write'].
list[str] | None
Restrict the key to specific repository IDs. Omit to allow all repositories in the organization.
int | None
Server-side TTL in seconds. The API accepts values from 100 through 31536000.

Response

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