Overview
Thegrants client manages authorization grants — the records that track which users have authorized which agents with which scopes. Grants also support delegation, where a parent agent can create a sub-grant for a child agent.
Access the grants client via client.grants.
Get
Retrieve a single grant by its ID:List
List grants with optional filters:ListGrantsParams
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | str | None | No | Filter by agent ID. |
principal_id | str | None | No | Filter by principal (user) ID. |
status | str | None | No | Filter by status ("active", "revoked", "expired"). |
page | int | None | No | Page number for pagination. |
page_size | int | None | No | Number of results per page. |
ListGrantsResponse
| Field | Type | Description |
|---|---|---|
grants | tuple[Grant, ...] | The list of grants. |
total | int | Total number of matching grants. |
page | int | Current page number. |
page_size | int | Number of grants per page. |
Revoke
Revoke a grant by its ID. This immediately invalidates the grant and any tokens issued under it:Delegate
Create a delegated sub-grant for a child agent. The sub-agent receives a subset of the parent grant’s scopes:Parameters
All parameters are keyword-only.| Parameter | Type | Required | Description |
|---|---|---|---|
parent_grant_token | str | Yes | The parent agent’s grant token (JWT). |
sub_agent_id | str | Yes | The agent ID of the sub-agent receiving the delegation. |
scopes | list[str] | Yes | Scopes to delegate (must be a subset of parent scopes). |
expires_in | str | None | No | TTL for the delegated grant (e.g. "1h", "30m"). |
Verify
Verify a grant token online against the Grantex API. The SDK uses the server-verified claims returned byPOST /v1/grants/verify — it does not decode the caller-supplied token locally, so forged or tampered tokens are always rejected by the server before any claim is surfaced. Raises GrantexTokenError if the server reports the token as inactive (revoked, expired, or unknown):
VerifiedGrant dataclass. See Offline Verification for the full field reference.
For purely offline verification without any network call to the Grantex API, use the standalone
verify_grant_token() function instead.Grant Type
TheGrant frozen dataclass has the following fields:
| Field | Type | Description |
|---|---|---|
id | str | Unique grant identifier. |
agent_id | str | The agent ID. |
agent_did | str | The agent’s DID. |
principal_id | str | The user/principal who authorized the grant. |
developer_id | str | The developer who owns the agent. |
scopes | tuple[str, ...] | The granted scopes. |
status | str | Grant status ("active", "revoked", "expired"). |
issued_at | str | ISO 8601 timestamp when the grant was issued. |
expires_at | str | ISO 8601 timestamp when the grant expires. |
revoked_at | str | None | ISO 8601 timestamp when the grant was revoked (if applicable). |