Skip to main content

Authentication

Manage your API keys. Who you are authenticated as is Users.me.

Access it as client.auth on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.

Methods​

All methods​

create_key​

create_key(*, name: str, scopes: Sequence[str], expires_in_days: int | None = None) -> ApiKeyCreateResponse

Create an API key for yourself.

The key belongs to you and your organization. Its secret is returned only in this response.

Parameters

  • name (str): The key's name, unique among your active keys (surrounding spaces are trimmed).
  • scopes (Sequence[str]): What the key may do: at least one scope, such as "apps:read" or "workflows:write", or a bundle ("read-only", "developer", "ci-cd", "ml-ops", "full-access") or "*".
  • expires_in_days (int | None, optional): Days until the key expires. The API's default is a key that never expires.

Returns

  • ApiKeyCreateResponse: The new key, with its secret in key.

Raises

  • ValidationError: scopes is empty or names an unknown scope, or name is blank.
  • ConflictError: You already have an active key with this name (error_code duplicate).

Examples

>>> created = client.auth.create_key(name="ci", scopes=["apps:read"]) >>> ci_client = Strongly(api_key=created.key, base_url="https://strongly.example.com")

list_keys​

list_keys(*, status: str | None = None, sort: str | None = None, limit: int | None = None) -> SyncPaginator[ApiKey]

List your API keys, newest first.

Parameters

  • status (str | None, optional): Only keys with this status: "active" or "revoked". The API's default is every key.
  • sort (str | None, optional): The order, as comma-separated wire field names, each prefixed with - for descending (for example "name" or "-lastUsedAt"). The API's default is "-createdAt".
  • limit (int | None, optional): The most keys to return; None returns every one.

Returns

  • SyncPaginator[ApiKey]: The keys, fetched a page at a time.

retrieve_key​

retrieve_key(key_id: str) -> ApiKey

Retrieve one of your API keys.

Parameters

  • key_id (str): The key's id.

Returns

  • ApiKey: The key's metadata.

Raises

  • NotFoundError: You have no key with this id.

revoke_key​

revoke_key(key_id: str) -> None

Revoke one of your API keys.

A revoked key stops authenticating at once. It stays listed, with the status "revoked".

Parameters

  • key_id (str): The key's id.

Raises

  • NotFoundError: You have no key with this id.
  • UnprocessableEntityError: The key is already revoked.

rotate_key​

rotate_key(key_id: str) -> ApiKeyRotateResponse

Replace one of your API keys with a new secret.

A new key is created with the old key's name, scopes and expiry, and the old key is revoked.

Parameters

  • key_id (str): The id of the key to replace.

Returns

  • ApiKeyRotateResponse: The new key (a new id), with its secret in key.

Raises

  • NotFoundError: You have no key with this id.