Skip to content

API Keys

Sync and async API key resources: create, list, revoke scoped tokens.

APIKeysResource

Bases: BaseResource

Synchronous access to the /api-keys endpoints.

All methods raise subclasses of :class:~ineepy.exceptions.IneepyError; authentication/permission failures raise :class:~ineepy.exceptions.UnauthorizedError / :class:~ineepy.exceptions.ForbiddenError.

create(name, scopes, *, expires_at=None, save_token=True, config_file=None)

Create a new API key.

Parameters:

Name Type Description Default
name str

Human-readable name for the key.

required
scopes str | Iterable[str]

Scope name, or an iterable of scope names, to grant (e.g. editor, viewer).

required
expires_at datetime | str | None

Expiry (datetime or ISO-8601 string); defaults to 2099-12-31 server-side.

None
save_token bool

When True (default), also writes the token to ineepy.toml so a bare Ineepy()/AsyncIneepy() can be constructed later with no arguments.

True
config_file str | Path | None

Path to the TOML config file (str or Path). Defaults to ineepy.toml in the current working directory.

None

Returns:

Type Description
str

The access token string. When save_token=True it is also

str

written to ineepy.toml.

Example::

token = client.api_keys.create('ci-key', ['editor', 'viewer'])

get(jti)

Return an API key by its JWT ID.

Parameters:

Name Type Description Default
jti str

JWT ID of the API key to retrieve.

required

Returns:

Type Description
APIKeyResponse

class:~ineepy.APIKeyResponse containing the API key details.

Raises:

Type Description
NotFoundError

No API key with the given jti.

list(*, limit=None, offset=None, filters=None, order_by=None)

Return a paginated list of API keys owned by the current user.

Parameters:

Name Type Description Default
limit int | None

Maximum number of items to return.

None
offset int | None

Number of items to skip.

None
filters str | Iterable[str] | None

Filter expressions in field:operator:value format (a single string or an iterable of strings).

None
order_by str | Iterable[str] | None

Sort expressions in field:direction format (a single string or an iterable of strings).

None

Returns:

Type Description
APIKeysListResponse

class:~ineepy.APIKeysListResponse containing metadata and

APIKeysListResponse

a list of :class:~ineepy.APIKeyResponse items.

revoke(jti)

Revoke an API key permanently.

Parameters:

Name Type Description Default
jti str

JWT ID of the API key to revoke.

required

Raises:

Type Description
NotFoundError

No API key with the given jti.

AsyncAPIKeysResource

Bases: AsyncBaseResource

Async access to the /api-keys endpoints.

All methods raise subclasses of :class:~ineepy.exceptions.IneepyError; authentication/permission failures raise :class:~ineepy.exceptions.UnauthorizedError / :class:~ineepy.exceptions.ForbiddenError.

create(name, scopes, *, expires_at=None, save_token=True, config_file=None) async

Create a new API key.

See :meth:APIKeysResource.create for full documentation.

get(jti) async

Return an API key by its JWT ID.

See :meth:APIKeysResource.get for full documentation.

list(*, limit=None, offset=None, filters=None, order_by=None) async

Return a paginated list of API keys owned by the current user.

See :meth:APIKeysResource.list for full documentation.

revoke(jti) async

Revoke an API key permanently.

See :meth:APIKeysResource.revoke for full documentation.