client.agent_vault.sessions.create() creates a session, which lets an AI agent use the services in an access bundle, the inline services sent with the session, or both. Admins can create sessions with any access bundle, and members with the access bundles granted to them.
Parameters
The ID of the Agent Vault project to create the session in.
The name of the access bundle that the agent can use during the session (pass
access_bundle, services, or both).Inline services to send with the session (Agent Vault admins only, up to 30).
How long the session lasts, as a duration of at least one minute such as
30m, 8h, or 7d, or as never for a session that doesn’t expire (defaults to 7d, or to 1h for a session on behalf of a user).A short description of what the session is for, such as
nightly deploy (up to 128 characters, without line breaks, tabs, or invisible characters).Key/value pairs that say who or what the session is for, such as a run ID or ticket (up to 20 keys, each key up to 255 characters and each value 1 to 1020, without line breaks, tabs, or invisible characters, and no
= in a key).The email address of the user that the session is created on behalf of (raises a
ValueError if you also pass on_behalf_of_user_id).The ID of the user that the session is created on behalf of (raises a
ValueError if you also pass on_behalf_of_user_email).Returns
The new session, with the session token in
token (Infisical returns the token only once).session.token to the agent, follow the steps in Start the agent.
Create a session on behalf of a user
If the client logs in as a machine identity with a delegation, the client can create sessions on behalf of the users that the delegation covers. For each of those sessions, the proxy uses the user’s personal values instead of the machine identity’s.- The session can use an access bundle only if both the user and the machine identity can use the bundle
- The session belongs to the machine identity, so the user can’t see the session unless they’re an Agent Vault admin
- In each session that the
get,list,update, andrevokemethods return,onBehalfOfis the user, orNoneif the session is the machine identity’s own
access_bundles.list. The proxy refuses a session’s requests to services that still need the user’s personal values, so also pass requires_setup=False to leave out the access bundles with those services.
Create a session with inline services
If the client logs in as a user or machine identity with the Admin role in the Agent Vault project, the client can send inline services with a session, instead of or beside an access bundle. Inline services let you pass along credentials that your code already holds, without setting anything up in Agent Vault in advance.- Each service is a dictionary that describes an HTTP API (
"type": "http"), an MCP server ("type": "mcp"), or a database or SSH server ("type": "postgres","mysql", or"ssh") - The dictionaries use the API’s field names, such as
hostPatternrather thanhost_pattern - Credentials, custom header values, and substitution values can’t contain text in double braces, such as
{{GITHUB_TOKEN}}, because inline services can’t use variables - A session can have up to 30 inline services, and no two of its services can have the same name or host pattern, including the services in its access bundle
- If a machine identity creates the session on behalf of a user, the machine identity needs the Admin role and the user doesn’t, and the inline services don’t use the user’s personal values
- In each session that the
create,get,list, andupdatemethods return,serviceslists the inline services without their secrets