Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.alterauth.com/llms.txt

Use this file to discover all available pages before exploring further.

from alter_sdk import App, Agent

App

The operator/admin client. Constructed with an app key (alter_key_app_…).

Signature

App(
    api_key: str,
    *,
    timeout: float = 30.0,
    caller: str | None = None,
    caller_type: CallerType | str = CallerType.SERVICE,
    user_token_getter: Callable[[], str | Awaitable[str]] | None = None,
)

Parameters

NameTypeDefaultDescription
api_keystrrequiredApp API key.
timeoutfloat30.0HTTP request timeout in seconds.
callerstr | NoneNoneAudit attribution label. Free-form string or a managed-agent UUID. See Concepts → Caller.
caller_typeCallerTypeSERVICESERVICE (default) or AGENT (shows in dev-portal Agents tab).
user_token_gettercallable | NoneNoneSync or async callable returning a JWT for identity resolution.

Properties

PropertyTypeNotes
actor_idstr | NoneCached actor UUID.
agentsAgentsNamespaceSee Agents reference.
base_urlstrResolved Alter Vault endpoint. Diagnostic only.
last_retry_infoRetryInfo | NoneRetry metadata from the most recent request().

Example

from alter_sdk import App

vault = App(
    api_key="alter_key_app_...",
    caller="email-research-bot",
    user_token_getter=lambda: get_jwt(),
)

Agent

The workload client. Constructed with an agent key (alter_key_agent_…).

Signature

Agent(
    api_key: str,
    *,
    timeout: float = 30.0,
    caller: str | None = None,
    user_token_getter: Callable[[], str | Awaitable[str]] | None = None,
)

Parameters

Same as App, except caller_type is implicit (always AGENT). user_token_getter is allowed but per-call combination of an agent key with a user_token returns HTTP 400 — see Agents → Overview.

Example

from alter_sdk import Agent

vault = Agent(api_key="alter_key_agent_...")
me = await vault.me()
print(me.id, me.name)

Lifecycle

Both classes are async-safe. Always call close() to release the underlying HTTP pool, or use the async context manager:
async with App(api_key=KEY) as vault:
    response = await vault.request("GET", url, grant_id=g)
# automatically closed

See also