Skip to main content
client.agentVault().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

object
required

Returns

CreatedAgentVaultSession
The new session, with the session token in token (Infisical returns the token only once).
To pass 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, and revoke methods return, onBehalfOf is the user, or null if the session is the machine identity’s own
To find the access bundles that a session on behalf of the user can use, pass the user’s email address or ID to accessBundles.list. The proxy refuses a session’s requests to services that still need the user’s personal values, so also pass requiresSetup: 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 an HTTP API (type: "http"), an MCP server (type: "mcp"), or a database or SSH server (type: "postgres", "mysql", or "ssh")
  • 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, and update methods return, services lists the inline services without their secrets
For the fields that each type of service takes, and for when Infisical deletes the services’ secrets, see Inline services.