Reference
Errors
Typed exception hierarchy for the Python SDK.
Every SDK exception inherits from AlterSDKError. Branching on the typed subclasses is the supported way to handle failure modes — never parse error message strings.
Version compatibility: this page tracks the latest published SDK line.
CallerAgentMismatchError,CallerAgentResolutionError,KeyExpiredError,KeyRotationExpiredError,KeyInactiveError, andKeyAppNotFoundErrorrequirealter-sdk>=0.23.1. Version 0.22.0 does not export them; upgrade before importing or catching these classes.MemoryIsolationError, itscodeattribute and theMEMORY_ISOLATION_CODESvocabulary requirealter-sdk>=0.28.0. Version 0.27.0 and earlier do not export them.
from alter_sdk import ( AlterSDKError, AlterValueError, MemoryIsolationError, MemoryIsolationCode, MEMORY_ISOLATION_CODES, BackendError, BlockedDestinationError, ServerFeatureUnsupportedError, ReAuthRequiredError, GrantExpiredError, GrantRevokedError, GrantDeletedError, GrantNotFoundError, AgentDelegationMissingError, GrantNotDelegableError, CredentialRevokedError, AmbiguousGrantError, GrantCandidate, NoDelegatedGrantError, PolicyViolationError, StepUpRequiredError, RedactDischargeFailedError, OperationUnreviewedError, InsufficientScopeError, TokenRefreshInProgressError, QuotaExceededError, RateLimitError, ConnectFlowError, ConnectDeniedError, ConnectConfigError, ConnectTimeoutError, ProviderAPIError, ScopeReauthRequiredError, ProviderUnauthorizedError, NetworkError, TimeoutError, ApprovalError, ApprovalDeniedError, ApprovalExpiredError, ApprovalTimeoutError, ApprovalExecutionFailedError, ApprovalPayloadTooLargeError, ProviderResponseTooLargeError, WebhookSignatureError, AgentError, AgentNotFoundError, AgentNameExistsError, CallerAgentMismatchError, CallerAgentResolutionError, AgentConcurrentUpdateError, AgentInactiveError, AgentRevokedError, InvalidKeyError, KeyRevokedError, KeyExpiredError, KeyRotationExpiredError, KeyInactiveError, KeyAppNotFoundError, KeyAlreadyRevokedError, KeyNotFoundError, LastActiveKeyError, AgentKeyLimitError, MeRequiresAgentKeyError, AgentCannotMintSubagentsError, RestrictedGrantRequiresProxyError, SiblingLabelConflictError, CredentialIdRequiredError, EndUserCredentialNotAssignableError, IdempotencyKeyBodyMismatchError, IdempotencyKeyAgentRevokedError, IdempotencyKeyAgentInactiveError,)The full hierarchy and a per-error recovery playbook are documented at /reference/errors. This page is a short index of what’s exported from alter_sdk so you know what to import.
NonProxyDisabledError
Section titled “NonProxyDisabledError”No active credential-release exception covers the caller and the provider or credential, or the organization has disabled all release. The message and details identify the missing caller, grant/provider and credential type.
Use proxy execution. Only a session-authenticated organization administrator can accept the scoped risk
through the portal; see the advanced reference.
The backend code is non_proxy_disabled (HTTP 403).
Catching by category
Section titled “Catching by category”from alter_sdk import PendingApprovalfrom alter_sdk import ReAuthRequiredError, BackendError
try: resp = await app.proxy_request("GET", url, provider="provider-id") if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id)except ReAuthRequiredError: # GrantExpiredError, GrantRevokedError, CredentialRevokedError, GrantDeletedError # — user must re-authorize via Connect ...except BackendError: # Any backend-origin failure not in the re-auth bucket ...Within the re-auth bucket, the subclasses say why: GrantExpiredError — the
grant’s TTL elapsed; GrantRevokedError — the grant was explicitly revoked
(Wallet, disconnect, or an administrator), raised on every subsequent
App-side call addressing it (Agent callers and calls addressing a
delegated grant instead receive the reason-neutral GrantDeletedError, so a
delegated agent cannot probe whether its access was deliberately revoked);
CredentialRevokedError: the underlying OAuth connection is permanently
broken, or its provider issues no refresh token and the session ended
(Encompass; the audit reason is provider_session_ended); GrantDeletedError: the
grant is permanently gone with no more
specific signal (re-authorization issues a new grant id).
Common attributes
Section titled “Common attributes”Every typed error carries .message and .details: dict[str, Any]. Specific subclasses add fields:
| Exception | Extra attributes |
|---|---|
GrantRevokedError, TokenRefreshInProgressError | grant_id |
CredentialRevokedError | grant_id, provider_id, app_user_id |
GrantExpiredError | provider_id, agent_id, app_user_id — populated only on the delegation-path expiry (a TTL-lapsed delegation chain); None on the root-path TTL expiry |
GrantNotFoundError | provider_id, agent_id, app_user_id (no grant_id — the grant lookup is what failed) |
AgentDelegationMissingError | subclass of GrantNotFoundError (same provider_id / agent_id / app_user_id fields) — raised on the agent path when a grant_id isn’t reachable by this agent; delegate via Connect or resolve by provider |
GrantNotDelegableError | (subclass of BackendError) — raised by agent.delegate() when the held grant has no consenting user or is not delegable, the credential’s operator ceiling is off (a managed-secret provider’s delegation policy or the OAuth provider’s agent sharing setting), or delegable=True asks for a child that the depth ceiling leaves no further hop (HTTP 403 grant_not_delegable). detail_reason names which: no_consenting_user, holder_not_delegable, ceiling_off, no_onward_hop or not_requested (None when the backend sent none) |
ScopeReauthRequiredError | grant_id, provider_id |
AmbiguousGrantError | provider_id, account_identifiers, account_was_provided, app_user_ids, grant_ids, candidates, candidates_truncated — when candidates_truncated is True every disambiguator here is a bounded sample, so an absence from any of them proves nothing |
NoDelegatedGrantError | provider_id, agent_id, app_user_id |
PolicyViolationError | policy_error |
StepUpRequiredError | subclass of PolicyViolationError; policy_error="step_up_required" and max_session_age_seconds carries the session-freshness ceiling when supplied |
RedactDischargeFailedError | subclass of PolicyViolationError; policy_error="redact_discharge_failed" and the request was denied because required redaction could not be applied |
OperationUnreviewedError | subclass of PolicyViolationError; policy_error="operation_unreviewed". operation_id (the provider-qualified name a rule uses, such as zoom:deleteRole), method, path_template (each str or None) name the unreviewed operation a rule refused because no rule admits it by name; an organization admin names operation_id in an operation allowlist to allow it, or in a require_approval rule whose every condition names it to hold it for approval, and add a scoped credential_minting allowance naming it (details) |
RestrictedGrantRequiresProxyError | subclass of BackendError; no extra attributes. The grant is proxy-only, so request() (raw credential release) refuses it; use proxy_request(). details["error"] names why: restricted_grant_requires_proxy (the grant carries method/endpoint restrictions or an operation policy — a content rule or an operation allowlist), delegated_grant_requires_proxy (a delegated or scope-narrowed grant), hitl_grant_requires_proxy (the grant requires approval) or user_limits_require_proxy (the grant’s user set a usage limit on it — a quota, a time window or an operation rule — on an OAuth or a managed-secret grant alike). Each of these is enforceable only when the backend makes the provider call itself. A fix-your-call error: switch the call site, do not retry |
SiblingLabelConflictError | label — the sibling label already active on the credential |
CredentialIdRequiredError | credentials — a list of CredentialChoice (credential_id, label): every developer credential the provider holds. Raised by create_managed_secret_grant() when the provider holds several and credential_id was omitted (HTTP 409 credential_id_required); retry with one of them |
EndUserCredentialNotAssignableError | (subclass of BackendError) — credential_id named an end user’s own key, which has one grant (the user’s) and is never assigned (HTTP 409 end_user_credential_not_assignable) |
QuotaExceededError | retry_after — seconds until the quota window resets (prefers the Retry-After response header over the body value, so it can differ from details["retry_after"], and is capped at 2,678,400 seconds / 31 days — a quota window is a calendar period up to a month long, and the response reports the longest exhausted one); may be None. Raised on a request-quota policy denial; the SDK never auto-retries it |
RateLimitError | retry_after — seconds to wait before retrying (prefers the Retry-After response header over the body value, so it can differ from details["retry_after"], and is capped at 3,600 seconds — one hour, above the platform’s legitimate retry guidance); scope ("ip", "api_key" or "organization") — which platform ceiling was hit (a plain str, not a closed enum, so a ceiling added later stays parseable; the known values are exported as RATE_LIMIT_SCOPE_VALUES, ordered outermost-first); limit; window_seconds. scope, limit and window_seconds may each be None — not every response carrying this error code supplies them, so branch on a missing value rather than assuming one. A transient throttle, not a denial: the same request succeeds once the reported wait elapses. Also raised for a non-JSON 429 from an intermediary such as an edge provider: the limiting layer is unknown, so scope, limit and window_seconds are None, retry_after is set only from a Retry-After header, and details is {"status_code": 429} |
InsufficientScopeError | required, granted, missing, scope_version, current_scope_version, scope_version_mismatch, documentation_url (aliases: required_scopes, granted_scopes, docs_url) |
ProviderAPIError, ScopeReauthRequiredError, ProviderUnauthorizedError | status_code, response_body |
NonProxyDisabledError | details keys caller_kind, caller_id, grant_id, provider_id, managed_secret_id, credential_kind |
ScopeReauthRequiredError | raised by request() only; also missing_scopes (from WWW-Authenticate: Bearer error="insufficient_scope") |
ProviderUnauthorizedError | grant_id, provider_id — provider returned 401 (credential rejected provider-side); re-authorize an OAuth grant via a new Connect session. For a managed-secret grant, the application rotates a developer credential (Developer Portal, or alter managed-secrets credentials rotate); an end user replaces their own key through a managed-secret Connect session with repair_grant_id. A 401 whose WWW-Authenticate challenge carries error="insufficient_scope" (RFC 6750 — the credential is still valid, it just lacks a scope) surfaces as a generic ProviderAPIError instead |
ConnectTimeoutError | details["reason"] is "poll_deadline_elapsed" when the local polling deadline wins, or "session_expired" when a session observed pending expires before Alter receives a callback. With no callback, an exact provider-side error is unknowable; the provider may have retained an error page, the browser may have closed, or the user may have abandoned the flow. A user who signed in to the provider but closed Connect without confirming also ends here; when the Alter deployment holds new connections until Confirm, no connection from that session is usable |
ServerFeatureUnsupportedError | subclass of BackendError; no extra attributes. The Alter backend predates a feature the call used, so the SDK raises instead of returning a session that would not do what was asked. On create_managed_secret_connect_session() (App and Agent), details["feature"] names what is missing: managed_secret_connect_provider — the backend still requires template_slug when only provider was sent, refuses a parameter it does not know (provider, agent, requested_grant, grant_policy, direct, repair_grant_id), answered a session without the path a current backend always reports (it ignored those parameters), or still requires an agent on a session that names none for an app key; agent_managed_secret_connect_session — a session naming no agent (the Agent method on an agent’s own key, or the application’s own use of the user’s key) against a backend that still requires delegated_agent_id; managed_secret_connect_delegable — delegable=True when the backend did not echo delegable_requested, or echoed it as False. details["status_code"] carries the HTTP status. Retrying against the same backend cannot help: upgrade the backend, or until then request the session with an app key and an agent — app.get_agent(agent_id).create_managed_secret_connect_session(template_slug=...) or the App method with template_slug and delegated_agent_id — without delegable |
ConnectConfigError | details["error"] names the cause (for example managed_oauth_scope_approval_required). create_managed_secret_connect_session() also raises it when the session cannot be created until an administrator or the application changes something (retrying does not help): secret_not_found (HTTP 404 — no active provider of the application has the provider slug); secret_template_mismatch (HTTP 422 — provider was not created from template_slug); idp_signin_not_configured (HTTP 409, details["retryable"] is False — the application’s identity provider cannot sign users in to approve; details["details"]["reason"] says what to change: missing_client_id or missing_client_secret — add the sign-in client ID and secret to the identity provider; issuer_cannot_sign_in — use an issuer that supports OpenID Connect sign-in, for WorkOS the AuthKit issuer https://<slug>.authkit.app); binding_hosts_required (HTTP 409 — the user would enter a key, but the provider derives its hosts from the key and has no host patterns set: an administrator sets them); provider_contract_repair_required (HTTP 409 — the provider’s stored contract is out of date: an administrator rotates its existing developer credential once before a key can be entered); no_eligible_grants (HTTP 409 — no path can succeed: on a key entry with an agent, that agent could never be delegated the key, details["details"]["reason"] agent_not_allowlisted or delegation_depth_exceeded; or a template_slug-only request whose template names no single provider found no grant the user holds, reason no_grant, grant_expired, delegation_depth_exceeded, group_source_not_allowed or agent_not_allowlisted — see the reasons). binding_hosts_required, provider_contract_repair_required and no_eligible_grants reach only a key bound to no managed agent: an app key, including an Agent from App.get_agent(), or an agent-typed alter_ak_… key minted under API Keys. A managed agent’s own key never receives them; the hosted page tells the user instead. create_connect_session with agent, or on an agent’s own key with a user token (Agent.create_connect_session(), and connect(), which creates the session first), raises it with details["error"] == "agent_allowlist_exceeded" (HTTP 422) when the delegated agent’s capability allowlist cannot use what the user would grant, before the user is sent to the provider: details["details"]["detail_reason"] is provider_not_allowlisted, scopes_not_allowlisted or grant_scopes_malformed, details["details"]["provider_id"] names the provider and details["details"]["uncovered_providers"] every provider refused. poll_connect_session, and connect() once the session exists, raise it with details["error_code"] == "agent_allowlist_exceeded" when the allowlist was narrowed before the user finished, with the same details["details"] (detail_reason, provider_id, uncovered_providers). An administrator widens the agent’s allowlist, or the application narrows the scopes it requests or passes a covering scope_constraint, before a new session. delegate() raises BackendError for the same code (details) |
ApprovalError (and subclasses) | approval_id |
ProviderResponseTooLargeError | status_code (the provider’s status), headers (the provider’s headers), limit_bytes (the buffered limit when the response passed it; None when an approval’s result was too large to store), approval_id (set when raised reading an executed approval’s result) |
ApprovalPayloadTooLargeError | limit_chars — the largest request this deployment can hold for approval |
WebhookSignatureError | subclass of AlterSDKError; no extra attributes. Raised by verify_webhook() for a delivery to reject — see below |
AgentError (and subclasses) | code, hint |
CredentialChoice is a supporting dataclass, not an exception: each item in CredentialIdRequiredError.credentials has credential_id (what create_managed_secret_grant(credential_id=...) takes) and label.
GrantCandidate is a supporting dataclass, not an exception. Each item in AmbiguousGrantError.candidates has grant_id, label, account_identifier, and account_display_name; retry with the chosen grant_id, or with provider + label when a stable sibling address is preferable.
Recovery patterns
Section titled “Recovery patterns”Identity-mode ambiguity — choose deliberately, never the first candidate:
from alter_sdk import PendingApprovalfrom alter_sdk import AmbiguousGrantErrortry: resp = await app.proxy_request("GET", url, provider="provider-id", user_token=user_jwt) if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id)except AmbiguousGrantError as e: # e.candidates: grant_id, label, account_identifier, account_display_name. # Let the user pick (or apply the account already saved on their profile), # persist the grant_id, and call by it with the user's JWT. grant_id = choose_grant(e.candidates) resp = await app.proxy_request("GET", url, grant_id=grant_id, user_token=user_jwt) if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id)Missing or broken credential — mint a recovery Connect session:
from alter_sdk import PendingApprovalfrom alter_sdk import NoDelegatedGrantError, CredentialRevokedError
try: resp = await agent.proxy_request("GET", url, provider="provider-id") if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await agent.await_approval(resp.approval_id)except (NoDelegatedGrantError, CredentialRevokedError) as e: session = await agent.create_connect_session_for_error(e) redirect_to(session.connect_url) results = await agent.poll_connect_session(session.session_token)Transient refresh conflict — exponential backoff:
from alter_sdk import PendingApprovalimport asynciofrom alter_sdk import TokenRefreshInProgressError
for attempt in range(3): try: resp = await app.proxy_request(...) if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id) break except TokenRefreshInProgressError: await asyncio.sleep(1 * (2 ** attempt))Quota window exhausted — wait for the window to reset:
from alter_sdk import PendingApprovalimport asynciofrom alter_sdk import QuotaExceededError
try: resp = await app.proxy_request(...) if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id)except QuotaExceededError as e: # A request-quota policy denial — the SDK never auto-retries it. await asyncio.sleep(e.retry_after if e.retry_after is not None else 60) resp = await app.proxy_request(...) if isinstance(resp, PendingApproval): for gate in resp.gates: print("Approval required:", gate.approval_url) resp = await app.await_approval(resp.approval_id)Insufficient scope — str(e) names the missing scopes and then says how to fix it: rotate the key with the scope added, load the new key, and restart the process (the client keeps the key it was created with, so a running process keeps failing until it is restarted), or, when the key already holds the scope, send the request without the scope constraint that narrowed it away. At a version mismatch, rotate the key:
from alter_sdk import InsufficientScopeError
try: await app.agents.create( name="bot", scopes={"provider-id": ["resource:read"]}, )except InsufficientScopeError as e: if e.scope_version_mismatch: print(f"Key minted at v{e.scope_version}; server at v{e.current_scope_version}. Rotate.") else: print(f"Missing: {e.missing}. See {e.docs_url}")See /reference/errors for the full hierarchy with descriptions and recovery guidance for every error.
Destination refusal
Section titled “Destination refusal”Version compatibility:
BlockedDestinationError, andRateLimitErrorfor a non-JSON 429, requirealter-sdk>=0.28.0. Version 0.27.0 and earlier raise a genericBackendErrorfor both responses.
BlockedDestinationError inherits from BackendError. The requested destination
failed the provider’s host/path allowlist or the network security check, or is
a route the provider’s reference page lists as refused on every connection. When
a call held for approval is refused as the approved call executes, the approval
wait raises ApprovalExecutionFailedError instead. Correct the URL before
retrying. Its details includes error: "blocked_destination", status_code,
and request_id when the server supplied one; use the request ID
when investigating the refusal. Private resolver addresses and credentials are
not part of the diagnostic contract.
ManagedOperationError
Section titled “ManagedOperationError”A managed integration rejected by the backend raises ManagedOperationError with
its stable code and HTTP status. Examples include unknown_contract_version,
integration_grant_mismatch and invalid operation arguments. A provider whose connections each use their own API host (a data center or a company host) refuses a connection with no such host as connection_origin_missing and one outside the hosts it allows as connection_origin_not_allowed (both 409); reconnecting, or saving the key with an allowed host, fixes them. Provider HTTP failures
and successful HTTP responses flagged provider_fault are represented by the retained
approval result and rejected by typed result decoding; they are not successful writes.
reason is an optional, machine-readable refinement of code (None when the backend sends none), also kept in details["reason"]. An attachment sent without its metadata (a bare file object for an operation whose file goes in a multipart attachment body) is code invalid_operation_input with reason attachment_metadata_required: send the file with its metadata (integrations.execute_upload(..., metadata=...)). Branch on code first; reason only narrows it.
ProviderResponseTooLargeError
Section titled “ProviderResponseTooLargeError”Extends BackendError. The provider answered, but its response is larger than the
5 MiB a buffered call returns. proxy_request() raises it instead of returning a cut
body, and so does reading an executed approval’s result (await_approval() and the
other result readers) when the result was kept without its body. status_code and
headers are the provider’s. The call was made, so a write may have happened: do not
resend a non-idempotent call to recover. Fetch a large response with
proxy_stream_request(),
which returns any size. A managed operation (integrations.execute(), or reading its
typed result) raises it the same way. Its message names
integrations.execute_stream() for a
binary response (it refuses a JSON operation) and proxy_stream_request() for any other.
ApprovalPayloadTooLargeError
Section titled “ApprovalPayloadTooLargeError”Extends BackendError (HTTP 413, approval_payload_too_large). The call needs
approval, and its request is too large to hold for approval on this deployment.
Nothing was held or sent. limit_chars is the largest request the deployment can
hold. Send a smaller request, or send a file with
proxy_upload_request(),
whose bytes are delivered after the approval instead of held.
ProxyTransferError
Section titled “ProxyTransferError”Extends BackendError. The streaming/binary proxy refused the call. code identifies
proxy_body_uninspectable (422, a rule or an approval needs to read the body; on GraphQL, any operation, family or parameter rule does),
proxy_stream_capacity (503, dedicated stream slots full),
proxy_stream_timeout (504, deadline before response headers), or
proxy_stream_approval_required (409, approval-gated streaming is unavailable).
Uploads from proxy_upload_request() add the proxy_upload_* and
proxy_approved_upload_too_large codes listed in the
error reference.
After response headers, transport failures interrupt iteration as NetworkError
or TimeoutError; never treat a partial stream as a complete provider response.
WebhookSignatureError
Section titled “WebhookSignatureError”Extends AlterSDKError. verify_webhook()
refused a delivery: a missing webhook-id, webhook-timestamp or webhook-signature
header, a timestamp outside the tolerance window (a replay), a signature no active
secret produced, or a body that is not the event envelope. The request reached the
receiver; it just was not from Alter — respond 400 and do not act on it. A malformed
secret argument is the receiver’s own configuration error and raises AlterValueError
instead.