By the end of this guide, an AI agent has its own API key, can call third-party APIs through Alter, and reaches only the credentials explicitly bound to it — not the app’s full grant store. The flow: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.
- The operator provisions a managed agent.
- The operator binds credentials to the agent (a managed-secret grant directly, or a user delegates an OAuth connection to the agent).
- The agent process loads its own API key and calls
agent.request().
Prerequisites
- An app with a
alter_key_app_…operator key. - For OAuth delegation flows: at least one provider configured and an identity provider wired.
- For managed-secret flows: at least one managed-secret provider configured.
Walkthrough
1. Provision the agent
In the developer portal: Agents → New Agent. Pick a name (research-bot), optionally set scope constraints and rate limits, click Create.
Equivalent SDK call:
2. Bind credentials to the agent
Two paths, depending on whether the credential belongs to a user or the operator. Path A — user delegates a connection. When the user runs Connect, passagent=<agent_id>:
3. Call providers from the agent
The agent process loads its own key and callsrequest() exactly as an app would:
Patterns
Listing the agent’s bound grants
grant_kind.
Self-introspection
me() works even if the agent is paused — useful for self-diagnostics. Any other call by a paused agent raises AgentInactiveError.
Trace-scoped audit identity
For multi-step workflows where each step should be attributed to a sub-agent:Agent.trace() in the Python SDK reference.
Choosing the agent process boundary
Two shapes of agent process:- Standalone — the agent runs in its own process / container / sandbox with only its agent key. Best for untrusted runtimes (user-installed MCP servers, sandboxed code).
- Embedded — the agent runs inside the main app process; the app holds the agent key alongside its app key. Best for backends where adding another key boundary buys nothing.
Troubleshooting
| Error | Likely cause | Fix |
|---|---|---|
NoDelegatedGrantError | The agent has no delegation for the requested provider. | Run a Connect session with agent=<this_agent_id> so a user can delegate, or issue a managed-secret grant to the agent. |
AgentInactiveError | The operator paused the agent. | Resume from the portal. |
AgentRevokedError | The operator hard-revoked the agent. | Provision a new agent. |
KeyRevokedError | The specific API key was revoked. | Mint a fresh key for the agent. |
InsufficientScopeError | The key’s scope set does not cover the route. | Mint a key with the required scopes, or update the agent’s allowlist. |
What’s next
Delegation
The user → agent consent model in depth.
Add human-in-the-loop approvals
Gate sensitive agent calls behind explicit user approval.
API keys
Mint, rotate, and revoke per-agent keys.