Use this file to discover all available pages before exploring further.
Sessions group related traces together, making it easier to monitor and debug complex workflows. Track entire user interactions or multi-step processes as a single unit.
There are two ways to create sessions: via span() / span_context() with session options (recommended), or via telemetry metadata on individual prompt calls.
For cases where you don’t need explicit spans, pass session info through telemetry metadata:
TypeScript
Python
In telemetry metadata, the session/user keys must be snake_case — session_id, session_name, user_id. The gateway only promotes these snake_case keys to session fields; camelCase keys (sessionId, …) are stored as ordinary metadata and will not group traces into a session.
const sessionId = `session-${Date.now()}`;async function handleUserMessage(message: string) { const prompt = await client.loadTextPrompt('chat.prompt.mdx'); const input = await prompt.format({ props: { message }, telemetry: { isEnabled: true, functionId: 'chat-handler', metadata: { user_id: 'user-123', session_id: sessionId, session_name: 'Customer Support Chat' } } }); return await generateText(input);}await handleUserMessage('Hello!');await handleUserMessage('What can you help me with?');
session_id = f"session-{int(time.time() * 1000)}"async def handle_user_message(message: str): prompt = await client.load_text_prompt("chat.prompt.mdx") params = await prompt.format( props={"message": message}, telemetry={ "isEnabled": True, "functionId": "chat-handler", "metadata": {"user_id": "user-123", "session_id": session_id, "session_name": "Customer Support Chat"} } ) return await run_text_prompt(params)await handle_user_message("Hello!")await handle_user_message("What can you help me with?")
The Sessions page lists each session with columns for ID, name, user, duration, cost, tokens, and trace count. Search by session ID or name, filter by date range and user, and sort by any column.Access sessions under the Sessions tab in the Dashboard or at http://localhost:3000 locally.
You can list sessions and retrieve a session’s traces programmatically using the CLI or REST API. Both the local dev server and the AgentMark Cloud gateway expose /v1/sessions and /v1/sessions/{sessionId}/traces.
REST API (Cloud)
REST API (local)
# List sessionscurl "https://api.agentmark.co/v1/sessions?limit=10" \ -H "Authorization: Bearer am_live_abc123" \ -H "X-Agentmark-App-Id: app_abc123"# List the traces belonging to a sessioncurl "https://api.agentmark.co/v1/sessions/session-1712764245/traces" \ -H "Authorization: Bearer am_live_abc123" \ -H "X-Agentmark-App-Id: app_abc123"
# No auth required locallycurl "http://localhost:9418/v1/sessions?limit=10"curl "http://localhost:9418/v1/sessions/session-1712764245/traces"
Both endpoints support pagination with limit and offset. The list endpoint also supports filtering by name and userId.See the Sessions API reference for full request and response details.