client.tokens
client.tokens — the tokens operations.
On AsyncKindgi every method is the same, awaited.
client.tokens.list()
Section titled “client.tokens.list()”list( *, cursor: str | None = None, limit: int | None = None, principal: str | None = None, minted_with: str | UUID | None = None, timeout: float | None = None,) -> ApiTokenPageList API keys. GET /v1/tokens
Newest first. Never returns secrets. A tenant admin sees every key (?principal= for one principal's); anyone else sees their own. A key or session with limits sees only its owner's keys within them: limited to a project, the keys limited to that project; with the member role, the member keys. Those are the keys it could mint, itself among them.
client.tokens.mint()
Section titled “client.tokens.mint()”mint( body: MintTokenBody | Mapping[str, Any] | None = None, /, *, idempotency_key: str | None = None, timeout: float | None = None, **fields: Any,) -> MintTokenResultMint an API key. POST /v1/tokens
An API key acts for one principal (for: a person or a service account; default the caller), with that principal's grants. Its role is a ceiling under them and its projectId a limit. Returns the plaintext token exactly once. A person or a service account's key mints its own keys; only a tenant admin mints for someone else, or an admin key. A caller can only grant capabilities it holds, and a key limited to a project mints only keys limited to it. A key that expires mints only keys that expire no later than it, and a session opened by token sign-in mints as the key it was opened with. A key minted with a key (mintedWith: the caller's, or the one a token sign-in session was opened with) stops when that key is revoked. Only mounted when the deployment supplies a TokenAdmin.
client.tokens.get()
Section titled “client.tokens.get()”get(token_id: str | UUID, /, *, timeout: float | None = None) -> ApiTokenRead an API key. GET /v1/tokens/{tokenId}
Never returns the secret. A tenant admin reads any key; anyone else only their own (someone else's reads as missing), and a key or session with limits only those within them, as for the list.
client.tokens.revoke()
Section titled “client.tokens.revoke()”revoke( token_id: str | UUID, /, *, idempotency_key: str | None = None, timeout: float | None = None,) -> RevokeTokenResultRevoke an API key. POST /v1/tokens/{tokenId}/revoke
Takes effect on the next request. Every key minted with it, and with those in turn, is revoked with it, whoever it acts for (alsoRevoked), and their sessions end. Revoking a revoked key keeps the first time, and revokes any key minted with it that isn't revoked yet. A tenant admin revokes any key; anyone else only their own, and a key or session with limits only those within them, as for the list.
client.tokens.mint_public()
Section titled “client.tokens.mint_public()”mint_public( body: MintPublicRunTokenBody | Mapping[str, Any] | None = None, /, *, idempotency_key: str | None = None, timeout: float | None = None, **fields: Any,) -> MintPublicRunTokenResultMint a public run token. POST /v1/tokens/public
A short-lived, read-only token for up to 50 runs (and their descendants), to hand to a browser: it can only call GET /v1/runs/{runId}/progress and GET /v1/runs/{runId}/progress/stream. Stateless: it cannot be revoked one by one, so keep lifetimes short. Mounted when the deployment issues public run tokens.