Vaults and credentials are authentication primitives that let you register credentials for third-party services once and reference them by ID at session creation. This means you don't need to run your own secret store, transmit tokens on every call, or lose track of which end user an agent acted on behalf of.
The vault reference is a per-session parameter, so you can manage your product at the agent resource granularity and your users at the session resource granularity.
A vault is the collection of credentials 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.
VAULT_ID=$(ant beta:vaults create \
--display-name "Alice" \
--metadata '{external_user_id: usr_abc123}' \
--transform id --raw-output)
echo "$VAULT_ID" # "vlt_01ABC..."The response is the full vault record:
{
"type": "vault",
"id": "vlt_01ABC...",
"display_name": "Alice",
"metadata": { "external_user_id": "usr_abc123" },
"created_at": "2026-03-18T10:00:00Z",
"updated_at": "2026-03-18T10:00:00Z",
"archived_at": null
}Two credential categories are supported:
mcp_oauth, static_bearer): each credential is keyed by an mcp_server_url. When the agent connects to a server at that URL at session runtime, the token is injected automatically.environment_variable): each credential is keyed by a secret_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.The actual credential values you supply (token, access_token, refresh_token, client_secret, secret_value) are treated as sensitive, write-only fields and never returned in API responses.
Use mcp_oauth when the MCP server uses OAuth 2.0. If you supply a refresh block, Anthropic 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 bodyCREDENTIAL_ID=$(ant beta:vaults:credentials create \
--vault-id "$VAULT_ID" \
--display-name "Alice's Slack" \
--transform id --raw-output <<'YAML'
auth:
type: mcp_oauth
mcp_server_url: https://mcp.slack.com/mcp
access_token: xoxp-...
expires_at: "2099-12-31T23:59:59Z"