Skip to main content

Usage

Access this class through the composio.sessions property:

Methods

create()

Creates a new tool router session for a user. Use sessionPreset: SessionPreset.DIRECT_TOOLS when all needed tools should be exposed directly; see ToolRouterCreateSessionConfig. The session’s MCP config carries the session credential only when the MCP URL shares the origin of the configured API base URL. When it does not, mcp: true makes the call throw ComposioMCPDestinationError (naming both origins, never a key); without mcp: true the session is returned with session.mcp.headers empty and a warning naming both origins is logged, so native tools keep working. Overload 1
Parameters Returns Promise<Session<TToolCollection, TTool, TProvider>> — The tool router session Overload 2
Parameters Returns Promise<SessionWithoutMcp<TToolCollection, TTool, TProvider>> — The tool router session Example

delete()

Delete a tool router session by ID. Deleted sessions immediately stop being retrievable or executable. Deleting a missing or already-deleted session surfaces the backend 404.
Parameters Returns Promise<ToolRouterSessionDeleteResponse>

use()

Use an existing session The session’s MCP config carries the session credential only when the MCP URL shares the origin of the configured API base URL. When it does not, mcp: true makes the call throw ComposioMCPDestinationError (naming both origins, never a key); without mcp: true the session is returned with session.mcp.headers empty and a warning naming both origins is logged, so native tools keep working. Overload 1
Parameters Returns Promise<Session<TToolCollection, TTool, TProvider>> — The tool router session Overload 2
Parameters Returns Promise<SessionWithoutMcp<TToolCollection, TTool, TProvider>> — The tool router session Example