agent resource granularity and your users at the session resource granularity.
Managed Agents API requests require the
managed-agents-2026-04-01 beta header, except memory store endpoints, which use agent-memory-2026-07-22 instead. The SDK sets the correct beta header automatically. See Beta headers.Create a vault
A vault is the collection ofcredentials associated with an end user. Give it a display_name and optionally tag it with metadata so you can map it back to your own user records.
Add a credential
Two credential categories are supported:- MCP credentials (
mcp_oauth,static_bearer): each credential is keyed by anmcp_server_url. When the agent connects to a server at that URL at session runtime, the token is injected automatically. - Environment variables (
environment_variable): each credential is keyed by asecret_name(the environment variable name) and stored in the sandbox as an opaque placeholder. When the agent initiates an outbound request, the opaque placeholder is substituted with the real secret at egress. The agent never sees the secret value. Use this for any service that authenticates through an environment variable, such as CLIs, SDKs, or direct API calls.
token, access_token, refresh_token, client_secret, secret_value) are treated as sensitive, write-only fields and never returned in API responses.
Environment variable credentials (
environment_variable) are not yet supported with self-hosted sandboxes.- MCP OAuth
- MCP static bearer
- Environment variable
Use
mcp_oauth when the MCP server uses OAuth 2.0. If you supply a refresh block, OMA refreshes the access token on your behalf when it expires.The refresh.token_endpoint_auth.type field indicates how to authenticate the refresh call:none: public clientclient_secret_basic: HTTP Basic authentication with the client secretclient_secret_post: client secret in the POST body
- Unique key per vault.
mcp_server_url(MCP credentials) andsecret_name(environment variable credentials) must be unique among active credentials in a vault. Creating a duplicate returns a 409. - Keys are immutable. To change
mcp_server_urlorsecret_name, archive the credential and create a new one. - Maximum 20 credentials per vault.
Reference the vault at session creation
Passvault_ids when creating a session:
- When no MCP credential matches by
mcp_server_url, the connection is attempted unauthenticated and will error if the server requires authentication. - When multiple vaults contain a matching credential, the first vault with a match wins.
- In multiagent sessions, vault credentials apply to every thread. An agent whose own definition declares the matching MCP server authenticates with these credentials. See Connect agents to MCP servers.
Rotate a credential
Secret values,display_name, and (on environment variable credentials) injection_location can be updated. injection_location updates merge per field, as described in the Environment variable tab of Add a credential. For a running session, an injection_location update propagates the same way as a secret rotation: the session’s credentials are re-resolved without a restart, as described in Credential lifecycle, and the updated locations apply to the session’s subsequent outbound requests. Structural fields (mcp_server_url, secret_name, token_endpoint, client_id) are locked after creation. To change them, archive the credential and create a new one.
Credential lifecycle
Credentials are re-resolved periodically, both during a session and during the vault lifecycle. This ensures that credential rotation, archival, or deletion propagates to running sessions without a restart. To be notified if a credential is archived, deleted, or fails to refresh, you can subscribe to the vault and credential webhooks associated with those lifecycle changes.This is a non-exhaustive list of webhooks; see Subscribe to webhooks for the complete list.
mcp_oauth credentials, re-resolution also refreshes the access token if it has expired. If the refresh fails, a vault_credential.refresh_failed event is emitted.
Diagnose an OAuth refresh failure
To diagnose why a refresh failed, callPOST /v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate (or client.beta.vaults.credentials.mcp_oauth_validate(...) in the SDK). This lets you decide how to handle the failure; the right action depends on the error type.
The top-level status tells you what to do next:
valid: the token works; no action needed.invalid: the grant is gone or the OAuth server rejected the refresh with a 4xx. Prompt the end user to re-authorize.unknown: a transient error (5xx, 429, or network failure). Wait and retry.
vault_credential_validation object. mcp_probe includes the failed MCP handshake step; refresh includes the outcome of the attempted refresh.
Other operations
- List vaults or credentials: Paginated, newest first. Archived records are excluded by default (pass
include_archived=trueto include them). - Archive a vault:
POST /v1/vaults/{id}/archive. Cascades to all credentials. Secrets are purged; records are retained for auditing. Future sessions referencing this vault fail; running sessions continue. - Archive a credential:
POST /v1/vaults/{id}/credentials/{cred_id}/archive. Purges the secret payload; the credential key (mcp_server_urlorsecret_name) remains visible and is freed for a replacement credential. - Delete a vault or credential: Hard delete. The record is not retained. Use archive if you need an audit trail.