---
title: Link agent sessions to Session Replay
description: Pass the Browser SDK's session ID and device ID to your backend agent session so Agent Analytics shows a Session Replay link for each agent session.
product: general
lang: en
token_estimate: 522
---
# Link agent sessions to Session Replay

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

When your frontend runs Amplitude Session Replay, you can link each agent session to the recording of the visit it happened in. Pass the browser's session ID and device ID to the backend when you open the agent session, and a Session Replay link shows in the sessions pane.

The two IDs identify different things. The agent session is the job, such as a ticket or a conversation, and your application owns that ID. The browser session is the visit, and Amplitude's Session Replay generates that ID on the frontend. One visit can contain several agent sessions.

## Where each ID comes from

- **Agent `sessionId`**: Your application generates or reuses this from your existing unit-of-work ID (thread, ticket, task). Refer to [Choose a session ID](https://amplitude.com/docs/amplitude-ai/agent-analytics/sessions#choose-a-session-id).
- **`browserSessionId` and `deviceId`**: The Amplitude Analytics Browser SDK maintains both on the client. Read them with `amplitude.getSessionId()` and `amplitude.getDeviceId()`, then forward them to your backend on the request that opens the agent session.

## Pass the IDs to the agent session

With the AI SDK, pass `browserSessionId` and `deviceId` when you open the agent session on the backend. For request-header examples, refer to [Link to the standard-analytics session](https://amplitude.com/docs/sdks/agent-analytics/sdk#link-to-the-standard-analytics-session) in the SDK reference.

The Session Replay ID (`<deviceId>/<sessionId>`) then lands as `[Amplitude] Session Replay ID` on the session's `[Agent]` events. Once at least one event carries it, a Session Replay link shows in the sessions pane.

If you send events without the AI SDK, add the replay properties to every agent event yourself. Refer to [Browser and edge notes](https://amplitude.com/docs/amplitude-ai/agent-analytics/instrument-http-api#browser-and-edge-notes).

