Usage
Access this class through thecomposio.sessions property:
Methods
create()
Creates a new tool router session for a user. UsesessionPreset: 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
Returns
Promise<Session<TToolCollection, TTool, TProvider>> — The tool router session
Overload 2
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.
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
Returns
Promise<Session<TToolCollection, TTool, TProvider>> — The tool router session
Overload 2
Returns
Promise<SessionWithoutMcp<TToolCollection, TTool, TProvider>> — The tool router session
Example