Reference
Errors
Error contracts and recovery across the SDKs, Connect, and CLI.
The Python and TypeScript server SDK error hierarchy is organized by developer action — the action to take is the first thing to know when an exception is caught. Both SDKs expose the same exception class names; the snippets below are Python but the TypeScript hierarchy is identical (camelCase fields). The Python export index and TypeScript export index cover language-specific imports and field spelling.
The reference tracks the latest published SDK line. The caller-agent and
API-key lifecycle classes (CallerAgentMismatchError,
CallerAgentResolutionError, KeyExpiredError, KeyRotationExpiredError,
KeyInactiveError, and KeyAppNotFoundError) require Python
alter-sdk>=0.23.1 and TypeScript @alter-ai/alter-sdk>=0.23.1; 0.22.0 does
not export them. AmbiguousGrantError.candidates_truncated /
.candidatesTruncated is newer still and is not present on the 0.24.2 line —
on an SDK without it the attribute reads as absent, which client code should
treat as “not reported”, never as “the list is complete”. The private-memory
API (MemoryIsolationError and its code, ScopedMemoryStore, and the
assertion verifier) requires SDK 0.28.0 or newer;
version 0.27.0 and earlier do not export it. See the language-specific export indexes
for the exact names and upgrade commands.
AlterSDKError├── AlterValueError — SDK rejected caller input; fix the code├── MemoryIsolationError — private-memory identity/partition not verified; branch on code├── BackendError — Alter backend returned an error│ ├── ServerFeatureUnsupportedError — the backend predates a feature this call used│ ├── BlockedDestinationError — destination failed the host/path allowlist or network security check│ ├── ReAuthRequiredError — user must re-authorize via Connect│ │ ├── GrantExpiredError│ │ ├── GrantRevokedError│ │ ├── CredentialRevokedError│ │ └── GrantDeletedError│ ├── GrantNotFoundError — wrong grant_id; fix the code│ │ └── AgentDelegationMissingError — agent path: grant not delegated to this agent│ ├── AmbiguousGrantError — multiple grants matched; pick one│ ├── PolicyViolationError — policy denied; may resolve later│ │ ├── StepUpRequiredError — user session is too old; re-authenticate│ │ ├── RedactDischargeFailedError — required redaction failed; fix body/rule│ │ └── OperationUnreviewedError — unreviewed operation; name it in a rule│ ├── InsufficientScopeError — key scopes don't cover the route│ ├── NoDelegatedGrantError — agent has no access path to the provider│ ├── NonProxyDisabledError — credential release refused; use the proxy or add an exception│ ├── RestrictedGrantRequiresProxyError — restricted grant; use the proxy call path│ ├── GrantNotDelegableError — onward delegation is not permitted│ ├── SiblingLabelConflictError — label already in use on this connection│ ├── DelegationLabelTakenError — another agent's delegation to this agent already uses the label│ ├── GrantTagsChangedError — the grant's tags changed since they were read; read and retry│ ├── CredentialIdRequiredError — provider holds several developer keys; name one with credential_id│ ├── EndUserCredentialNotAssignableError — that key is an end user's own; it has one grant│ ├── TokenRefreshInProgressError — transient 409; retry│ ├── QuotaExceededError — request-quota window exhausted; wait retry_after│ ├── RateLimitError — rate limit, Alter's or an intermediary's (non-JSON 429); scope may be unset│ └── AgentError — managed-agent management│ ├── InvalidKeyError│ ├── AgentNotFoundError│ ├── AgentNameExistsError│ ├── AgentConcurrentUpdateError│ ├── MeRequiresAgentKeyError│ ├── KeyRevokedError│ ├── AgentInactiveError│ ├── AgentRevokedError│ ├── KeyNotFoundError│ ├── KeyAlreadyRevokedError│ ├── LastActiveKeyError│ ├── AgentKeyLimitError│ ├── AgentCannotMintSubagentsError│ ├── IdempotencyKeyBodyMismatchError│ ├── IdempotencyKeyAgentRevokedError│ └── IdempotencyKeyAgentInactiveError├── ConnectFlowError — Connect flow failed│ ├── ConnectDeniedError — user clicked Deny│ ├── ConnectConfigError — OAuth app or IDP sign-in misconfigured│ └── ConnectTimeoutError — no callback before deadline/expiry├── ProviderAPIError — provider returned 4xx/5xx│ ├── ScopeReauthRequiredError — 403 + scope mismatch; re-authorize│ └── ProviderUnauthorizedError — 401; token rejected provider-side; re-authorize├── ApprovalError — HITL approval branch│ ├── ApprovalDeniedError│ ├── ApprovalExpiredError│ ├── ApprovalTimeoutError│ └── ApprovalExecutionFailedError└── NetworkError └── TimeoutError — request timed outCatching by action
Section titled “Catching by action”The hierarchy is built so that catching a parent class handles every leaf that requires the same response.
- “The user needs to re-authorize.” Catch
ReAuthRequiredError. Triggers: revoked grant, expired grant, broken credential, deleted grant, or a provider session that ended (provider_session_ended: the provider issues no refresh token, as on Encompass, and the token’s session expired or lapsed unused). An ended session is still a 403credential_revokedon the wire, so the SDKs raiseCredentialRevokedError; its message says the provider session ended and the provider issues no refresh token, and the audit row’s reason isprovider_session_ended. Response: show the Connect widget. - “The user needs to re-authorize with a wider scope.” With
request(), catchScopeReauthRequiredError(subclass ofProviderAPIError); withproxy_request(), checkstatus_codeandcredential_hint. Trigger: the provider returned 403 and the grant’s stored scopes don’t cover the route. Response: show the Connect widget; the new authorization upgrades the grant in place. - “The provider rejected the credential.” Catch
ProviderUnauthorizedError(subclass ofProviderAPIError). Trigger: the provider returned 401 on arequest()call: the credential was revoked, expired, or otherwise invalidated provider-side. One exception: a 401 whoseWWW-Authenticatechallenge carrieserror="insufficient_scope"(RFC 6750) means the credential is still valid but lacks a scope, so it surfaces as a genericProviderAPIErrorinstead. Response: for an OAuth grant, show the Connect widget (a new Connect session re-authorizes the grant); for a managed-secret grant, update the stored secret with a valid value. For a managed secret whose template exchanges a stored client credential for a short-lived token, Alter discards the refused token when the SDK’s background report of the 401 reaches it, so retry the call once first, after a short delay: that retry gets a fresh token, while an immediate retry can still be served the refused one. If the fresh token is refused too, check the client’s access to that resource at the provider. - “The agent has no access to this provider.” Catch
NoDelegatedGrantError. Trigger: an agent calledrequest(provider=...)and no delegation or agent-owned managed-secret grant resolved. Response: prompt a user to delegate, or issue a managed-secret grant to the agent. - “The agent passed a grant_id it can’t reach.” Catch
AgentDelegationMissingError(a subclass ofGrantNotFoundError, so an existingGrantNotFoundErrorcatch still fires). Trigger: an agent calledrequest(grant_id=...)/proxy_request(grant_id=...)and the grant is not delegated to this agent — or a user/basegrant_idwas passed where the agent’s own delegation id (fromlist_grants) was required. Response: delegate the agent via Connect, or resolve by provider (omitgrant_id) to route through the agent’s existing delegations. - “The user session is too old for this operation.” Catch
StepUpRequiredError. Trigger: acontent_matchstep-up obligation requires a fresher identity session. Response: re-authenticate the user, obtain a fresh user session, and retry. - “A rule refused an operation Alter has not reviewed.” Catch
OperationUnreviewedError. Trigger: the call is an unreviewed operation of the provider’s published API, and an operation, family or content rule that does not name it applies. Response: do not retry unchanged. Have an organization admin nameoperation_id(the provider-qualified name, such aszoom:deleteRole) in an operation allowlist to allow it, or in arequire_approvalrule whose every condition names it to hold it for approval, and add a scopedcredential_mintingallowance naming it (details). - “Required request redaction could not be applied.” Catch
RedactDischargeFailedError. The provider request was denied before forwarding. Response: fix the request body shape or the rule’sredact.fields; retry only after the mismatch is corrected. - “This grant cannot be delegated onward.” Catch
GrantNotDelegableError. Response: when a managed-secretdelegatecall passeddelegableasTrue/trueand the message says the new child has no further hop, the held grant is already delegable, so call again withdelegableomitted orFalse/false(details). Otherwise, establish a grant with onward delegation enabled at the source; for a managed-secret provider, the operator must also permit re-delegation. - “The calling key lacks a required scope.” Catch
InsufficientScopeError. Response: rotate a version-stale key whenscope_version_mismatchis true; otherwise checkrequired_any_of— when true, any ONE scope inmissingsatisfies the route (for example the approval status poll acceptsapprovals:readorproxy:execute), so add a single one rather than all of them; when false, use a key whose explicit scopes include every entry inmissing. - “A transient backend condition.” Catch
TokenRefreshInProgressError. Trigger: a parallel refresh holds the lock. Response: retry with backoff. - “The quota window is exhausted.” Catch
QuotaExceededError. Trigger: a request-quota policy denied the call — the fixed window’s limit is spent. Response: waitretry_afterseconds (the time until the window resets), then retry. The SDKs never auto-retry this error — retrying before the window resets is denied again. - “You are sending requests too fast.” Catch
RateLimitError. Trigger: the platform rate limit for the API key (or the organization-wide aggregate, when one is configured) is exhausted — a transient throttle, not a denial. Also raised for a non-JSON 429 from an intermediary such as an edge provider; then the limiting layer is unknown,scopeis unset andretry_afteris set only when the response carried aRetry-Afterheader. Response: waitretry_afterseconds when set (otherwise bounded exponential backoff with jitter) and retry the same request;scope, when set, says which ceiling was hit (api_key— slow this key down or spread load across keys;organization— every key shares one budget, so slowing one caller may not be enough). Distinct fromQuotaExceededError(a policy denial — retrying inside the window is denied again) and from a billing-period cap, which stays a genericBackendError. - “The requested permissions need Alter’s approval.” Catch
ConnectConfigErrorand check the error code formanaged_oauth_scope_approval_required(details["error"]/details.erroron a create-session failure,details["error_code"]/details.error_codeon a Connect poll failure). Trigger: the scopes the app requests exceed what Alter’s managed OAuth client is approved for. Response: never retry — the response isretryable: falseand every fresh Connect session fails identically until the approval changes. Contact Alter to have the scopes approved, or narrow the app’s configured scopes to the approved set, and only then create a fresh session. When the approval names scopes the provider has since folded into a broader one,details["details"]["retired_approved_scopes"]/details.details.retired_approved_scopeslists them: an approval of a retired scope never carries over to its broader replacement, so the replacement needs approving. - “The application must re-select this provider’s scopes.” Catch
ConnectConfigError. The error’sdetailscarry the codeconnect_scope_revoked(details["error"]/details.erroron a create-session failure,details["error_code"]/details.error_codeon a Connect poll failure) with the reasonretired_selection_requires_reselection(details["details"]["reason"]/details.details.reasonon a create-session failure, HTTP 409;details["error_reason"]/details.error_reasonon a Connect poll failure). Aconnect_scope_revokedwithout that reason is a scope revoked during the session and keeps its existing error. Trigger: the application’s saved scope selection for the provider names only scopes the provider has folded into a broader one (for example, Sentry’s retired dashboard scopes), so Connect fails closed rather than widening the selection or falling back to the defaults. On the create-session 409 only,details["details"]["retired_scopes"]/details.details.retired_scopeslists the retired scopes,details["details"]["broader_successors"]/details.details.broader_successorsnames the broader scopes to re-select, anddetails["remediation"]["action"]/details.remediation.actionisreselect_provider_scopes; a Connect poll failure carries only the code and the reason. The session is still created (a user already connected to the provider keeps the reuse path), and the refusal arrives on the poll once a new authorization for that provider starts. A reconnect or switch-account session can only start a new authorization, so it is refused at create (HTTP 409) when it names the provider in its allowed providers (a reconnect always does); one that names no provider is refused only when no other provider can start a new authorization, and otherwise leaves that provider out. When several named providers need re-selecting,details["details"]["also_denied_providers"]/details.details.also_denied_providerslists the others. Response: never retry — an application administrator re-selects the provider’s scopes in the Developer Portal, or withalter providers update --app <app> --provider <provider-id> --scopes <list>(alter policy show-accessnames each provider that needs it in itsNOTEScolumn); every new authorization for it fails the same way until then. The same refusal withdetails["details"]["pinned"]/details.details.pinnedset to true and the remediation actioncreate_new_sessionmeans the session’s own required scopes pin a retired scope for the provider, alone or beside live ones: create a new session that pins the scopes inbroader_successorsinstead. - “The provider refused the account that approved the connection.” Catch
ConnectFlowErrorand checkdetails["error_code"]/details.error_codeon a Connect poll failure forprovider_access_forbidden. Trigger: the provider definitively refused the new connection access to read the connected account, so nothing was stored. For Rippling this is a 403 at install: the person who approved the connection lacks permission to install apps, or the Rippling listing does not includecompanies.read. Response: do not retry unchanged — have an administrator who can install apps connect, or add the missing permission to the provider app, then create a new Connect session. - “The provider rejected the application’s OAuth client.” Catch
ConnectConfigErrorand checkdetails["error_code"]/details.error_codeon a Connect poll failure forinvalid_clientorunauthorized_client. Trigger: the user approved access, then the provider refused the client ID and secret saved for the application (invalid_client), or refused that client this kind of authorization (unauthorized_client), so nothing was stored. Common causes are a mistyped or regenerated client secret, and credentials from a production app saved for a sandbox environment, or the reverse. Response: do not retry unchanged. Update the provider’s client ID and secret (and, for a sandbox, use the app created in the provider’s sandbox), then create a new Connect session. - “The identity provider cannot sign users in to approve a delegation.” Catch
ConnectConfigErrorand checkdetails["error"]/details.errorforidp_signin_not_configured(HTTP 409). Trigger:create_managed_secret_connect_session()/createManagedSecretConnectSession()— the user approves a managed-secret delegation only after signing in through the application’s identity provider, and that provider has no usable sign-in client. The reason is atdetails["details"]["reason"]/details.details.reason:missing_client_idormissing_client_secret— add the sign-in client ID and secret to the identity provider;issuer_cannot_sign_in— the issuer validates tokens but cannot sign users in, so use an issuer that supports OpenID Connect sign-in (for WorkOS, the AuthKit issuerhttps://<slug>.authkit.app). Response: never retry — the response isretryable: falseand every new session fails the same way until an administrator changes the identity provider. OAuth Connect sessions never raise it: when the identity provider cannot sign users in, an OAuth delegation goes through the provider’s own authorization instead. The hosted page’s own sign-in can also reportno_idp_configured, but never to an SDK: creating a session already requires an identity provider to verify the user’s token. - “This delegation can never be approved.” Catch
ConnectConfigErrorand checkdetails["error"]/details.errorforno_eligible_grants(HTTP 409). Trigger:create_managed_secret_connect_session()/createManagedSecretConnectSession()with a key bound to no managed agent (an app key, or an agent-typedalter_ak_…key from API Keys), when nothing the user could approve would reach the agent: the agent’s allowlist or the provider’s delegation policy refuses the delegation of a key the user would store, or a deprecatedtemplate_slug-only request names no single provider and the user holds no grant it could use.details["details"]["reason"]/details.details.reasonnames the cause (see Delegation request codes). Response: fix that cause, then create a new session; retrying unchanged gets the same answer. A managed agent’s own key never receives it: its session is created and the page explains. - “The provider cannot take a user’s key yet.” Catch
ConnectConfigErrorand checkdetails["error"]/details.errorforbinding_hosts_requiredorprovider_contract_repair_required(HTTP 409). Trigger: a managed-secret Connect session that would ask the user for their own key (the user holds no grant on the provider yet), when the provider takes its API host from the key and no binding host patterns are set, or when the provider’s stored contract needs an administrator’s repair. Response: never retry unchanged — an administrator sets the provider’s binding host patterns (alter managed-secrets set-end-user-key-setup --binding-host, or the dashboard’s End-user key setup card), or rotates its existing developer credential once, then create a new session. A managed agent’s own key never receives either at session creation; the page tells the user instead. - “No such managed-secret provider.” Catch
ConnectConfigErrorand checkdetails["error"]/details.errorforsecret_not_found(HTTP 404) orsecret_template_mismatch(HTTP 422). Trigger:providernames no active managed-secret provider of the app (a missing slug, another app’s, and a disabled one answer alike), or the deprecatedtemplate_slugsent beside it is not that provider’s template. Response: pass the provider’s slug (theslugfield ofalter managed-secrets list --output json), not its template id. - “The agent cannot use what this delegation would hand it.” Catch
ConnectConfigErrorand check the error code foragent_allowlist_exceeded(HTTP 422):details["error"]/details.erroron a create-session failure,details["error_code"]/details.error_codeon a Connect poll failure. Trigger:create_connect_session()/createConnectSession()withagent, or on an agent’s own key with a user token (agent.create_connect_session()/agent.createConnectSession(), andconnect(), which creates the session first), when the delegated agent’s capability allowlist does not cover what the user would grant — refused before the user is sent to the provider, with the code atdetails["error"]/details.error— or, on polling, when the allowlist was narrowed before the user finished. While a narrowing of the agent’s allowlist is pending, the check uses the narrowed allowlist, and the message names when the narrowing applies.delegate()raisesBackendErrorfor the same code. Nothing was delegated. The check is atdetails["details"]["detail_reason"]/details.details.detail_reasonon session creation,delegate()and a poll failure (details). Response: do not retry unchanged — an administrator widens the agent’s allowlist, or the application narrows the scopes it requests from the provider or passes ascope_constraintthe allowlist covers; then create a new session. If the allowlist was saved before the provider folded some of its scopes into a broader one (for example Sentry’s retired dashboard scopes), it still names the retired scopes, which no connection holds: allowlist the broader scope instead.alter policy show-accessnames each such allowlist on stderr, and lists the broader scopes in the agent provider entry’sallowlist_folded_intofield. - “The Alter backend is older than this SDK feature.” Catch
ServerFeatureUnsupportedError(aBackendErrorsubclass). Trigger:Agent.create_managed_secret_connect_session()/agent.createManagedSecretConnectSession(), or, on a managed-secret session,provider, a session that names no agent, oragent,requested_grant,grant_policy,direct,repair_grant_idordelegable, against a backend that predates them. Alsotagsonlist_grants()/listGrants(),agents.list(),mint_grant()/mintGrant(),agents.create(),agents.update()orcreate_connect_session()/createConnectSession(), andlabel,tagsorrulesondelegate(), against a backend that predates them: an unfiltered list or a session is not returned; a grant or agent written without its tags carries its id in the error’s details; and a delegation made without its rules is revoked first (details["revoked"]/details.revoked; when false, revoke it yourself), while one that only lost its tags or label is kept (details["revoked"]/details.revokedis false,details["grant_id"]/details.grant_idnames it): it holds no less than the held grant allows, so revoke it yourself if the name or tags were essential. Response: upgrade the backend, or call without the new option (withtemplate_sluganddelegated_agent_idin place ofproviderandagent) until it supports it; retrying cannot help. - “A network problem.” Catch
NetworkError. Trigger: connection failure, DNS, timeout. Response: retry with backoff (catchTimeoutErrorseparately if a different retry profile is needed for timeouts vs connection refused).
Selected exception details
Section titled “Selected exception details”ProxyTransferError
Section titled “ProxyTransferError”A subclass of BackendError, raised when a binary proxy call, a streaming response or an upload is refused before any provider response, or an upload fails while it is sent. Read code:
code | Status | Recovery |
|---|---|---|
proxy_body_uninspectable | 422 | A policy rule or an approval needs to read the body (on GraphQL, any operation, family or parameter rule does; with no such rule a binary GraphQL body is scanned for credentials instead, see credential_minting_refused). An upload to a GraphQL endpoint is always refused here, because its bytes are not read before they are sent. Send a bounded JSON body, or change the rule. A UTF-8 form body (application/x-www-form-urlencoded) is read only on an operation whose provider documents a form-encoded body, and a text body only on an operation that documents one (Fail-closed); a form label on an operation whose provider reads JSON is refused here. A request whose operation an operation allowlist cannot name gets the allowlist’s 403 operation_unclassified instead. For a call that needs approval, send the bytes as an upload. |
proxy_stream_capacity | 503 | Wait details.retry_after_seconds, then retry with bounded backoff. |
proxy_stream_timeout | 504 | The deadline passed before response headers. Retry only an idempotent call. |
proxy_stream_approval_required | 409 | Use proxy_request() / proxyRequest(), which returns a pending approval. A binary body cannot be held inline: send it with proxy_upload_request() / proxyUploadRequest(). |
operation_not_streamable | 422 | integrations.execute_stream() / integrations.executeStream() serves an operation whose response is a file. One that returns a JSON document is refused: call integrations.execute(). |
operation_not_uploadable | 422 | integrations.execute_upload() / integrations.executeUpload() serves an operation whose body is one file. Send any other operation with integrations.execute(). |
proxy_upload_size_mismatch / proxy_upload_hash_mismatch | 422 | The bytes differ from the declaration. Send the declared bytes with a new ticket. |
proxy_upload_boundary_in_body | 422 | The file contains the multipart boundary of the envelope Alter builds around it (an operation whose file is sent inside a multipart body), so it was refused before that part of the file was sent and the provider never received a complete body. The boundary is derived from the operation’s arguments and the file’s declared SHA-256, so a file that matches its declaration almost never contains it: check that the bytes sent are the bytes declared. Then call again with a new ticket; changing the file’s arguments, such as its file name, gives a new boundary. |
proxy_upload_too_large / proxy_approved_upload_too_large | 413 | Over the upload limit (50,000,000 bytes), or the limit for an upload that needs approval (also 50,000,000 bytes). details.max_bytes names it when the ticket is refused. |
proxy_upload_timeout | 408 | The upload stalled, ran past its time limit, or stayed under the minimum rate. Call again. |
proxy_upload_client_disconnected | 499 | The connection ended during the upload. Call again. |
proxy_upload_expired | 410 | Temporary storage for an approved upload lapsed. Deliver again while the approval is open. |
proxy_upload_ticket_invalid | 401 | The ticket is malformed, expired, or belongs to another key. Returned only after the request’s signature and key are verified: an unauthenticated request gets the generic invalid_signature 401. Call again for a new one. |
proxy_upload_ticket_used | 409 | A ticket is good for one delivery. Call again for a new one. |
proxy_upload_context_mismatch | 403 | The delivery differs from the admitted request (key, agent, rule or grant). Use one client for both. |
proxy_upload_approval_required | 409 | Policy changed since the ticket: the upload now needs approval. Call again. |
proxy_upload_not_ready | 409 | The approval is not waiting for an upload: undecided, ended, or already delivered. |
proxy_upload_capacity / proxy_upload_storage_capacity | 503 | Upload slots or temporary storage are full. Wait, then retry with bounded backoff. An upload that was refused here is safe to retry. |
proxy_upload_storage_queue_full / proxy_upload_storage_queue_timeout | 503 | The body-free storage admission queue is full or its wait expired. No bytes were read and the ticket was not spent. Retry delivery with the same unexpired ticket using bounded backoff; calling the SDK upload method again obtains a fresh ticket. |
proxy_upload_ticket_unavailable / proxy_upload_storage_unavailable | 503 | A dependency is unavailable, so the upload failed closed. Retry with bounded backoff. |
proxy_upload_storage_corrupt | 500 | Temporary storage failed verification, so nothing further was sent. Call again. |
MemoryIsolationError
Section titled “MemoryIsolationError”Private memory identity or partition verification failed. A direct child of AlterSDKError, not a BackendError: it is raised locally by memory_scope() / memoryScope(), by ScopedMemoryStore, and by the assertion verifier, never from an HTTP response. Branch on the stable code attribute, never on the message (the message only repeats the code as a prefix). The value is one of the closed MEMORY_ISOLATION_CODES vocabulary, identical in both SDKs; MemoryIsolationCode is the exported Literal / union type.
code | Meaning | Recovery |
|---|---|---|
memory_identity_unverified | The IdentityContext was constructed, deserialized, copied or mutated in-process and carries no provenance. | Resolve identity through the authenticated SDK, or verify an assertion against the configured issuer, audience, trusted keys and application. |
memory_live_refresh_required | A resolved snapshot was bound to a ScopedMemoryStore without a resolver. | Pass refresh_identity / refreshIdentity, or bind an assertion-backed identity. |
memory_refresh_not_live | The resolver returned an identity minted before the operation started (a cached or memoized result). | Make the resolver call Alter on every invocation. |
memory_identity_expired | The assertion-backed identity is past its signed expiry. | Obtain and verify a fresh assertion. |
memory_assertion_invalid | The token failed verification. details["reason"] / details.reason is one of malformed, header, key, signature, lifetime, claims or binding; no token, claim or key material is ever included. | key usually means a rotated or mis-pasted JWKS; lifetime an expired token or clock skew beyond the 5-second iat leeway; binding the wrong application or agent. Fix the verifier configuration, or obtain a fresh assertion. |
memory_agent_required | No authenticated agent is bound (an application-only identity). | Resolve or assert through an agent key. |
memory_user_required | User mode was requested for a headless identity. | Pass agent_only=True / { agentOnly: true } for a headless agent. |
memory_user_not_active | The represented user is not active. | Deny; a suspended user cannot open memory until reinstated. |
memory_user_cannot_be_dropped | Agent-only mode was requested for an identity that represents a user. | Use user mode; agent-only mode never drops a user. |
memory_identity_changed | The refreshed identity resolves to a different partition than the one the store was bound to. | Create a new scoped store for the new principal. |
memory_store_scope_violation | The store returned a result outside the requested partition. | Fail closed and correct the store integration. |
A malformed path, key, value, query, filter, pagination argument, option or verifier argument is a programming error and raises AlterValueError instead, so a MemoryIsolationError handler only ever sees an authorization outcome. Serialized identity JSON does not establish trust; headless agents require explicit agent-only mode. See memory isolation and migration.
AmbiguousGrantError
Section titled “AmbiguousGrantError”Raised when provider-based resolution matches more than one grant. Alter never silently picks a grant — there is no “default grant” or “most recently connected wins” behavior. The error enumerates the candidates so the caller (or the end user, conversationally) chooses explicitly. The candidates are always scoped to the caller’s own accessible grants — the error can never reveal a grant the caller could not use.
Credentials are always reached through a grant: by grant_id, or by the
provider (for a managed-secret provider, its slug), which resolves one grant.
An application key passes the user’s token to narrow the match to that user’s
grants (without one, every grant the application holds on the provider is a
candidate); an agent resolves among the grants it holds and passes a user’s
token only to choose between users. Several matching grants return HTTP 409
ambiguous_grant and raise AmbiguousGrantError; narrow the call with
label, account or grant_id.
| Attribute | Description |
|---|---|
provider_id | The provider whose grants matched. |
candidates | One entry per matching grant: grant_id and label (the sibling address — retry with provider + label), plus, where the caller may see them, account_identifier and account_display_name. Retry with the chosen grant_id — the universal disambiguator. |
account_identifiers | List of matching accounts; show to the user to pick. A matching grant with no account identifier is listed by its grant id instead, which account= does not match: retry that one with grant_id. For a caller with no user token (an application key resolving by provider alone) the list spans every matching grant the application holds, across users. Bounded when candidates_truncated is true. |
account_was_provided | True if account= was already passed and still produced an ambiguity (sign of a mis-set account). |
app_user_ids | (Agent flavor, OAuth provider) UUIDs of the users with matching delegations, when an agent calls without a user token. Bounded when candidates_truncated is true. For an agent holding delegations from multiple users, candidates carry grant IDs and labels only — other users’ account identifiers are never exposed to the agent. |
grant_ids | (Agent flavor, managed-secret provider) IDs of the matching grants when an agent calls without a user token and the provider’s slug matches more than one grant it holds. They can span several users: delegations from one or more users, plus grants issued to the agent itself. Retry with the chosen grant_id, or pass the user’s token to narrow the delegations to that user. Bounded when candidates_truncated is true. |
candidates_truncated | True when more grants matched than the error can carry. It bounds every disambiguator above — candidates, account_identifiers, app_user_ids and grant_ids are all drawn from the same capped set — so an absence from any of them is not evidence the grant, account or user does not exist. Narrow the request, or list the application’s grants and pick a grant_id. False (or absent) means the set was not capped. |
Pass the chosen grant_id (or account=<chosen> / label=<chosen> /
user_token=<jwt> for the account / label / agent flavors) to disambiguate
on retry. For production workloads, prefer addressing grants by grant_id
from the start — the Connect flow returns it at consent time, and it stays
unambiguous no matter how many grants a user adds later.
NonProxyDisabledError
Section titled “NonProxyDisabledError”HTTP 403 non_proxy_disabled. No live credential-release exception covers this caller and credential, or the organization disabled all release. The provider was not called.
details carries caller_kind, caller_id, grant_id, provider_id, managed_secret_id and credential_kind. Move the call to proxy_request() / proxyRequest(), or have an organization administrator add an exception under Settings → API key policy → Credential-release exceptions. See non-proxy requests.
RestrictedGrantRequiresProxyError
Section titled “RestrictedGrantRequiresProxyError”Raised when raw-token retrieval is attempted against a grant whose policy
carries method/endpoint restrictions or an operation policy (a content rule or
an operation allowlist). Restricted grants are proxy-only by
design — a token handed to the caller could not be held to the restriction —
and there is no opt-out. Switch the call to the SDK’s proxied execution path
(proxy_request() / proxyRequest()); restriction denials there surface as
PolicyViolationError.
The same error, with details["error"] / details.error set to
user_limits_require_proxy (HTTP 400), is raised once the end user has set
any limit that applies to the grant — a request quota, active hours, a request
match or an operation rule such as the Connect page’s Read-only limit, from the
Wallet or on the Connect page. A limit binds only on calls
Alter sees: a raw credential handed to the caller would count one retrieval
and then never be limited again. It applies to OAuth and managed-secret grants
alike, so an OAuth grant whose user added a quota stops releasing raw tokens.
A quota or active-hours rule the application sets does not trigger it (the
application’s restriction and approval rules are proxy-only already).
When more than one of these applies, details["error"] names the first, in
this order: hitl_grant_requires_proxy (an approval rule, the user’s own
“Ask me before changes” limit included), restricted_grant_requires_proxy (an
application restriction or operation rule), delegated_grant_requires_proxy
(an agent’s delegation or a scope-narrowed grant, whatever limit the user set
on it), then user_limits_require_proxy. The response is the same:
call through proxy_request() / proxyRequest(), where every limit is
enforced; retrying the raw retrieval cannot succeed while the user’s limit
exists.
GrantNotDelegableError
Section titled “GrantNotDelegableError”Raised when agent.delegate() tries to delegate a grant that does not permit
onward delegation. Existing grant authority cannot be widened by retrying the
same call. The causes:
- No consenting user. The held grant does not trace back to a user who approved it, so no one consented to sharing it onward.
- The held grant is not delegable. The user did not allow onward sharing
when they approved the delegation. Ask for it again through a Connect session
with
delegableset toTrue/true, which the user decides on the consent screen. In the wallet the user can allow it for a managed-secret grant by delegating to the agent again with sharing on; for an OAuth connection the wallet can only create a new grant for the agent with sharing on, which has a different grant id. - The operator ceiling is off. For a managed-secret provider, the provider’s delegation policy does not allow re-delegable grants. For an OAuth provider, the provider’s Agent sharing setting is off. An administrator turns it on. The ceiling is checked on every onward call, so turning it off refuses further delegation from grants that were already delegable.
It is also raised when delegable is True / true and the ceiling’s depth
leaves the new child no further hop, since the child could never delegate
onward.
detail_reason (Python) / detailReason (TypeScript) names the cause, so a
caller branches on it rather than on the message: no_consenting_user,
holder_not_delegable, ceiling_off, no_onward_hop or not_requested. It is
None / null when the backend sent none (an older backend), and an unknown
value is passed through unchanged. Omit delegable or pass False / false (neither triggers this depth
check), or have an administrator raise the depth ceiling while it is below the
cap of 8. A child that would itself sit deeper than the ceiling allows is
refused with HTTP 422 delegation_depth_exceeded, raised as BackendError.
AgentDelegationMissingError
Section titled “AgentDelegationMissingError”Raised on the agent path when a grant_not_found 404 comes back for an
explicit grant_id. A subclass of GrantNotFoundError, so existing
except GrantNotFoundError / instanceof GrantNotFoundError handlers keep
catching it unchanged. For an agent caller the bare 404 is ambiguous — the
grant may exist but not be delegated to this agent, or a user/base grant_id
was passed where the agent’s own delegation id (from list_grants /
listGrants) was required (an agent can only address its own delegation by
id). The App/operator path is unaffected — there grant_not_found genuinely
means “no such grant / not owned”, so it stays a plain GrantNotFoundError.
Inherits GrantNotFoundError’s recovery-context fields (provider_id /
agent_id / app_user_id, populated only on identity-mode raises). Recover by
delegating the agent through Connect (create_connect_session /
createConnectSession), or resolve by provider (omit grant_id) so the call
routes through the agent’s existing delegations.
SiblingLabelConflictError
Section titled “SiblingLabelConflictError”Raised by mint_grant() / mintGrant() when the requested label is already
held by an active grant on the same connection. Carries label. Pick a
different label, or revoke the holder first — revoking a grant frees its
label.
DelegationLabelTakenError
Section titled “DelegationLabelTakenError”Raised by delegate() (HTTP 409, code delegation_label_taken) when
another agent already gave a delegation to the same recipient, for the same
provider or managed secret, the requested label, in any status (a revoked
one included, so a label is never handed over to a different delegator).
Carries label. Nothing is delegated. Pick another label. Delegating again
from the same held grant keeps its own label.
GrantTagsChangedError
Section titled “GrantTagsChangedError”Raised by update_grant_tags(..., expected_tags=...) /
updateGrantTags(..., { expectedTags }) (HTTP 409, code
grant_tags_changed) when the grant’s current tags are not exactly
expected_tags: someone changed them after they were read. Nothing is
written. Read the grant’s tags again, reapply the change, and retry with the
new map as expected_tags. Without expected_tags the map is replaced
unconditionally and this is never raised.
CredentialIdRequiredError
Section titled “CredentialIdRequiredError”Raised by create_managed_secret_grant() / createManagedSecretGrant() (409
credential_id_required) when the provider holds more than one
developer-set credential and the call did not name the one the grant serves.
Carries credentials — the choices, each a CredentialChoice with
credential_id / credentialId and label. Retry the call with
credential_id / credentialId set to one of them. A provider with a
single developer-set credential never raises this: that credential is implied.
EndUserCredentialNotAssignableError
Section titled “EndUserCredentialNotAssignableError”Raised by create_managed_secret_grant() / createManagedSecretGrant() (409
end_user_credential_not_assignable) when the named credential_id is an end
user’s own credential. An end-user credential serves exactly one grant — its
owner’s — so it can never be assigned to another principal. Name a
developer-set credential instead; the end user’s grant can still be delegated
to an agent through the delegation flow.
User-owned managed-secret grants
Section titled “User-owned managed-secret grants”An end user’s own managed-secret key — the grant it creates and every
delegation made from it — and any delegation a user consented to belong to
the user, the way a user’s OAuth connection does. The application can revoke
them and read them, and nothing else. These refusals come from the developer
portal routes the dashboard and the alter CLI call; no SDK method reaches
them.
| Code | HTTP | Refused | Recovery |
|---|---|---|---|
grant_user_owned | 403 | Editing a user-owned grant (label, description, settings), or adding a grant-level policy rule to one: a rule homed on it, another rule attached to it, or a new body or re-enabling of a developer rule that already includes it (disabling, renaming and deleting such a rule stay allowed). Nothing changed. | Leave the grant to its user, who sets its limits in the Wallet or on the Connect page. A rule on its provider, its user, an agent or the app still applies to it. Revoke the grant if it must go: revoking an end user’s own key destroys the key. The CLI exits 7 and names the code. |
credential_user_owned | 403 | Rotating or renaming an end user’s own key. | Only the user can replace their key, through Connect. The application can delete it, which revokes every grant it serves. The CLI exits 7. |
end_user_key_setup_invalid | 422 | Setting the end-user key setup with a field the provider cannot take. Each refused field is an entry of fields with its own code: unknown_scope (a scope the provider’s catalog does not list, the ids in values; only providers that publish a catalog, such as Rippling, check this) or template_not_bound (binding host patterns on a provider that does not derive its allowed hosts from the key). Nothing was saved. | Use the ids in the provider’s template_api_key_scopes; send no binding host patterns for that provider. |
InsufficientScopeError
Section titled “InsufficientScopeError”Raised when the calling key — possibly after per-call attenuation — lacks a scope the backend route requires.
The message is the backend’s sentence naming the missing scopes, followed by what to do about it. Two things go wrong after this error, and the message addresses both:
- Which key. It is the API key the client was constructed with, not a personal access token. Rotate an app key with the scope added (
alter keys rotate --presetor--scopes, or the key’s page in the Developer Portal). An agent’s own key has a fixed scope set and cannot be widened: make the call with an app key. - Why it repeats after the fix. The SDK reads its key once, when the client is created. Load the new key into the application and restart the process; a process that is already running keeps the old key, and the old key keeps its old scopes.
- When the key already holds the scope.
grantedis what remained after any scope constraints sent with the request. If the key’s stored scopes include the missing one, a constraint narrowed it away, and rotating changes nothing: send the request without that constraint.
The fix sentence is appended only when the response names a missing scope. Branch on missing, never on the message text.
| Attribute | Description |
|---|---|
required | Scopes the route requires. With required_any_of, alternatives — any one suffices. |
granted | Scopes the key has, post-intersection with constraints. |
missing | The unsatisfied scopes. Without required_any_of: required \ granted, all needed. With it: every accepted alternative — add any one. |
scope_version | Catalog version the key was minted against. |
current_scope_version | Catalog version the server is on. |
scope_version_mismatch | True iff the missing scope only exists at the server’s version — rotate the key. |
documentation_url | Per-scope docs link. |
required_any_of | True when the route accepts ANY ONE of required (OR semantics — e.g. the approval status poll accepts approvals:read or proxy:execute). False (default): every scope is required. |
ScopeReauthRequiredError
Section titled “ScopeReauthRequiredError”Raised by request() when the provider returns 403 and the grant’s stored scopes don’t cover the route. proxy_request() does not raise it: the 403 comes back as a result, with credential_hint set when Alter recognized the cause.
| Attribute | Description |
|---|---|
grant_id | The grant that needs re-authorization. |
provider_id | The provider. |
missing_scopes | When parsed from a WWW-Authenticate: insufficient_scope challenge, the specific scopes missing. None when the source was a pre-flight backend flag. |
status_code, response_body | The provider’s raw response. |
Pattern:
result = await app.proxy_request(...)if result.status_code == 403 and result.credential_hint: session = await app.create_connect_session(allowed_providers=["<provider-id>"]) notify_user(session.connect_url)ProviderUnauthorizedError
Section titled “ProviderUnauthorizedError”Raised when the provider returns 401 to a request() call — the provider rejected the credential (revoked, expired, or otherwise invalidated provider-side). The 401 sibling of ScopeReauthRequiredError; both extend ProviderAPIError, so existing ProviderAPIError handlers keep catching it. A 401 whose WWW-Authenticate challenge carries error="insufficient_scope" (RFC 6750) is deliberately excluded — the credential is still valid, it just lacks a scope — and surfaces as a generic ProviderAPIError instead.
| Attribute | Description |
|---|---|
grant_id | The grant the rejected credential was issued under. |
provider_id | The provider. |
status_code, response_body | The provider’s raw response. |
Recovery depends on the grant family:
- OAuth grant — re-authorize via a new Connect session (same pattern as
ScopeReauthRequiredError:create_connect_session(allowed_providers=[e.provider_id])and surface the URL to the user). - Managed-secret grant — the stored secret is no longer accepted by the provider; update it with a valid value.
PolicyViolationError
Section titled “PolicyViolationError”Raised when a policy denies the call.
| Attribute | Description |
|---|---|
policy_error | Backend-supplied identifier for the violated policy (e.g., outside_business_hours, ip_not_allowed, rate_limit_exceeded). |
When a rule denied the call, the response’s denied_by names the rule type, the level it was set at and one of thirteen reasons: rule_denied (the request matched the condition a json_match, time-window, IP-allowlist or similar rule blocks), content_rule_denied (a content rule’s operation or parameters matched what it blocks), operation_not_allowed (the operation is not on an operation allowlist), request_condition_not_met (a request allowlist selects the request and a condition it requires does not hold, or a required field is missing), request_field_not_listed (a strict request allowlist selects the request and the request carries a field the rule does not name), request_ambiguous (a raw-form request allowlist applies and the request spells its path or a checked field in a form servers read differently, such as a path with .., //, an encoded separator or double percent-encoding, or amount.total in place of or beside amount_total; send the canonical path and field names), operation_unclassified (the request could not be matched to a cataloged operation while an operation-scoped rule applies, so it could not be checked), operation_unreviewed (the request is an unreviewed operation and no rule admits it by name; the response’s error is then operation_unreviewed and it names the operation, see OperationUnreviewedError), projection_failed (a condition’s parameter could not be read), duplicate_argument (the request sends an argument more than once; see below), undeclared_argument (see below), tag_mismatch (a tag match rule applies and the acting agent and the connection do not carry the same value for a listed tag key, or either lacks it; a call with no acting agent, the application’s own backend, is not checked; the same reason refuses handing a connection to such an agent, with denied_by.keys naming the keys: delegate, a Connect session or consent that shares the new connection with the agent, and a delegation from the Wallet; it also refuses delegate by an agent whose own value no longer matches the connection it holds) or ceiling_empty (together the limits on the connection allow nothing). Three further denied_by.reason values name no rule. account_mismatch: the request’s path names an account other than the one the connection was authorized for, on a provider whose API names the account in the path (QuickBooks: the company id after /v3/company/ or /manage/entitlements/v3/ differs from the connection’s account_identifier), or the path is spelled so that the account it names cannot be read (.., //, an encoded /, a ; parameter or whitespace in a segment). It applies to every connection with no rule needed, before the provider is called; use the connection authorized for the other account. context_header_ungoverned: while a rule whose verdict depends on where the request runs applies to the operation (a content rule with params conditions, or an approval rule with params, whose match selects it), the request switched the provider namespace with a provider context header, or the query-string form of one the provider also reads (each provider’s reference page lists its context headers with their parameter names; Dropbox’s are Dropbox-API-Path-Root, Dropbox-API-Select-User and Dropbox-API-Select-Admin, parameters path_root, select_user, select_admin, which Dropbox also reads as query parameters of the same names) and no stored content rule with effect deny (or approval rule) bound to the operation names that header’s parameter, so a folder or operation rule could not have judged where the request actually lands. denied_by.context_parameters lists the ungoverned parameter names (names only, never the header’s value). Every content rule fires to deny, so a stored rule governs the header with the condition that fires on what is refused: {"op": "exists", "value": true} on the parameter forbids the header, {"op": "not_all_in", "value": [...]} admits only the listed values and denies a request without the header, which cannot be compared, unless an {"op": "exists", "value": true} condition on the parameter comes first (a JSON-object header value is compared as compact, key-sorted JSON on both sides; every value ignores case and surrounding whitespace); a per-request rule never governs a header. The governing rule needs at least the authority of every location-dependent rule on the operation: an end user’s or a delegating agent’s rule never lifts the refusal that protects a rule set above it. With no such rule (no rules, an operation allowlist only, or content rules on other operations) the header is forwarded. See Keep Dropbox access inside one client folder. redaction_alters_authorized_request: the rules allowed the request, but a redaction they asked for would remove or change a field that a deny or step-up condition, an approval rule, or a request allowlist condition on the same request judged (or, under a strict raw-form request allowlist, would change which fields it finds), so the provider would receive a request no rule allowed. denied_by.redaction_parameters lists those field names (names only): a parameter name, or for a raw-form request allowlist the address its author wrote, such as body:metadata[source]; see Redact instead of deny. Rule values themselves — allowed operations, listed addresses, approver emails — are never returned.
May resolve on its own (time-of-day window opens, rate limit decays). One
policy denial does not raise this class: a request-quota window denial
raises QuotaExceededError instead, which carries the
seconds until the window resets.
One policy_error does not resolve on its own: credential_minting_refused
(HTTP 403). The call named a provider operation that would leave the caller
holding a provider credential, such as a token exchange, a new or rotated API
key, or a password the caller changes. Alter refuses every such operation on
every connection by default, before it reaches the provider (see
Operations that hand over a credential).
Retrying the same request gets the same answer until an operator allows the
operation with a credential_minting rule naming its provider and operation
id, outright or behind human approval; the caller cannot lift the refusal
itself. When the request path could be more than one such operation, the
allowance must name every one of them. A request whose path cannot be read well enough to rule such an
operation out is refused with the same code, and no allowance covers it.
So is a GraphQL request to an endpoint that can return a credential when Alter
could not read all of it (a transport, encoding or framing it does not read, or
a request past its inspection budget): send the document as UTF-8
application/json or application/graphql, or by GET with only the document
parameters (GraphQL).
Otherwise, call the provider’s API through the existing connection instead.
duplicate_argument is given when a rule reads the request’s parameters and
the request sends an argument more than once: a form field that takes one value
sent more than once, a query parameter that takes one value sent with different
values or also sent in the body or a header, a key repeated in a JSON argument
or namespace header (such as Dropbox’s Dropbox-API-Arg), a namespace header also sent as its
query-string form (Dropbox’s Dropbox-API-Path-Root header and a path_root query parameter,
even with the same value), or, where Alter
reads a body as JSON text, a JSON key repeated in one object (at any depth). A
JSON body sent through the SDKs reaches Alter as one object, so each of its
keys is read once. A header written under two spellings is refused before any
rule runs, with duplicate_header_spelling.
Readers disagree on which value a repeated argument carries (some keep the
first, some the last, and servers join repeated headers), so Alter refuses the
request rather than check one value while the provider acts on another.
Retrying the same request gets the same answer; send each argument once.
undeclared_argument is given when a rule reads the request’s parameters and
the request carries a query parameter its operation does not take, on a
provider whose catalog lists every query parameter each operation takes
(QuickBooks: the parameters Intuit documents, such as minorversion,
requestid, include with its documented values on an entity read or a query
and, on a query, query).
The rule judged the listed parameters, while the provider would also act on the
other one (for example expand or fields), so Alter refuses the request, as
the managed methods refuse undeclared input with invalid_operation_input.
A parameter with documented values (include) also refuses any other value, or
the parameter sent twice. include is a declared parameter a rule can read; the managed QuickBooks
methods do not take it yet, so send it through the raw proxy. With no rule reading the operation’s parameters the
request is forwarded as before. Retrying the same request gets the same answer;
send only the operation’s parameters.
StepUpRequiredError
Section titled “StepUpRequiredError”A typed PolicyViolationError for a content_match step-up obligation. Its
policy_error / policyError is always step_up_required, and
max_session_age_seconds / maxSessionAgeSeconds carries the rule’s freshness
ceiling when supplied. Re-authenticate the user to obtain a fresh identity
session, then retry the original request.
RedactDischargeFailedError
Section titled “RedactDischargeFailedError”A typed PolicyViolationError raised when a content_match redact obligation
could not safely transform the request body. Its policy_error /
policyError is always redact_discharge_failed. The request fails closed and
is not forwarded to the provider. Correct the request shape or the rule’s
redact.fields before retrying.
OperationUnreviewedError
Section titled “OperationUnreviewedError”A typed PolicyViolationError (HTTP 403, error operation_unreviewed). Its policy_error / policyError is always operation_unreviewed. The call is an operation of the provider’s published API specification that Alter has not reviewed, so its families are unknown, and an operation, family or content rule applies while no rule admits it by name. The refusal is the same one a call no catalog can name gets (before an operation was cataloged as unreviewed, the same call was refused with policy_violation and denied_by.reason operation_unclassified; an SDK released before OperationUnreviewedError raises a plain PolicyViolationError whose policy_error is operation_unreviewed), so a broad rule cannot be dodged by calling it. With no operation, family or content rule on the connection, the call runs.
The error names the operation:
| Field (Python / TypeScript) | Meaning |
|---|---|
operation_id / operationId | The exact name a rule uses: the provider-qualified <provider>:<operation-id>, such as canva:createUrlImportJob (the bare id from the provider’s specification can belong to several providers, so a rule never names an unreviewed operation by it) |
method / method | Its HTTP method |
path_template / pathTemplate | Its provider path, with placeholders |
details["denied_by"] / details.denied_by names the rule that refused it, with reason operation_unreviewed. A field the response does not carry as text is None / undefined. To use the operation, name operation_id in an operation allowlist to allow it, or in a require_approval rule whose every condition (operation and match) names it to hold it for approval. Saving, changing, applying elsewhere or deleting such a rule needs an organization admin, and a personal access token also needs dashboard_app_policy:rules_admit_unreviewed. A deny rule or an approval with any other condition naming it judges it but never lets it through. Because an unreviewed operation may create a credential or change account security, an admitted one is then refused with policy_error credential_minting_refused until an operator adds a credential_minting allowance with that provider naming the same operation_id, with caller_type, caller_id, expires_at and reason. A family never allows it, and a family rule always refuses it. See Unreviewed operations.
invalid_url
Section titled “invalid_url”A 400 from proxy_request() / proxyRequest() that surfaces as a plain
BackendError with details['error'] / details.error set to invalid_url:
Alter cannot send the request URL, for example because its host name is not a
valid internationalized domain name. It applies to every proxied call, whether
or not the call requires approval. Nothing is created or forwarded. Fix the
URL; retrying it unchanged gets the same answer.
invalid_header_name
Section titled “invalid_header_name”A 422 from proxy_request() / proxyRequest() that surfaces as a plain
BackendError with details['error'] / details.error set to
invalid_header_name: a request header name is not a valid HTTP header name
(an RFC 9110 token: letters, digits and !#$%&'*+-.^_`|~, with no spaces).
Nothing is created or forwarded. Both SDKs refuse such a name locally with
AlterValueError before sending, so this error reaches an application only
from another client, or from a request approved before the rule applied (which
then fails instead of running). Rename the header and retry.
duplicate_header_spelling
Section titled “duplicate_header_spelling”A 422 from proxy_request() / proxyRequest() that surfaces as a plain
BackendError with details['error'] / details.error set to
duplicate_header_spelling and details['message'] / details.message
“A header name must not be repeated in another spelling (header names are
case-insensitive).”: the headers map names one header in two spellings
(Dropbox-API-Arg and dropbox-api-arg). Header names are case-insensitive,
so the provider would read the two lines as one header — whichever its stack
takes first — while a policy rule could judge only one of them. The request is
refused on every connection, before any policy is evaluated; nothing is
created or forwarded, and the refusal appears in the audit log as a denied
call. A request frozen for approval before this rule applied fails at
execution with the same code instead of running. Send the header once, in one
spelling, and retry.
query_too_long
Section titled “query_too_long”A 422 from proxy_request() / proxyRequest() that surfaces as a plain
BackendError with details['error'] / details.error set to
query_too_long and details['max_url_length'] / details.max_url_length
set to 65536: a URL Alter would have to send is longer than 65,536
characters once percent-encoded, the most Alter’s HTTP client will send.
Shorter URLs are forwarded and the provider applies its own limit. Length is
measured as sent, so repeated list values and multi-byte characters count in
full (an emoji is twelve encoded characters). The limit is the same whether
the query is in url or in the separate query parameters. Two checks apply,
and both refuse before anything reaches the provider:
- The URL as written: the request’s
urlwith the separate query parameters merged in. Checked when the call arrives, before any approval is created. - The URL as sent: the same URL plus any query-parameter credential Alter adds for the grant. Checked just before sending, so a request that fits as written can still be refused here; an approved request refused here fails.
Shorten the query, or move the data into the request body if the provider
accepts it there, and retry. (request() builds its URL in the application
and applies the same 65,536-character limit to url with its query
parameters, raising AlterValueError before sending.)
query_params_unmergeable
Section titled “query_params_unmergeable”A 422 from proxy_request() / proxyRequest() that surfaces as a plain
BackendError with details['error'] / details.error set to
query_params_unmergeable: the separate query-parameters argument could not
be merged into the request URL because a parameter value has a shape the HTTP
layer cannot encode. Length is never this error: a URL that is too long once
merged is query_too_long, and a URL Alter cannot parse is
refused earlier with 400 invalid_url. The request is rejected
before any policy or credential work runs and nothing is forwarded to the
provider. (request() merges its query parameters locally, so it raises a
client-side error for the same inputs and never produces this code.) Flatten
the query parameter values to strings, numbers, booleans, or lists of those,
and retry.
invalid_batch_input
Section titled “invalid_batch_input”A 422 for a provider batch (a QuickBooks batch request) whose items Alter
cannot judge one by one. A managed call raises it as ManagedOperationError
with this code; proxy_request() / proxyRequest() and request() surface
it as a plain BackendError with details['error'] / details.error set to
invalid_batch_input. Nothing is forwarded to the provider, and the refusal is
recorded as a denied call. Triggers: an item with no unique bId, more than one
entity, a Query that is not a SELECT … FROM <entity> statement, or an
entity the provider’s catalog does not govern; on a managed call, also more
than 30 items, a Query whose statement names no single FROM table, or an
item whose operation is not create, update or delete. On a raw request
an item with another operation is forwarded, judged as the whole batch, unless
an operation-aware rule (a content rule, an operation allowlist, an AI review,
or a match or approval rule that selects an operation or family) applies to the
connection; then it is refused with this code, because the rule could not
judge the effect that item has. See QuickBooks policy
behaviour. Fix the
named items and retry; retrying unchanged gets the same answer.
Provider-call and credential-store codes
Section titled “Provider-call and credential-store codes”These server-side failures arrive as a plain BackendError. Switch on
details['error'] / details.error, and read the HTTP status from
status_code / statusCode. On a 503 the SDKs copy the Retry-After header
into details['retry_after_seconds'] / details.retry_after_seconds. A 502
carries no retry hint. Neither SDK retries any of these on its own.
The provider-call codes come from proxy_request() / proxyRequest(), where
Alter makes the provider call. request() calls the provider from the
application itself, so the same failures surface there as NetworkError or
ProviderAPIError.
details['error'] | HTTP | retry_after_seconds | Meaning | Recovery |
|---|---|---|---|---|
provider_timeout | 502 | Not set | The provider did not answer within the call’s timeout. The request may have reached the provider. On a synchronous call, a GET, HEAD or OPTIONS request that Alter’s policy catalog classifies as a read-only operation (never a custom integration’s operation, never a request with an upload body) may already have been sent a second time on a new connection, when the first connection dropped before an answer. | Retry with backoff. Before repeating a call that is not idempotent, check whether the provider applied it. |
provider_unreachable | 502 | Not set | Alter could not complete a connection to the provider, or the connection failed before a response arrived. The request may have reached the provider. On a synchronous call, a GET, HEAD or OPTIONS request that Alter’s policy catalog classifies as a read-only operation (never a custom integration’s operation, never a request with an upload body) may already have been sent a second time on a new connection, when the first connection dropped before an answer. | Same as provider_timeout. If it persists, the provider or its address is down. |
provider_unavailable | 503 | 1 | The application’s recent calls to this provider kept failing, so Alter is not sending the application’s calls to it for a short cooldown. Other applications’ calls are unaffected. The provider was not contacted. | Retry after the interval. The call was not sent, so a retry is safe for any method. |
provider_busy | 503 | 1 | Too many calls to this provider’s host were already in flight. The provider was not contacted. | Retry after the interval. The call was not sent. |
app_concurrency_limit | 503 | 1 | The application already had as many concurrent proxied calls in flight as one application may hold, in total or to this provider’s host. The provider was not contacted. | Retry after the interval. If it recurs, run fewer proxied calls in parallel. The call was not sent. |
egress_pool_exhausted | 503 | 1 | Alter had no outbound connection free to start the call. This is Alter’s own capacity, not the provider’s or the application’s. The provider was not contacted. | Retry after the interval. The call was not sent. |
dns_resolution_timeout | 503 | 5 | The provider’s host name could not be resolved in time, or the DNS resolver answered with a temporary failure (SERVFAIL). This says nothing about the request. The provider was not contacted. | Retry after the interval. The call was not sent. If it persists for one host, that host’s DNS is failing. A host name that does not exist is a 400 dns_resolution_failed instead, which a retry cannot fix. Returned only for a host the grant may reach: the destination allowlist is checked before any lookup. |
overloaded | 503 | 1 | The Alter instance that received the call was already running as many proxied calls as it accepts at once, so it refused this one before resolving its grant or credential. The provider was not contacted. | Retry after the interval; another instance often serves the retry. The call was not sent. |
A refused 503 call has not reached the provider, so retrying it never repeats
an action. The one-second intervals are short because each of those refusals
is a condition of the Alter instance that answered, and the next attempt is
often served by another instance. The five seconds for
dns_resolution_timeout are not: a DNS resolver that timed out or answered
with a temporary failure usually gives the same answer for a few seconds,
whichever instance asks. For a call that waited for approval, Alter retries
every code in this table except overloaded itself after the approval (overloaded refuses a call when it is made, before any approval exists),
within the at-most-once rule below. provider_unavailable, provider_busy,
app_concurrency_limit and egress_pool_exhausted are Alter’s own capacity:
it keeps retrying those, waiting out a provider’s cooldown, for up to 10
minutes after the last approval (never past the approval’s expiry), and then a
bounded number of times more. Every code in this table is retried a bounded
number of times; if those attempts run out it reports an
ApprovalExecutionFailedError whose message starts exhausted <attempts> retries: and names the code.
An approved call reaches the provider at most once. Alter sends an
approved call again only when a second copy cannot repeat an action: the
earlier attempt failed before any of the request was sent (the connection
could not be opened, or one of the 503 refusals above), or the call is a
GET, HEAD or OPTIONS request that Alter’s operation catalog for the
provider names a read with no other effect. The method alone is not enough,
because some providers act on a GET. Any other call that may have reached
the provider is not sent again: a provider_timeout or
provider_unreachable failure after the request may have been sent, an
internal failure after sending began, a provider answer whose result Alter
could not then record, or a call whose execution stopped after sending
began. An Idempotency-Key header on the request does not change this: not
every provider honours one, so Alter does not rely on it. The approval then
ends failed and await_approval() / awaitApproval() raise an
ApprovalExecutionFailedError whose message starts
provider_outcome_unknown:. The provider may or may not have performed the
call: check the provider (for example, look for the payment or the record
the call would have created) before making it again.
Credential-store outages. request() and proxy_request() /
proxyRequest() both read the credential from Alter’s credential store, for
OAuth and managed-secret grants alike. When that store cannot be reached,
times out, or refuses the read for rate, even after Alter’s own retries, the call fails with:
details['error'] | HTTP | retry_after_seconds | Meaning | Recovery |
|---|---|---|---|---|
service_unavailable | 503 | 5 | Alter’s credential store was temporarily unavailable. The message is “Credential storage temporarily unavailable”. Nothing about the grant or the stored credential changed. | Retry after the interval. Do not reconnect the account or replace the credential. |
A failure a retry cannot fix (a stored credential Alter cannot read back) is a
502 instead, with no retry hint: credential_unavailable, or
credential_storage_corrupted for a managed-secret credential read by
request(). Contact support; retrying does not help.
Minted-token codes
Section titled “Minted-token codes”Some managed-secret templates store a client ID and secret (and, for the
Encompass API user, a user login) instead of a token, and Alter exchanges them
at the provider for a short-lived token when a call needs one: SAP S/4HANA and
Shopify client credentials, Corrigo Enterprise, and both Encompass machine
routes. When that exchange fails, request() and proxy_request() /
proxyRequest() raise a plain BackendError; switch on details['error'] /
details.error.
details['error'] | HTTP | Meaning | Recovery |
|---|---|---|---|
client_credentials_rejected | 409 | The provider rejected the stored credential. The message names which one: the client credentials (client ID and secret), or, on a template that stores a user login, the user name or password. details['provider_status_code'] carries the status the provider returned, when it returned one. | Fix the credential the message names, then retry: rotate the client secret, or update the stored login (a fields-only update keeps the stored key; see Update fields and keep the key). Retrying unchanged cannot succeed. |
client_credentials_misconfigured | 409 | The stored fields cannot form a token request. For a template with a fixed token endpoint (Corrigo, Encompass) the message names the fields to check, each of which must be present, not blank, and free of control characters. For a template whose token endpoint is built from a field (Shopify’s store subdomain) it points at the fields the endpoint is built from, each of which must be a single hostname label, and the client ID. Otherwise (SAP S/4HANA, whose token endpoint URL is entered on the provider) it points at the token endpoint URL and the client ID. It is also the answer when an endpoint entered on the provider, or built from its fields, resolves to an address Alter does not connect to. | Correct the named fields on the provider and save again. |
client_credentials_unavailable | 503 | The token endpoint could not be reached, timed out, or refused the exchange without rejecting the credential. It is also the answer when a fixed token endpoint (Corrigo, Encompass) resolves to an address Alter does not connect to, or when the endpoint’s host name cannot be resolved. The response carries Retry-After: 5: Alter has already retried the exchange once. | Wait Retry-After seconds, then retry with backoff. If it persists, the provider’s token service is down. |
client_credentials_malformed_response | 502 | The token endpoint answered success but returned no usable access token. | Retry later; if it persists, the provider’s token service is misbehaving. |
provider_egress_rate_limited | 429 | A provider under Alter’s egress cap (Corrigo) counts each token exchange too, so a call that needs a new token can be refused before the exchange is sent. | Wait Retry-After seconds and retry. |
A rejection is replayed for a while. After the provider rejects a stored
credential, Alter answers with the same client_credentials_rejected error
without contacting the provider again, for up to 5 minutes when the client
credentials were rejected and up to 30 minutes when a user login was, so
repeated calls cannot lock the provider account. Saving the credential again in
Alter (a rotation, or an update of the login) clears this at once and the next
call tries the provider. A fix made only at the provider, such as unlocking the
user or re-enabling the client there, takes effect when that window ends.
database_unavailable
Section titled “database_unavailable”Any call can fail with HTTP 503 and details['error'] / details.error set to
database_unavailable, raised as a plain BackendError with
details['retry_after_seconds'] / details.retry_after_seconds set to 2.
Alter lost its database connection while it was handling the request, for
example during a database failover, or the database ended the session (a
failover shutdown, a killed session). The message is “The database connection
was lost while handling the request. A read can be retried. A write may or may
not have been applied; check its result before retrying it.”
The connection can be lost after the request’s change was saved, or while it was being saved, so the error does not say whether a change was applied:
- A read changes nothing. Retry it after the interval.
- A call that changes something may already have taken effect. Check its result before retrying it: list or fetch the resource a create would have made, and after a mint look for the new key and revoke one you do not keep. Retrying a create or a mint blind can leave a duplicate.
Neither SDK retries it on its own, except that await_approval() /
awaitApproval() keeps polling through it as through any transient 503. The
alter CLI retries it for reads and
for PUT, PATCH and DELETE requests, which set state, and never for POST
requests (retries).
QuotaExceededError
Section titled “QuotaExceededError”Raised when a request-quota policy rule’s window limit is exhausted. This is a policy denial, not a transient outage — retrying before the window resets is denied again, so the SDKs never auto-retry it.
| Attribute | Description |
|---|---|
retry_after | Seconds until the current quota window resets, taken from the Retry-After response header when present and the body value otherwise, and capped at 2,678,400 seconds (31 days) (see the backoff ceiling). The cap is deliberately far larger than RateLimitError’s: a quota window is a calendar period, so a monthly quota legitimately means weeks, and clamping it to an hour would wake a caller ~700 times over a month instead of once. May be None (undefined in TypeScript) when the backend didn’t supply either. |
Recovery: wait retry_after seconds, then retry. A 429 relayed from the
provider itself (an upstream rate limit passed through the proxied call path)
is not a quota denial and surfaces as a generic BackendError instead.
RateLimitError and the platform rate limit
Section titled “RateLimitError and the platform rate limit”Raised when the platform rate limit is exhausted — a transient throttle, not a
denial: the same request succeeds once the window drains. Both SDKs surface
this as a typed RateLimitError. It is also raised for a non-JSON 429 from an
intermediary (see Intermediary limits below), where scope is unknown and
retry_after may be unset.
Version compatibility:
BlockedDestinationError, andRateLimitErrorfor a non-JSON 429, require SDK 0.28.0 or newer (alter-sdk/@alter-ai/alter-sdk). Version 0.27.0 and earlier raise a genericBackendErrorfor both responses.
The limit. Every API key allows 1,000 requests per minute by default. Two independent controls adjust it, and they are checked separately.
Per key — a key can be minted with a custom limit (for example, alter keys mint --rate-limit-rpm), and an organization policy can set a maximum any
single key may be held to. The effective per-key limit is:
| Key minted with an explicit limit? | Organization sets a per-key maximum? | Effective limit |
|---|---|---|
| yes | yes | the lower of the two — the maximum is a cap, never a boost |
| yes | no | the key’s own limit |
| no | yes | the organization’s maximum (it also serves as the default) |
| no | no | 1,000 per minute |
Across the organization — a policy can additionally set an aggregate limit
that every key in the organization shares. It is checked after a request
clears its own per-key limit, so exceeding it is reported separately with
scope: "organization". It is unset by default.
Intermediary limits. An edge or shared-IP limiter can reject a request
before the API-key limiter runs. A remaining API-key budget therefore does not
prove that every applicable budget remains available. If that layer returns a
non-JSON 429, both SDKs raise RateLimitError, retain HTTP status 429 in
details.status_code, and parse Retry-After when present. scope, limit, and
window_seconds stay None (undefined in TypeScript): the SDK does not invent
an API-key limit or attribute an unidentified response to an edge provider. Missing or
invalid retry guidance also stays unset; use bounded backoff appropriate to the
operation. No raw intermediary response body is exposed on the exception.
A last-observed API-key snapshot describes the origin’s last reported budget,
not the unidentified limiter’s remaining capacity.
The 429 response body. On the wire the fields are nested under a detail
object; the SDKs unwrap it for you and expose the fields on the typed
RateLimitError. A raw HTTP caller sees:
{ "detail": { "error": "rate_limit_exceeded", "scope": "api_key", "message": "API key rate limit exceeded (1000 requests per 60s). Retry after 2s.", "limit": 1000, "window_seconds": 60, "retry_after": 2 }}| Field | Description |
|---|---|
error | rate_limit_exceeded, or provider_egress_rate_limited for the provider egress cap (see The provider egress cap below). |
scope | Which ceiling was hit: ip (a per-client-IP gate that fronts the unauthenticated surfaces, evaluated before any key is resolved), api_key (this key’s own limit), organization (an organization-wide aggregate every key shares), or provider_egress (Alter’s combined traffic to one provider, shared by every Alter customer). |
limit | The limit that was exceeded, in requests per window — the ceiling named by scope, so on an organization rejection it is the organization aggregate, not this key’s limit. |
window_seconds | The window length in seconds (60). |
retry_after | Seconds to wait before retrying — the time until the next unit of budget frees up, not the whole window. Budget is replenished continuously rather than all at once when the window ends, so this is often a second or two even on a 60-second window. Honour it instead of sleeping window_seconds. |
message | Human-readable summary of the above. |
On the typed SDK exception, scope, limit and window_seconds /
windowSeconds are optional — not every response carrying this error code
supplies them — so check for a missing value before branching on one.
Response headers:
| Header | Description |
|---|---|
Retry-After | Seconds to wait before retrying. The SDKs’ typed retry_after / retryAfter field prefers this header over the body value. |
RateLimit-Policy | Standard quota policy metadata (q quota and w window seconds) following the IETF RateLimit fields draft. |
RateLimit | Standard current service limit for the binding policy (r remaining and t seconds to the effective window end). |
X-RateLimit-Limit | The ceiling this response was metered against; never assume it is this key’s own limit. On a 429 it is the ceiling named by scope: the key’s limit for api_key, the organization-wide aggregate for organization. A provider_egress 429 leaves the X-RateLimit-* and RateLimit headers describing the key’s own budget, which that refusal did not spend; its wait is Retry-After. On a success it is the ceiling the reported X-RateLimit-Remaining belongs to: the key’s own limit, or the organization aggregate when that is the tighter of the two. |
X-RateLimit-Remaining | Requests remaining against the binding constraint — the lower of what is left on this key and, when an organization aggregate is configured, what is left on that aggregate. 0 on a 429. |
X-RateLimit-Reset | Unix timestamp at which the current rate-limit window resets — the same meaning the header carries on GitHub and Stripe. It is not a per-request retry instant: Retry-After is the authoritative wait for the rejected call. Sleep until Retry-After to retry one call; read X-RateLimit-Reset to know when the full budget returns. |
X-Alter-Rate-Limited-Scope | ip, api_key, organization, or provider_egress: the same value as the body’s scope. Present only on this limit’s 429s, so it distinguishes a platform throttle from other 429 responses (a quota policy denial or a billing-period cap). |
The standard pair and compatibility X-RateLimit-* headers also ride on
successful responses to SDK calls, so a well-behaved client can throttle
itself before it ever sees a 429. They are not attached to every Alter endpoint
— only to requests this limit meters.
Treat their absence as unknown, never as unlimited: a response without them
says nothing about how much budget is left, and a client that reads “no headers”
as “no limit” will keep hammering the very endpoint that stopped reporting.
Both SDKs parse the compatibility triple, or the standard pair when the triple
is absent, into a frozen snapshot and expose the latest reading as
last_rate_limit / lastRateLimit, on the client and on App / Agent alike.
It is updated by every call the limit meters — successful calls included — so
the self-throttling above is something an application can actually implement:
import asynciofrom datetime import datetime, timezone
await app.proxy_request("GET", url, grant_id=grant_id)
budget = app.last_rate_limitif budget is not None and budget.remaining < 10: # reset_at is an aware UTC datetime read from the server's clock. await asyncio.sleep((budget.reset_at - datetime.now(timezone.utc)).total_seconds())await app.proxyRequest({ method: "GET", url: url, grantId });
const budget = app.lastRateLimit;if (budget !== null && budget.remaining < 10) { await new Promise((r) => setTimeout(r, budget.resetAt.getTime() - Date.now()));}The snapshot carries limit, remaining and reset_at / resetAt, with the
same meanings as the headers — including the caveat that they describe the
binding constraint, which may be the organization aggregate rather than this
key’s own ceiling. It is None / null until a metered call completes, and
stays at its last reading when a later response carries no headers: absence is
unknown, so the value is never silently cleared.
The alter CLI surfaces the same reading on its metered commands:
alter sdk-passthrough resolve-identity includes a rate_limit object in its
JSON output (null when the backend reported none), and
alter sdk-passthrough request prints an alter-rate-limit: line to stderr
alongside the provider’s own response headers.
Recovery: wait retry_after seconds and retry the same request. If scope is
api_key, slow this key down or spread load across keys; if organization,
every key in the organization shares one budget, so slowing a single caller
may not be enough — raise the ceiling or reduce aggregate load.
The typed scope field stays a plain string rather than a closed enum, so a
ceiling added in a later release does not become an unparseable response for an
application pinned to an older SDK. Both SDKs export the currently known values
as RATE_LIMIT_SCOPE_VALUES (the ordered values ip, api_key, organization,
provider_egress, outermost-first), so a handler can branch on the shared constant instead of a
hand-typed literal — and should treat an unrecognized value as
some ceiling was hit, never as malformed.
RateLimitError is raised the same way from every SDK surface, including the
managed-agent calls (agents.create(), agents.list(), …): the platform limit
meters every API-key-authenticated request, not only credential retrieval.
The SDKs absorb a rate limit instead of raising it only inside their two
polling loops. A poll already owns a deadline, and by the time it runs the user
may already have authorized — so raising there would strand a completed
authorization behind a transient throttle. The sign-in poll
(poll_auth_session / pollAuthSession, and authenticate()) treats a
throttle like any other transient response and retries at its own poll
interval until its timeout. The headless Connect poll (poll_connect_session
/ pollConnectSession, and the polling half of connect()) waits for the
interval the service asks for and keeps polling, surfacing
ConnectTimeoutError with reason "rate_limited" only if the entire timeout
is consumed. Every other method hands the caller the number to sleep.
The provider egress cap
Section titled “The provider egress cap”Some providers limit requests per client IP address. A call Alter sends to a
provider on an application’s behalf (a proxy_request call, or a call that
runs after an approval) leaves from network addresses that every Alter customer
shares, so such a provider counts all of Alter’s customers as one client. For
those providers Alter caps its combined traffic, across every customer, below
the provider’s own limit:
| Provider | Alter’s combined cap |
|---|---|
| Corrigo Enterprise | 40 requests in any 5 seconds (8 per second sustained) |
A call over the cap is not sent to the provider. The response is a 429 with
Retry-After and X-Alter-Rate-Limited-Scope: provider_egress:
{ "detail": { "error": "provider_egress_rate_limited", "scope": "provider_egress", "message": "Alter's shared request budget for this provider is in use: Alter sends it at most 40 requests per 5 seconds across all of its customers, to stay under the provider's per-IP rate limit. The request was not sent. Retry after 2 seconds.", "limit": 40, "window_seconds": 5, "retry_after": 2 }}Both SDKs raise it as RateLimitError with scope set to provider_egress.
Alter also refuses a call this way, with retry_after set to the window length,
when it cannot confirm how much of the shared budget is left, rather than risk
the provider blocking the address for every customer. Recovery: wait
retry_after seconds and retry. The budget is shared, so a call can be refused
even when this application sends few; spreading load across keys or
applications does not help.
The backoff ceiling
Section titled “The backoff ceiling”retry_after / retryAfter is capped, whether the value came from the
Retry-After header or from the response body. The documented recovery is to
sleep the value, and an unbounded number — from a malformed header, or from an
intermediate proxy that rewrote Retry-After — would park a worker for as long
as that number says with no way to recover.
The cap depends on which 429 it is, because the two describe different clocks:
| Error | Cap | Why |
|---|---|---|
RateLimitError | 3,600 seconds (one hour) | The platform’s own retry hint is bounded well below one hour. The larger SDK ceiling rejects corrupted or hostile guidance without clipping a legitimate platform response. |
QuotaExceededError | 2,678,400 seconds (31 days) | A quota rule’s window is a calendar period — minute, hour, day or month — and the response reports the longest window that is exhausted. A monthly quota legitimately means weeks. 31 days is the longest such window, so every real hint passes through untouched while a nonsensical value is still bounded. |
Honour the value you are given rather than a fixed sleep: on a monthly quota it is the difference between waking once and waking hundreds of times.
LastActiveKeyError
Section titled “LastActiveKeyError”Raised by agents.revoke_key() / agents.revokeKey() when revoking would leave the agent with zero non-revoked keys.
Recovery: mint a replacement first, deploy it, then retry the revoke. Or pass force=True / { force: true } to deliberately brick the agent.
AgentError family
Section titled “AgentError family”All inherit from BackendError. Each carries a stable code attribute (agent_not_found, agent_inactive, key_revoked, …). Switch on err.code (not on the message) when handling backend categories. KeyRevokedError and KeyAlreadyRevokedError deliberately share key_revoked; use the typed class when the distinction between authentication rejection and an invalid key-lifecycle transition matters.
Every backend-originated error also exposes the HTTP status as
status_code (Python) / statusCode (TypeScript). A 500/503 response with a
valid Retry-After header carries the bounded value in
details["retry_after_seconds"] / details.retry_after_seconds.
A 503 whose error is service_unavailable on an API-key- or
personal-access-token-authenticated call, or on minting a key, an agent key or
a personal access token, means Alter could not verify or issue credentials at
that moment. It is transient and says nothing about the credential itself: the
response carries Retry-After: 15, the SDKs raise BackendError with
status_code 503 and details["retry_after_seconds"] set, and the CLI retries
read commands after that interval on its own. Retry after the interval; do not
replace the key. The same code on request() or proxy_request() /
proxyRequest() with a 5-second interval and the message “Credential storage
temporarily unavailable” means the stored credential could not be read at that
moment; see credential-store outages.
AgentConcurrentUpdateError (agent_concurrent_update, HTTP 409) means a
managed-agent update used a stale expected_version / expectedVersion.
Fetch the current agent, recompute the full desired allowlist from that fresh
record, and retry with its version. Do not replay a stale scope payload:
scope updates replace the complete allowlist and could otherwise restore
access another operator removed.
| Error | Recovery |
|---|---|
InvalidKeyError | Replace the unknown/deleted key with a valid app or agent key. A key created before the September 2026 key-security upgrade also raises this, with an explanatory hint; it can no longer authenticate — create a new key (details). |
KeyExpiredError | Mint and deploy a key whose configured expiry is still in the future. |
KeyRotationExpiredError | Replace the rotated key with its active successor. |
KeyInactiveError | Replace the key or restore its supported active lifecycle state. |
KeyAppNotFoundError | Retry only after the owning application is restored; this normally indicates backend data corruption. |
AgentNotFoundError | Correct the agent id/name, or recreate an agent that no longer exists. Also raised by a call that names a target agent — Connect session creation (agent, delegated_agent_id / delegatedAgentId), the recovery-session helper and delegate() — when that agent is not an active agent of the app (details.error == "agent_not_found"), and by ANY credential call when the client’s caller identifier names no active managed agent (details.error == "caller_agent_unresolved") — there, fix the asserted caller identity (the agent may have been revoked). |
CallerAgentMismatchError | Use the agent bound to the key, or use a key bound to the asserted caller agent. |
CallerAgentResolutionError | Retry after details.retry_after_seconds; persistent failures require operator investigation. |
AgentNameExistsError | Choose another name, or revoke the existing active agent before reusing it. |
AgentConcurrentUpdateError | Fetch fresh state, recompute the complete desired allowlist, and retry with the fresh version. |
MeRequiresAgentKeyError | Call me() from an SDK instance using the agent’s own key; app-key callers should fetch the agent through the app namespace. |
KeyRevokedError, KeyAlreadyRevokedError | Mint and deploy a replacement key; a revoked key cannot return to an active lifecycle state. |
AgentInactiveError | Have an operator resume the agent, then retry. Raised by every call from a paused agent’s key — credential calls, list_grants(), delegate(), Connect session minting, key derivation, catalog reads — with deliberate exceptions: agent.me() keeps working so a paused workload can self-diagnose, and telemetry ingestion (span emission and the SDK’s automatic provider-call audit reporting) keeps flowing so pausing an agent never blinds its audit trail. Suspension is containment: a paused agent cannot enumerate its grants or acquire new access. |
AgentRevokedError | Recreate the terminally revoked agent and issue new keys. Same whole-surface reach as AgentInactiveError, though revoking an agent revokes its keys in the same operation, so the usual rejection after a revoke is KeyRevokedError; this class covers the narrow race where a key authenticated just before the revoke committed. |
KeyNotFoundError | Correct the key id and verify that it belongs to the targeted agent. |
LastActiveKeyError | Mint and deploy a replacement first, or explicitly force the revoke when bricking the agent is intended. |
AgentKeyLimitError | The agent is at its per-agent active-key cap. Revoke a key it no longer uses, then retry the mint — the cap counts non-revoked keys, so a revoke frees a slot immediately. |
AgentCannotMintSubagentsError | Use an app key for agent-management operations. |
IdempotencyKeyBodyMismatchError | Replay the original body with that idempotency key, or use a fresh key for the changed operation. |
IdempotencyKeyAgentRevokedError | Use a fresh idempotency key to create a new agent. |
IdempotencyKeyAgentInactiveError | Resume the cached agent, or use a fresh idempotency key to create another agent. |
Agent codes without typed SDK wrappers
Section titled “Agent codes without typed SDK wrappers”A few backend agent codes have no dedicated exception subclass. They are still stable contracts. Which class carries them depends on the call that produced them, not on the status:
- A code raised by a credential call —
request()/proxy_request()— on a 403 arrives asPolicyViolationError. Branch onerr.policy_error(Python) /err.policyError(TypeScript), the dedicated field for exactly this. - A code raised by an agent-management call arrives as a plain
BackendError, whatever its status.
In every case err.details['error'] (Python) / err.details.error (TypeScript) also carries the code, so a single branch on details handles the whole table uniformly.
details['error'] | HTTP | Surfaces as | Meaning |
|---|---|---|---|
agent_expected_version_required | 422 | BackendError | A direct request supplied scopes without expected_version. The published SDKs reject this as AlterValueError before the network; fetch the agent and pass its current version. |
agent_scope_not_allowed | 403 | PolicyViolationError | The agent key called a route whose target provider / OAuth scope / managed-secret provider slug is not in the agent’s scope allowlist. Widen the allowlist on the agent. The error does not name the scopes; the audit record of the refusal does. Open the denied event in the developer portal (Why this was denied) or run alter audit explain <trace-id> to see which check failed and the scopes the allowlist does not include. The allowlist is a ceiling, never a binding: a grant the agent holds no delegation for is the opaque not-found (GrantNotFoundError) on every surface, including revoke, whatever the allowlist says. |
legacy_managed_secret_name_rejected | 422 | BackendError | An agent create or update added an entry under the legacy managed_secrets allowlist key, which matches providers by display name. List each provider’s slug under managed_secret_slugs instead; err.details['hint'] / err.details.hint names the key. Entries an agent already stores under managed_secrets may be kept or removed. Nothing was saved. |
invalid_scope_constraint | 422 | BackendError | create_connect_session(..., agent=..., scope_constraint=[...]) named scope atoms outside every allowed provider’s effective scopes for the session — a delegation can only narrow, never widen. When only some providers are affected the session is created and scope_constraint_warnings names them instead — unless every provider the constraint fits is one the session dropped because the delegated agent’s capability allowlist cannot use it (see agent_allowlist_exceeded), which is refused the same way, since no consent could produce a delegation. Narrow the constraint to a subset of the provider’s scopes, or widen the app’s configured scopes. |
delegation_rule_widens | 422 | BackendError | delegate(rules=...) named a rule looser than one already on the chain: an operation_allowlist admitting something the chain’s allowlists do not, a quota above a chain quota of the same period, or a larger max_pending. Only those three are compared; this is an authoring check for those three types, and every rule still applies at runtime. A require_approval rule may also only name approvers that a require_approval rule already applying to the chain names: any other approver is refused with detail_reason approver_outside_chain, so an agent can never route an approval request to a person the operator or end user did not choose. The message never repeats an approver’s address. rule_index names the rule, message says why and detail_reason is the closed code. Nothing is delegated. |
delegation_rule_type_not_allowed | 422 | BackendError | delegate(rules=...) named a rule type an agent may not author, such as credential_minting. rule_index names the rule. Nothing is delegated. |
delegation_rule_invalid | 422 | BackendError | A delegate(rules=...) body failed validation for its type (including a rule that names an operation Alter has not reviewed by its bare id; the message lists the provider-qualified <provider>:<operation> names to use), or the child would pass a rule ceiling: detail_reason agent_rule_ceiling_reached when the delegating agent would hold more than 20 of its own rules on the child (so it can never use up the room the operator’s rules need), rule_ceiling_reached past the child’s 100 rules. rule_index names the rule, and is null for a ceiling. Nothing is delegated. |
delegation_label_taken | 409 | DelegationLabelTakenError | delegate(label=...) named a label another agent’s delegation to the same recipient, for the same provider or managed secret, already carries, in any status. See DelegationLabelTakenError. Nothing is delegated. |
agents_cannot_tag_grants | 403 | BackendError | An agent’s key (or an app key acting as an agent) called update_grant_tags() / updateGrantTags(). A grant’s tags are operator metadata; an agent sets tags only on a delegation it makes, through delegate(tags=...). Call with an app key. Nothing is written. |
grant_tags_changed | 409 | GrantTagsChangedError | update_grant_tags(..., expected_tags=...) found the grant’s tags no longer equal expected_tags. See GrantTagsChangedError. Nothing is written; current_tags in the body is the map the grant holds now. |
tag_operator_only | 403 | PolicyViolationError (grants), BackendError (agents.create / agents.update) | A tag match rule names a tag key this call sets, changes or removes, and the caller is not an operator: an API key needs agents:admin (agents) or grants:admin (grants, including a new grant’s tags from mint_grant(tags=...) or a Connect session’s tags), the dashboard and alter grants tag / alter agents update --tag need an organization admin (a personal access token also needs dashboard_grants:admin / dashboard_agents:admin), and an agent can never set such a key, through delegate(tags=...) or a Connect session it requests. A Connect session refusal is raised as a Connect error with this code. details["keys"] names the keys. Nothing is written. |
tag_in_use | 409 | BackendError | A tag match rule names a key this call changes or removes on an agent that holds active connections, or on a connection that has active delegations. Relabelling would move live access across the boundary; revoke those connections or delegations first. details["keys"] names the keys. Nothing is written. |
delegation_tag_not_writable | 422 | BackendError | delegate(tags=...) gave a key the child already carries a different value, or (on the wire) a null. A delegation only adds tags. details["key"] names the key. Nothing is delegated. |
invalid_tags | 422 | BackendError | A tag map or tag filter does not fit the grammar. The message names the key. |
idempotency_record_corrupted | 500 | BackendError | An idempotency replay pointed at an agent or key that no longer exists. Retry with a fresh idempotency key; the underlying corruption is operator-investigable. |
An agent key that calls any agent-management operation — including reading another agent’s record — is refused with AgentCannotMintSubagentsError (see the table above); use an app key for management calls and agent.me() for self-introspection.
Delegation request codes
Section titled “Delegation request codes”Creating a Connect session that delegates to an agent or asks a user for their own managed-secret key, approving it, and delegating onward with delegate() can be refused with these codes. no_eligible_grants, secret_not_found, secret_template_mismatch, binding_hosts_required and provider_contract_repair_required arrive as ConnectConfigError, agent_not_found as AgentNotFoundError, and repair_grant_not_found (HTTP 404) and grant_not_found as GrantNotFoundError. agent_allowlist_exceeded arrives as ConnectConfigError from Connect session creation and polling, and as BackendError from delegate(). delegated_agent_missing arrives as ConnectFlowError from polling. tag_mismatch arrives as PolicyViolationError from session creation and as ConnectFlowError from polling (with details['denied_by'] / details.denied_by, as on session creation). The rest arrive as BackendError. Switch on details['error'] (Python) / details.error (TypeScript); a failure raised while polling a Connect session carries the code at details['error_code'] / details.error_code instead. Only service_unavailable is transient; for every other code, retrying the same request gets the same answer.
details['error'] | HTTP | Raised by | Meaning | Recovery |
|---|---|---|---|---|
agent_cannot_delegate_to_other_agent | 400 | OAuth and managed-secret session creation with an agent’s own key | The request named a different active agent of the app as the delegation target. An agent’s key may request a delegation only for itself. | Omit the target (agent on OAuth; the Agent method for managed secrets sends none) so the session is for the calling agent, or create the session with an app key to name another agent. |
agent_requires_user_token | 400 | OAuth and managed-secret session creation | agent was set without a user token, so no user could consent to the delegation. | Pass the user’s JWT as user_token / userToken, or configure a user-token getter. |
user_token_required | 400 | Managed-secret session creation | The request carried no user token and named no agent, so there is no user to ask. The SDKs require user_token, so only a direct request receives it. | Pass the user’s JWT as user_token. |
repair_grant_not_found | 404 | Managed-secret session creation with repair_grant_id | The grant is not the user’s own key on this provider in a status a repair can bring back (gone, revoked, or another user’s or kind of grant); one answer for every miss. Raised as GrantNotFoundError. | Pass the grant_id of the user’s own key on the provider, or omit repair_grant_id to let the page ask for a key. |
delegated_agent_id_required | 422 | Managed-secret session creation on a backend older than the one these SDKs target | Older backends required an agent on every managed-secret session from a key bound to no managed agent. A current backend never sends it: with no agent, an app key asks for the application’s own use of the user’s key. The SDKs raise ServerFeatureUnsupportedError instead of passing it on. | Upgrade the backend, or name the agent. |
secret_not_found | 404 | Managed-secret session creation | provider names no active managed-secret provider of the app. A missing slug, another app’s slug and a disabled provider answer alike. | Pass the provider’s slug (the slug field of alter managed-secrets list --output json), not its template id. |
secret_template_mismatch | 422 | Managed-secret session creation with both provider and the deprecated template_slug | The provider provider names was not created from that template. A custom provider never matches. | Send provider alone. |
binding_hosts_required | 409 | Managed-secret session creation that would ask the user for their own key, from a key bound to no managed agent; the key step of the hosted page | The provider takes its API host from the key, and the application has set no binding host patterns, so no key could be accepted. | An administrator sets binding host patterns for the provider (alter managed-secrets set-end-user-key-setup --binding-host), then create a new session. |
provider_contract_repair_required | 409 | Managed-secret session creation that would ask the user for their own key, from a key bound to no managed agent; the key step of the hosted page | The provider’s stored contract is out of date, so a new key cannot be stored against it. | An administrator rotates the provider’s existing developer credential once, then create a new session. |
grant_limit_exceeded | 402 | Managed-secret session creation that would ask the user for their own key, from a key bound to no managed agent; the key step of the hosted page | Storing the key would create a grant, and the organization is at its plan’s grant limit. details.current_usage and details.limit carry the numbers. | Upgrade the plan or revoke grants no longer used. |
agent_not_found | 404 | OAuth and managed-secret session creation, and delegate() | The named agent is not an active agent of this app (unknown, paused or revoked). Raised as AgentNotFoundError. On session creation it is reported before the identity provider’s readiness is checked. | Correct the agent id or name, or resume the agent. |
no_eligible_grants | 409 | Managed-secret session creation with a key bound to no managed agent (an app key, including an Agent from App.get_agent() / App.getAgent(), or an agent-typed alter_ak_… key from API Keys) | Nothing the user could approve would reach the agent, so nobody could complete the session. Two cases: the user holds no grant on the provider and the agent’s allowlist or the provider’s delegation policy would refuse the delegation of a key they stored; or a deprecated template_slug-only request names no single provider and the user holds no grant it could use. A user who simply holds no grant is asked for their own key instead. No session was created. details['details']['reason'] / details.details.reason is no_grant, grant_expired, delegation_depth_exceeded, group_source_not_allowed or agent_not_allowlisted. A managed agent’s own key never receives it. | Fix the named cause (reasons table), then create a new session. |
service_unavailable | 503 | OAuth and managed-secret session creation with a user token; delegate() with rules | On session creation: the user token verified, but its user could not be synchronized at that moment (a transient lock or database fault); nothing was committed and no session was created. On delegate() with rules: the Alter instance that received the call already had too many delegations with rules in progress, from this application or in all, or no rule check freed up within a second (Retry-After: 1); ordinary bursts of a few delegations wait their turn instead, so this answer means an unusual load; nothing was delegated and the held grant is unchanged. Either way it arrives as BackendError with status_code / statusCode 503 and details['retry_after_seconds'] / details.retry_after_seconds from the Retry-After header. | Retry after the interval, with bounded backoff if it recurs; a delegate() retry is safe, since nothing was delegated. If it persists, make fewer delegations with rules in parallel. |
identity_provider_inactive | 409 | OAuth and managed-secret session creation with a user token | The app’s identity provider is disabled, so its users cannot be synchronized. BackendError with status 409 and no retry hint. | An administrator re-enables the identity provider. Retrying does not help until then. |
identity_group_name_ambiguous | 409 | OAuth and managed-secret session creation with a user token | Two groups of the app’s identity provider share a display name the token’s group claim names, so the user’s memberships cannot be resolved. BackendError with status 409 and no retry hint. | An administrator renames or merges one of the groups. Retrying does not help until then. |
invalid_origin | 400 | OAuth and managed-secret session creation | allowed_origin is not a single origin: it has a path, query, fragment or credentials, a wildcard host, is *, empty or has no scheme, uses http:// on a non-loopback host in production, or is longer than 300 characters. Managed-secret session creation formerly answered *, an empty value and a value without a scheme with a request-validation 422, and both session routes answered a value over 300 characters that way; they now return this code for them too. | Pass the page’s exact origin, such as https://app.example.com, or omit the parameter. |
agent_allowlist_exceeded | 422 | OAuth Connect session creation and completion (the provider callback, the confirmation screen, and approval of an account the user already connected); managed-secret delegation approval on the hosted Connect page; delegating from the Wallet; onward delegate() (OAuth and managed secrets) | The agent’s capability allowlist cannot use what the delegation would hand it, so every call the agent made through it with its own key would be refused (agent_scope_not_allowed). For OAuth that means the allowlist does not cover every scope the connection holds, or names the provider not at all; for a managed-secret provider, that it does not name the provider’s slug. Nothing was delegated. The refusal applies to every delegation to the agent, although at request time the allowlist is checked only for calls made with the agent’s own key: a call made with an application key, including through an Agent from App.get_agent() / App.getAgent(), is not checked against it. Where the detail is depends on the surface. On session creation and delegate(), details['details']['detail_reason'] / details.details.detail_reason names the check: provider_not_allowlisted, scopes_not_allowlisted, ceiling_empty (the scope_constraint leaves the agent none of the connection’s scopes; delegate() only — at session creation that case is invalid_scope_constraint) or grant_scopes_malformed for OAuth, managed_secret_not_allowlisted for a managed-secret provider. On an OAuth refusal details['details']['provider_id'] / details.details.provider_id names the provider, and details['details']['uncovered_providers'] / details.details.uncovered_providers is always present and lists every provider refused (provider_id and detail_reason, this one first). A failure raised while polling a Connect session — the allowlist was narrowed before the user finished — carries the code at details['error_code'] / details.error_code and the same details['details'] / details.details object (detail_reason, provider_id, uncovered_providers). The response never names the missing scopes; the audit log does (alter audit explain <trace-id>). OAuth session creation is checked before the user is sent to the provider: a provider the request names (in allowed_providers / allowedProviders, or as a required_scopes / requiredScopes key) that the agent cannot use refuses the session; when the request omits allowed_providers, a provider it does not name that the agent cannot use is dropped from the session instead, named in scope_constraint_warnings / scopeConstraintWarnings with an agent_allowlist: prefix and listed in dropped_providers / droppedProviders (provider_id / providerId and check), and the session is refused only when no provider remains. For OAuth, while a narrowing of the agent’s allowlist is pending, every check uses the narrowed allowlist, so a delegation that would stop working when the narrowing applies is refused now, and the message names when it applies. Renewing an OAuth delegation the agent already holds (re-consenting, approving again from the Wallet, or delegating again with delegate()) with terms that are narrower or the same is applied, not refused; only new terms that widen it (onward sharing newly allowed, a scope_constraint removed or widened, or a later or removed expiry) are checked. On the hosted Connect pages the user sees a message to contact the application administrator, and in the Wallet one to choose another agent or ask an administrator to enable it; neither shows the allowlist detail. | An administrator widens the agent’s capability allowlist (developer portal Agent Identity, or alter agents update --scopes with the agent’s full allowlist from alter agents show plus the missing scopes — --scopes replaces the whole allowlist), the application narrows the scopes it requests from the provider, or it passes a scope_constraint the allowlist covers; then start a new session. An allowlist that still names scopes the provider has since folded into a broader one (allowlist_folded_into in alter policy show-access --output json) is fixed by allowlisting the broader scope instead. Distinct from the runtime 403 agent_scope_not_allowed, which refuses a call an agent makes. |
grant_not_found | 404 | delegate() | The calling agent does not hold the grant, the held grant was revoked while the delegation was being made, or a held managed-secret grant’s secret no longer exists. Nothing was delegated. Raised as GrantNotFoundError; the message is fixed and names no internal id. | Use a grant id from the agent’s own list_grants() / listGrants(). A revoked grant, or one whose secret was deleted, must be delegated to the agent again. |
delegated_agent_missing | 409 | OAuth Connect completion (the provider callback, the confirmation screen, and approval of an account the user already connected); delegating from the Wallet | The agent the delegation was for was deleted, suspended or revoked after the session was created, so nothing was delegated to it. Polling raises ConnectFlowError with details['error_code'] / details.error_code set to delegated_agent_missing, whichever of those steps refused it. On the hosted Connect pages the user sees that the assistant is no longer available and is asked to contact the application administrator. In the Wallet’s New grant dialog the user sees that the agent is no longer available and is asked to choose another agent or create the grant without one; the dialog clears the agent and reloads the list of agents. Re-consenting to a delegation the agent already holds with terms that are narrower or the same is applied rather than refused. Session creation itself refuses an inactive agent with agent_not_found. | Resume the agent (a suspended one) or name an active agent, then create a new session. Retrying the same session cannot succeed. |
tag_mismatch | 403 | OAuth and managed-secret session creation that names an agent; OAuth Connect completion (the provider callback and fast-path approval); managed-secret delegation approval on the hosted Connect page; delegating from the Wallet | A tag match rule requires the agent and the new connection to carry the same value for a tag key, and they do not. Session creation refuses it when the session’s own tags set a value the agent does not carry and no connection the user already holds would give the delegation the agent’s value instead (a reused connection’s own tags win over the session’s, and a rule that excludes that connection does not apply to it) (PolicyViolationError, details['denied_by'] / details.denied_by with reason tag_mismatch and keys). An OAuth session judges each provider with that provider’s rules: a provider the request names (in allowed_providers / allowedProviders, or as a required_scopes / requiredScopes key) refuses the session, a provider it does not name is dropped instead, named in scope_constraint_warnings / scopeConstraintWarnings with a tag_match: prefix and listed in dropped_providers / droppedProviders with check tag_mismatch, and the session is refused only when no provider remains. A value the connection takes from a grant the user already holds is judged when the delegation is written, and polling then raises ConnectFlowError with details['error_code'] / details.error_code set to tag_mismatch, details['error'] / details.error set to policy_violation and the same details['denied_by'] / details.denied_by session creation carries. When a rule names a key the session’s tags leave unset and no connection the user could approve with is known to carry the agent’s value, the session is still created and warns now: a tag_match: entry in scope_constraint_warnings / scopeConstraintWarnings (OAuth) or warnings (managed secrets), naming the keys and the remedy: set the agent’s value in the session’s tags, or, for a key the agent does not carry, tag the agent first. A session an agent’s own key creates is judged without the user’s connections (session creation never tells an agent what the user holds), so it warns whenever the key is unset. The hosted pages (OAuth and managed secrets) and both Wallets tell the user to contact the application administrator, with the same policy_violation code and message and never the rule. A delegation whose application was deleted while the user was consenting is refused the same way, with denied_by.detail_reason app_unresolved and no keys. Nothing was delegated. | An operator gives the agent and the connection the same value for the key (alter agents update --tag, alter grants tag), or excludes the agent from the rule, then start a new session. |
delegation_methods_exceed_parent | 422 | Delegating from the Wallet with Allowed request methods | The user asked to let the agent use an HTTP method their own access does not allow. A delegation can only narrow the methods it hands on. Nothing was delegated. The user sees this in the Wallet; it is not sent to the application. | Choose only methods the user’s access allows (the dialog offers exactly those after it reloads). |
Approval errors
Section titled “Approval errors”| Error | Meaning | Recovery |
|---|---|---|
ApprovalDeniedError | Approver clicked Deny. | The safe decision reason is the exception message; surface it to the requester. Use approval_id for correlation. |
ApprovalExpiredError | Window elapsed with no decision made — or the request can no longer run because the managed-secret provider it waited on was deleted, in which case the approval’s decision_reason names the deletion. | Re-issue the call to create a new approval; after a deletion, the call needs a grant on another provider. |
ApprovalTimeoutError | SDK gave up waiting; the approval may still be pending. | Persist approval_id and re-poll. A transient polling failure is preserved as the exception cause. |
ApprovalExecutionFailedError | Approved, but the eventual provider call failed. One cause is credential_slot_changed: after approval the grant’s credential settings started filling a header or query parameter the approved request sets, so it cannot run as approved. Another is provider_outcome_unknown: the call may have reached the provider and was not sent again (at most once). | Inspect the safe message, which prefers the execution error, fix the underlying grant/policy/provider failure, and re-issue the call. When the message starts provider_outcome_unknown:, first check the provider for the call’s effect, and re-issue it only if it was not applied. |
ApprovalError.details contains the approval_id when one is available; it
does not contain the decision or execution reason.
An approved call whose provider response is too large to return whole ends
executed, and reading its result raises ProviderResponseTooLargeError (not an
ApprovalError) with the provider’s status code and headers and the approval_id.
The approved call ran: do not re-issue it to recover. A call that needs the full
response uses proxy_stream_request() / proxyStreamRequest(), which cannot wait
for approval.
Approval creation refusals
Section titled “Approval creation refusals”Before an approval exists, the request that would create it can be refused with
a typed status. These arrive as BackendError (not an ApprovalError — there
is no approval_id yet); switch on details["error"] / details.error:
error | Status | Meaning | Recovery |
|---|---|---|---|
too_many_pending_approvals | 429 | The grant is at its pending-approval cap. | Wait for existing approvals to be decided or expire; the response carries Retry-After. |
approval_config_error | 422 | HITL is enabled but no approver can be resolved — for example, an OAuth approval rule with no approvers on a connection no end user connected, or a managed-secret grant with no approvers. | The app administrator names an explicit approver on the approval rule; retrying does not help. |
credential_slot_in_request | 422 | The request sets a header or query parameter where Alter places the grant’s credential (details["fields"] / details.fields names each one, such as query.api_key or header.x-tenant-token). The approver could never see that value, so no approval was created. | Remove those fields; Alter supplies the credential after approval. (A call that does not require approval is not refused: those fields are removed before the credential is added.) |
approval_request_unsupported | 422 | The approver could not be shown this request in full, so its approval could never be approved. Applies to a request no operation catalog describes, where the approver sees every value in full, however long and however many: at most 1,000,000 characters of field names and values together (counted on the values themselves, not their display; a query value shown in its encoded form is counted on what it decodes to), nesting at most 32 levels, no two fields shown under the same name, and header names that are HTTP tokens. details.field_detail is always present and names the field and the reason, never a value. For a catalogued operation it applies whenever the operation’s parameters cannot be read because of the request itself: a body that is not a JSON object, a Content-Type the operation is not read from, or a field that is missing or of the wrong type. No approval was created. (If the catalog itself cannot read an operation, whatever is sent, the approval is still created and the Wallet marks it not approvable.) | Send a request within those bounds, or one that has the shape the operation expects, or ask the administrator to route the operation without approval. |
sensitive_payment_input_requires_token | 422 | The request carries raw card data, so no approval was created. Raw card data is a card security code or card-number field anywhere in the input; a card object (a number beside an expiry, a security code or object: card, under any field such as card, source or external_account); a card holding a number, network token, track data or an encrypted card; the same as form fields such as card[number]; or any of these in the query. Alter never holds raw card data for an approval on a managed provider, even encrypted. Stripe returns sensitive_input_not_retained for raw card data instead, the code it has always returned. A managed operation raises it as ManagedOperationError with this code. Earlier releases also returned this code for QuickBooks bank account and routing numbers; those requests are now held for approval and masked. | Send the provider’s card token or card-on-file reference instead of the card fields, or ask the administrator to route the operation without approval. |
sensitive_input_not_retained | 422 | Alter could not classify the request’s input, so it could not find the sensitive values to mask for the approver: a URL or query string that cannot be parsed, a body that is neither JSON, form nor multipart on an operation with reviewed sensitive fields, or form fields that contradict each other (owner=x beside owner[ssn]=...). On Stripe it also means raw card data, which is never held for an approval. No approval was created. A managed operation raises it as ManagedOperationError with this code. This code no longer fires for classified sensitive fields (passwords, tax and national ids, bank and routing numbers, dates of birth, files, secrets): those requests are held for approval and masked, see Sensitive input in approvals. | Send the input as JSON, form or multipart data, or ask the administrator to route the operation without approval. |
invalid_url | 400 | Alter cannot send the request URL (for example, a host name that is not a valid internationalized domain name). Every proxied call with such a URL is refused with this error, whether or not it requires approval, before quota, policy, credential or approval work (see invalid_url for the full order), so no approval is created. | Fix the URL; retrying it unchanged gets the same answer. |
approval_payload_too_large | 413 | The request is too large to hold for approval on this deployment; nothing was created and nothing was sent. Typed as ApprovalPayloadTooLargeError, with limit_chars / limitChars naming the largest request the deployment can hold. | Send a smaller request, or send a file with proxy_upload_request() / proxyUploadRequest(), whose bytes are delivered after the approval instead of held. Retrying unchanged gets the same answer. |
approval_freeze_failed | 503 | The request payload could not be captured for the approver; nothing was created. | Transient. Retry after Retry-After (details.retry_after_seconds). |
approval_creation_contended | 503 | Approval creation for this grant was contended and timed out; nothing was created. | Transient. Retry after Retry-After (details.retry_after_seconds); the retry is safe because no approval was persisted. |
Both 503s are safe to retry as-is: the refusal happens before any approval row or approver notification exists, so a retry can never duplicate an approval.
Server SDK Connect flow errors
Section titled “Server SDK Connect flow errors”These exceptions belong to the Python and TypeScript server SDKs’ headless Connect helpers. They are not exported by the browser Connect package.
| Error | Meaning | Recovery |
|---|---|---|
ConnectFlowError | Generic flow failure, including an unavailable/expired token on the first poll, an unknown terminal state, a total usage-limit application failure, or an agent the session delegates to that was suspended, revoked or deleted before the user finished (details["error_code"] / details.error_code is delegated_agent_missing). | Inspect the safe message. For a total usage-limit failure, inspect details["failed_grants"] / details.failed_grants. An unavailable first poll deliberately does not disclose whether the session existed; create a fresh session. For delegated_agent_missing, create a new session for an active agent. |
ConnectDeniedError | The user refused authorization and the session had nothing left to try. A session that can still continue — two or more allowed providers, a grant already authorized in this session, or an account the user has already connected and can still approve — returns the user to the provider picker and stays pending instead, so this is not raised. | Respect the decision; start another flow only when the user chooses to retry. Sessions that can still continue end in a later terminal state, or in ConnectTimeoutError if the user abandons the flow. |
ConnectConfigError | OAuth client is misconfigured (wrong redirect URI, invalid client ID/secret), fresh provider authorization is unavailable (provider_configuration_unavailable / shared_dev_credential_unavailable), the scopes the app requests exceed what Alter’s managed OAuth client is approved for (managed_oauth_scope_approval_required), or — on managed-secret session creation — provider names no active managed-secret provider of the app (secret_not_found, or secret_template_mismatch beside a deprecated template_slug), the app’s identity provider cannot sign users in to approve (idp_signin_not_configured) or, for a key bound to no managed agent, the provider cannot accept a user’s key yet (binding_hosts_required, provider_contract_repair_required) or the session could never be completed (no_eligible_grants), or — on OAuth session creation with agent or on an agent’s own key with a user token, and when polling that session — the delegated agent’s capability allowlist cannot use what the user would grant (agent_allowlist_exceeded), or the application’s saved scope selection for a provider names only scopes the provider folded into a broader one (connect_scope_revoked with the reason retired_selection_requires_reselection, HTTP 409 on OAuth session creation for a reconnect or switch-account session that names the provider, or that names none and has no other provider able to start a new authorization, or for any session whose required scopes pin the provider only to retired scopes; and when polling once a new authorization starts). | For a misconfiguration or an unavailable provider, ask the app administrator to correct the provider configuration or availability, then create a fresh session. For managed_oauth_scope_approval_required the app administrator cannot fix it: the approval ceiling sits on Alter’s managed OAuth client, and the Dev Portal offers only the already-approved scopes. Contact Alter to have the requested scopes approved, or narrow the app’s configured scopes to the approved set, and only then create a fresh session. For idp_signin_not_configured, read the reason at details["details"]["reason"] / details.details.reason: missing_client_id or missing_client_secret — the app administrator adds the sign-in client ID and secret to the identity provider; issuer_cannot_sign_in — the administrator switches to an issuer that supports OpenID Connect sign-in (for WorkOS, the AuthKit issuer https://<slug>.authkit.app). Both responses carry retryable: false — every fresh session fails identically until the configuration changes. For no_eligible_grants, read the reason at details["details"]["reason"] / details.details.reason and fix that cause (Delegation request codes) before creating a new session. For secret_not_found / secret_template_mismatch, pass the provider’s slug as provider. For binding_hosts_required / provider_contract_repair_required, an administrator sets the provider’s binding host patterns, or rotates its developer credential once, before a new session can succeed. For agent_allowlist_exceeded, read the check at details["details"]["detail_reason"] / details.details.detail_reason (on a create-session failure and on a poll failure, where the code is at details["error_code"] / details.error_code); 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 (Delegation request codes). For retired_selection_requires_reselection (at details["details"]["reason"] / details.details.reason on a create-session failure, details["error_reason"] / details.error_reason on a poll failure), an administrator re-selects the provider’s scopes in the Developer Portal or with alter providers update --scopes; the create-session 409 alone names the broader scopes in details["details"]["broader_successors"] / details.details.broader_successors. |
ConnectTimeoutError | Alter observed a pending session but received no completion callback before the local deadline or server expiry. details["reason"] / details.reason is "poll_deadline_elapsed", "session_expired", or "rate_limited". | Re-poll the same token after a local deadline while the server session remains valid; create a fresh session after server expiry. A provider may have kept an error on its own page, the browser may have closed, or the user may have abandoned the flow; without a callback Alter cannot truthfully name which one occurred. 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. For "rate_limited" the authorization may well have succeeded — re-poll the same token with a fresh timeout, and raise the key’s per-minute limit if Connect flows run concurrently. |
Browser Connect SDK errors
Section titled “Browser Connect SDK errors”@alter-ai/connect exports the AlterError interface, not exception classes:
interface AlterError { code: string; message: string; details?: Record<string, unknown>; failedGrants?: ConnectFailedGrant[];}Two launch-time codes are specific to the inline (embedded) flow and reject the open() promise rather than reaching onError: invalid_container (the container option is not an element attached to the document) and embed_unsupported_origin (the host page has no http(s) origin, or is itself inside an iframe). One inline flow code reaches onError: embed_load_timeout, when the frame delivers no message within 15 seconds of mounting. See the Connect SDK types reference.
Flow failures arrive through onError and the error event. Branch on
error.code, never message. The browser SDK’s own current codes are
popup_blocked, redirect_error, invalid_oauth_url, invalid_response,
embed_load_timeout, grant_policy_application_failed, and
grant_activation_failed; errors posted by
the hosted flow preserve their server-supplied code, so that set is
intentionally open. In inline mode the hosted page posts its bind refusals with
embed_origin_mismatch, embed_not_allowed, session_expired,
embed_verify_failed, or cookies_required, and renders the error in place; a
409 embed_mode_conflict (the session already continued in a new window) is
not an error, and the widget offers that window again.
- For
connect_denied, respect the provider decision. This code is terminal only when the session has nothing left to try — which includes a multi-provider picker whose every offered provider the user has now declined; a session that can still continue returns to the picker instead of emitting an error, and reports the refusal as a non-terminalprovider_declinedevent so the application still learns about it without the Connect UI closing. Server-side pollers observe the same refusals:poll_connect_session()/pollConnectSession()accept anon_event/onEventcallback fired per declined provider, and a timeout after denials lists them inConnectTimeoutError.details. A provider failure that was not a refusal — an outage, a rotated client credential — reports asprovider_erroron that same channel, so do not treat every non-terminal notice as a user decision. - For
popup_blocked, ask the user to allow the popup and retry. - For
embed_load_timeout, the inline frame never reported in: confirm that the host page’s origin equals the session’s allowed origin, that the page is not itself inside an iframe, and that the Alter host is reachable, then mint a fresh session and retry. - For an inline bind refusal (
embed_origin_mismatch,embed_not_allowed,session_expired,embed_verify_failed,cookies_required), the widget has already rendered the error in place; mint a fresh session with the correctallowedOriginrather than reopening the same one. - For
redirect_error, restore browser storage access and retry. - For
invalid_oauth_urlorinvalid_response, stop and report the malformed flow rather than treating it as success. - For
grant_policy_application_failed, inspectfailedGrants. A partial completion is not an error: it arrives throughonSuccess, with failures incompletion.failedGrants. - For a managed-secret session that asked the user for their own key, the
page shows most problems in place and lets the user try again (a key the
provider rejects, malformed fields, at most five attempts). It reports an
error to the application only when the session cannot continue:
key_attempts_exhausted(five keys refused),secret_not_found,binding_hosts_required,provider_contract_repair_required,no_eligible_grantsorgrant_limit_exceeded(the provider or the organization changed after the session was created),end_user_key_exists(the user already holds a key for this provider, for example one stored in another session first: a user holds one key per provider),provider_changed(the provider’s configuration changed after the key was checked),grant_not_found(the key a repair would replace is gone),sibling_label_conflict, orinvalid_policy_draft. Each means nothing was stored; create a new session once the cause is fixed. - For
grant_activation_failed, no usage limit was at fault: every selected connection could not be completed when the user confirmed it (for example, the same account was connected again in a newer Connect session). Start a new connection. Server-side, the same outcome raisesConnectFlowErrorwithdetails.error_codeset togrant_activation_failed;grant_policy_application_failedis the usage-limit counterpart.
Calls rejected at the local lifecycle boundary use Error objects with a
code: invalid_options means fix the open() arguments, while
sdk_destroyed means create a new SDK instance. Passing the reserved
baseURL configuration throws a plain Error without an AlterError code;
omit that field. Popup closure is an onExit transition, not an error. See the
complete browser code and delivery table
and callback guarantees.
CLI exit contract
Section titled “CLI exit contract”The alter CLI is an executable surface, not an exception-class API. Scripts
branch on its stable process status and use stderr only for diagnostics. The
CLI scripting reference is the
language-specific source of truth.
| Status | Name | Recovery |
|---|---|---|
0 | OK | Continue; the command succeeded. |
1 | ERROR | Inspect stderr; fix the reported runtime/server problem or retry a transient network failure. |
2 | USAGE | Correct the flag, argument, configuration, or input format. |
3 | AUTH | Run alter auth login to replace a missing, expired, or revoked PAT. |
4 | NOT_FOUND | Correct the resource identifier or handle absence as an expected script branch. |
5 | CONFLICT | Reconcile the current resource state or confirmation requirement, then retry. |
6 | RATE_LIMIT | Retry with backoff. |
7 | FORBIDDEN | The request was authenticated but refused (HTTP 403), and the printed message says why. The causes include: the PAT lacks a required explicit scope (re-mint or select one that has it — signing in again with the same scopes does not help); the organization’s plan does not include the feature (upgrade the plan); the route is admin-only and the token’s owner is not an organization admin (have an admin run it); or the target belongs to an end user — grant_user_owned / credential_user_owned, an end user’s own managed-secret key or a delegation the user consented to, which you can revoke but not change (see User-owned managed-secret grants); or the approval was required by the end user’s own rule (approval_requires_end_user), which only that person can decide, in the Wallet. |
8 | CANCELLED | Treat the operation as not performed; in automation, supply the command’s documented confirmation flag. |
75 | BUSY | Nothing was saved or applied because a concurrent change held a lock. Retry the same command unchanged, with backoff; after a busy policy apply, do not re-plan or edit the plan file. |
Recovering from missing-grant errors
Section titled “Recovering from missing-grant errors”When a request fails because the user hasn’t authorized the provider yet, the SDK exposes recovery context on the typed error so a re-consent flow can be driven without manual derivation:
NoDelegatedGrantErrorcarriesprovider_id/agent_id/app_user_id(camelCase in TypeScript).GrantNotFoundErrorcarriesprovider_id/agent_id/app_user_idwhen the raise was identity-mode.GrantExpiredErrorcarriesprovider_id/agent_id/app_user_idwhen the expiry was raised on the delegation path (a TTL-lapsed delegation chain); the root-path TTL expiry leaves them unset.CredentialRevokedErrorcarriesprovider_id/app_user_id(noagent_id— credential revocation is grant-scoped, not agent-scoped).
For CredentialRevokedError, the recovery helper also carries the error’s
grant_id as the Connect repair target. Reconnecting the same provider account
replaces the broken shared credential, preserves the existing connection instead
of adding a duplicate, and reports operation="reauth" (operation: "reauth" in
TypeScript). Sibling connections sharing that credential pick up the replacement
on their next call.
Repairing a specific connection is an optimization, not a requirement. An error
raised by a backend predating this contract carries no connection id, so the
helper names no target and mints an ordinary session. Pass
user_token (userToken) so the session can address a connection that belongs to
an end user — without it only application-owned connections are addressable. If the
named connection is rejected when the session is created — it is not addressable by
this caller, or it is no longer active — the helper falls back to an ordinary
Connect session, so reconnecting always remains possible. That fallback session
usually reports operation="creation", but it follows the standard rules, so it
still reports operation="reauth" if it ends up restoring an existing connection
for the same account.
One connection shape is not repaired in place by an ordinary reconnect: a connection whose default grant is currently delegated to an agent. Reconnecting it without naming a target restores the connection but returns a new connection id, because silently re-pointing a handle an agent is actively delegating from would change that agent’s access rather than repair anything. Passing the error to the recovery helper (which names the target explicitly) preserves the id in that case too — another reason to prefer it over an unaddressed reconnect.
The fallback covers rejection at session creation only. If the named connection is accepted and then stops being active before consent completes, the flow fails rather than quietly connecting something else.
Reconnecting must use the same provider account. If a different account authorizes, or the provider returns no verifiable account identity, the session fails rather than silently rewriting the credential behind the existing connection.
Python
from alter_sdk import PendingApprovalfrom alter_sdk import NoDelegatedGrantError
try: await app.proxy_request(provider="slack", user_token=jwt, url=..., method=...)except NoDelegatedGrantError as e: # 1. Mint a recovery Connect session using the error's context. session = await app.create_connect_session_for_error( e, allowed_origin="https://app.example.com", ) # 2. Surface the URL to the user. redirect_user(session.connect_url) # 3. Poll until consent completes. results = await app.poll_connect_session(session.session_token) # 4. Retry with the freshly-minted grant_id. response = await app.proxy_request(grant_id=results[0].grant_id, url=..., method=...) if isinstance(response, PendingApproval): for gate in response.gates: print("Approval required:", gate.approval_url) response = await app.await_approval(response.approval_id)TypeScript
import { HttpMethod, NoDelegatedGrantError } from "@alter-ai/alter-sdk";
try { await app.proxyRequest({ method: HttpMethod.GET, url: "...", provider: "slack", userToken: jwt });} catch (e) { if (e instanceof NoDelegatedGrantError) { // 1. Mint a recovery Connect session. const session = await app.createConnectSessionForError(e, { allowedOrigin: "https://app.example.com", }); // 2. Surface the URL. redirectUser(session.connectUrl); // 3. Poll until consent completes. const results = await app.pollConnectSession(session.sessionToken); // 4. Retry. let response = await app.proxyRequest({ method: HttpMethod.GET, url: "...", grantId: results[0].grantId, }); if ("status" in response) { for (const gate of response.gates) { console.log("Approval required:", gate.approvalUrl); } response = await app.awaitApproval(response.approvalId); } } else { // Re-throw every other error class — silently swallowing // NetworkError, BackendError, or programming bugs would hide // the real failure. throw e; }}When recovery context is available
Section titled “When recovery context is available”| Error | Identity-mode raise (carries context) | Direct-mode raise (context is None) |
|---|---|---|
NoDelegatedGrantError | Agent-runtime resolution with provider= + optional user_token= | n/a — always identity-mode |
GrantNotFoundError | Identity-mode lookup by (user, provider) failed | Caller passed an explicit grant_id= that doesn’t exist |
CredentialRevokedError | Token refresh hit a permanent failure (provider revoked, refresh token expired), or a provider session that issues no refresh token ended (provider_session_ended) | n/a: always carries a grant_id |
GrantExpiredError | Delegation-chain TTL expiry can carry provider/agent/user context | Root-path TTL expiry leaves recovery context unset |
create_connect_session_for_error / createConnectSessionForError accepts
NoDelegatedGrantError, GrantNotFoundError (including its agent subclass),
and CredentialRevokedError. It raises AlterValueError when required
provider context is unavailable, and also when NoDelegatedGrantError lacks
its required agent context. For direct-mode GrantNotFoundError (a stale
grant_id), call create_connect_session /
createConnectSession directly with the correct provider. GrantExpiredError
exposes recovery context on delegation-chain failures but is not accepted by
the convenience helper; use the explicit session-creation method when
re-consent is appropriate.
What recovery does NOT cover
Section titled “What recovery does NOT cover”AmbiguousGrantError— surfacecandidates(each carries agrant_id, the universal disambiguator) to let the user or agent pick, then retry with the chosengrant_id. Checkcandidates_truncatedbefore telling a user their grant is missing: when it is true every disambiguator on the error (candidates,account_identifiers,app_user_ids,grant_ids) is a bounded sample, and the right move is to narrow the request or list grants rather than report “not found”. For the OAuth account flavor,account_identifiers+account=and, for the agent flavor,app_user_ids+user_token=are alternates — and the only usable disambiguators when account/user fields are empty are thegrant_ids incandidates. Minting a new session would be the wrong remediation here.
Blocked destination
Section titled “Blocked destination”BlockedDestinationError is a BackendError subclass raised when a proxy call’s
destination fails the provider’s host/path allowlist or the network security
check (HTTP 422). It is also raised for a route the provider’s reference page lists as refused on every
connection (Notion’s Admin API, for example); that route stays refused, so use the
provider’s public API instead. When a call held for approval is refused as the approved
call executes, the approval wait raises ApprovalExecutionFailedError instead.
Correct the host or URL; retrying the same destination will not fix a policy refusal. Read
details["error"] / details.error for blocked_destination and
details["request_id"] / details.request_id for the response correlation ID
when available. The exception preserves HTTP status without disclosing resolved
private addresses. With the destination allowlist enforced (the default), the
allowlist is checked before any DNS lookup: a host outside the grant’s allowed
hosts is refused with blocked_destination without being resolved, so the two
DNS codes below are only ever returned for a host the call may reach. A host
name that does not exist remains a separate
dns_resolution_failed diagnostic (HTTP 400, a plain BackendError; correct
the host), and a resolver that timed out or failed temporarily is the
retryable 503 dns_resolution_timeout.
No provider HTTP request was made in any of these cases.
An end user’s own managed-secret key
on a provider whose host comes from the key is also held to the application’s
current binding host patterns on every call: after an administrator narrows or
clears them, a proxied call to a host they no longer allow is refused with
blocked_destination until a pattern allows it again. The key itself is kept.