Developer guide: 13. Session replay and heatmaps
Session replay ingest, search, retention, playlists and heatmaps over the API.
13. Session replay and heatmaps
Replay records what a visitor saw and did (rrweb DOM events) so you can watch it back, search it, annotate it and share it. Heatmaps bin clicks, moves and scroll depth per page. Both are read with a project key or an account key. In the tables below {p} is /v1/projects/{project_id}. Dates in these families are RFC 3339 with Z (2026-11-01T00:00:00Z). Relative values (-7d, mtd, yesterday, now) are also accepted on replays/search and, in the from/to query string of the heatmap and web routes, where they snap in UTC (the project timezone is not used because a query string has no project context). Other routes with their own from/to query parameters (forms, accessibility, annotations, adoption, flags usage and similar) take RFC 3339 only.
Scopes: replay routes need replay:read (reads) or replay:write (tags, comments, shares, playlists). pii:read is also needed for anything that exports raw recordings (export, export/html, video, evidence). Heatmap routes need insight:read or insight:write, except heatmaps/snapshot and heatmaps/recordings, which show recordings and need replay:read. Without pii:read, distinct_id in replay rows is masked and person_id is null.
Turning recording on
Importing the SDK's replay module is not enough. The project must also allow it: PUT {p}/settings/sdk {"session_recording": true, "replay_sample_rate": 1} (or PATCH; a PATCH with session_recording: true sets replay_sample_rate to 1.0 when it was 0 and the call sends none). The defaults are session_recording: false and replay_sample_rate: 0, and nothing is recorded until both are set. Remote config can only tighten local SDK config (a lower rate, more masking, more blocked URLs), never loosen it.
replay_url_blocklist and replay_never_record are both lists of URL patterns (substring match, * wildcard, or a regular expression written re:...; case-insensitive) and both are in settings/sdk:
replay_url_blocklist: recording pauses on any page whose URL matches and resumes when the visitor navigates to a page that does not. The SDK discards what it buffered for the blocked page, and the worker drops matching pages from stored chunks. The rest of the session is still recorded.replay_never_record: if the session starts on a matching URL (or a manual or latereplay.start()runs on one), the whole session is not recorded, including the pages visited after. Use it for entry points such as/admin; use the blocklist for single sensitive pages inside an otherwise recordable session.
13.1 Send a replay chunk
The browser SDK does this for you (@lucida-analytics/browser/replay, see section 15). From a server or a test, post rrweb chunks to the capture host.
Method and path | Auth | Purpose |
|---|---|---|
| public or secret key ( | one chunk of one session |
SID=$(uuidgen | tr A-Z a-z); NOW=$(($(date +%s)*1000))
curl -sS -X POST "$LUCIDA_CAPTURE/v1/replay" -H "Content-Type: application/json" -d '{
"api_key":"'"$PK"'","session_id":"'"$SID"'","window_id":"w1","seq":0,
"events":[
{"type":4,"timestamp":'"$NOW"',"data":{"href":"https://acme.test/pricing","width":1280,"height":720}},
{"type":2,"timestamp":'"$((NOW+10))"',"data":{"node":{"type":0,"id":1,"childNodes":[{"type":2,"id":2,"tagName":"html","attributes":{},"childNodes":[{"type":2,"id":3,"tagName":"body","attributes":{},"childNodes":[{"type":2,"id":4,"tagName":"button","attributes":{"id":"buy"},"childNodes":[{"type":3,"id":5,"textContent":"Buy"}]}]}]}]},"initialOffset":{"left":0,"top":0}}},
{"type":3,"timestamp":'"$((NOW+1500))"',"data":{"source":2,"type":2,"id":4,"x":300,"y":200}}]}'
# {"status":1}Field | Rules |
|---|---|
| required. A UUID you choose; it is the replay id in every later call. Put the same value in |
| required. rrweb events: type |
| required. Chunk number within the session, 0, 1, 2 ... Send them in order. Chunks are stored by |
| tab id. One session can have several windows. Optional (omitted is accepted) |
compression | optional, three forms. (1) Plain JSON. (2) |
size | 10 MB per request. Larger bodies are rejected; split the chunk |
Gotchas:
Masking is the sender's job. Lucida stores what you send. The SDK masks inputs by default; a custom sender must mask before posting (see Replay privacy).
200 {"status":1}means accepted onto the queue. The replay appears in search after a few seconds, and its size and click counts after the chunk is processed.A body without
session_id,seqoreventsis400. A bad key is401./v1/replayexists on the capture host only; the API host answers404.Replays are retained for 30 days by default (
retention_untilon each row).
13.2 Search replays
POST {p}/replays/search takes a JSON filter. Every field is optional. limit is 1 to 500 (default 50); an unknown field is 400 and the message lists the valid ones.
Field | Type and meaning |
|---|---|
|
|
|
|
| property group over person properties and cohorts |
| arrays of strings; any value matches |
|
|
|
|
|
|
| case-insensitive substring of any URL in the session |
| minimum frustration signals (rage and dead clicks) |
| 1 to 100 percent |
|
|
|
|
| booleans |
|
|
| only replays that expire soon and are not on hold |
| restrict to or leave out these ids |
|
|
|
|
| paging; |
| a |
|
|
|
|
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/search" -d '{
"date_range":{"from":"2026-11-01T00:00:00Z","to":"2026-11-10T00:00:00Z"},
"events":[{"name":"$pageview"}],"url_visited":"/pricing","min_frustration":1,
"order_by":"frustration","limit":20}' | jq '.data[] | {session_id,started_at,duration_s,frustration_count,first_url}'A row has: session_id, distinct_id, person_id, started_at, ended_at, duration_s, active_ms, click_count, keypress_count, size_bytes, chunk_count, first_url, urls, frustration_count, experience_score, experience_bucket, legal_hold, ai_tags, tags, retention_until, console_error_count, network_error_count, has_console_error, has_network_5xx, viewed.
13.3 Read one replay
Method and path | Scope | Purpose |
|---|---|---|
|
|
|
|
| per chunk |
|
| the chunk body, |
|
| decoded rrweb events in |
|
| text timeline for agents: |
|
| the same chunk list plus |
|
|
|
|
| JSON bundle: |
|
| one self-contained HTML player that plays offline; the two params clip it |
|
| queue an MP4 or GIF render |
|
| list, poll and download renders |
|
| captured values that were encrypted by a masking rule (metadata only) |
|
| decrypt one value; audited with its reason |
|
| the AI summary and tags for the replay; |
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID/transcript" | jq -r '.lines[] | "\(.t_ms)ms \(.text)"'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID/chunks/0" | gunzip | jq 'length'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID/export/html?start_ms=0&end_ms=3000" -o clip.htmlVideo body (exports/video): format (mp4 or gif, required), start_ms, end_ms, fps (1 to 30, default 10), skip_idle, player_chrome, width (1 to 1920). Renders are queued; poll video-exports/{id}.
Bulk export: POST {p}/replays/export/bulk and POST {p}/replays/export/window (both replay:read + pii:read) export many replays or a time window; their request bodies are in services/lc-api/openapi.json.
13.4 Tags, retention, legal hold, delete
# tags (trimmed, lower-cased, 1 to 40 chars, at most 20) and the caller's watched flag
lc -X PATCH "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID" -d '{"tags":["Pricing","rage"]}' # 204
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/tags" # [{"tag":"pricing","replays":1}]
# keep a replay beyond the default retention (admin; future, at most 5 years)
lc -X PATCH "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID" -d '{"retention_until":"2027-06-01T00:00:00Z"}'
# legal hold blocks the retention sweeper and deletes
lc -X PUT "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID/hold" -d '{"hold":true}' # 204
lc -X DELETE "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID" # replay:write or admin
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/bulk_delete" -d '{"session_ids":["<uuid>","<uuid>"]}'PATCH needs at least one of viewed, tags, retention_until; viewed belongs to a user, so an API key gets 400 for it. bulk_delete takes 1 to 100 ids, audits each deletion and reports replays on hold as skipped.
13.5 Comments, moments, issues, evidence, shares
Method and path | Scope | Body or purpose |
|---|---|---|
| read / write |
|
| write |
|
| read | search comments; open comment tasks ( |
| write |
|
| read / write | list, change, delete saved clips |
| read / write | file a tracker issue: |
| write | no body. A signed bundle of chunks plus a SHA-256 manifest ( |
| read | the project's Ed25519 public key ( |
| read / write | public link, see below |
| read | AI summary |
Share links (replays, replay playlists, web, heatmaps) use one body. All fields are optional:
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/replays/$SID/shares" -d '{
"expires_in_days":7,"password":"correct horse battery","allowed_origins":["https://app.example.com"],
"options":{"hide_branding":true}}' | jq '{id,expires_at,password_protected}'expires_in_days defaults to 7, at most 90. never_expires: true needs the organization setting permanent_shares (otherwise 403). password is 8 to 200 characters and stored as an argon2id hash. allowed_origins limits who may frame the embed. The viewer URL (url and token) is returned once; later listings show id, expires_at, revoked_at, password_protected only. Public pages: GET /v1/public/replays/{token} (+ /chunks/{seq}), /v1/embed/replays/{token} for an iframe.
13.6 Playlists (collections)
A playlist is a saved replay search, plus pinned sessions. A smart playlist refreshes itself.
Method and path | Scope | Purpose |
|---|---|---|
| read / write | list, create |
| read / write | read, change ( |
| read | sessions matching now, in search order ( |
| read / write | pinned sessions |
| read / write | share links (body as above) |
# a saved search (filters = the body of replays/search)
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/replay-playlists" -d '{
"name":"Pricing frustration",
"filters":{"date_range":{"from":"2026-11-01T00:00:00Z","to":"2026-12-01T00:00:00Z"},"url_visited":"/pricing","min_frustration":1},
"pinned":["'"$SID"'"]}'
# a smart playlist: rolling window, no filters, no pins
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/replay-playlists" -d '{
"name":"Rage clicks this week","smart":{"kind":"rage_clicks","window_days":7}}'smart.kind is rage_clicks, friction, errors or high_value; window_days is 1 to 90. A normal playlist's /sessions uses filters.date_range (absolute or relative such as -7d) and defaults to the last 30 days when it is not set. The playlist id is also valid as playlist_id for moments and MCP get_playlist (section 16).
13.7 Alerts, capture health, storage, privacy scans
Method and path | Scope | Purpose |
|---|---|---|
| read / write |
|
| read | replays per session in the last 24 h against the 7 days before: |
| read |
|
|
|
|
|
|
|
|
| findings |
|
|
|
|
| used by the AI pass: record findings ( |
13.8 Sessions
GET {p}/sessions (insight:read) lists analytics sessions, newest first, and tells whether a replay exists.
Query: from, to, order_by, direction, channel, country, device_type, entry_path, exit_path, is_bounce, distinct_id, person_id, min_duration, include_internal, limit, cursor.
Row: session_id, distinct_id, person_id, started_at, ended_at, duration_s, events, pageviews, entry_path, entry_url, exit_path, exit_url, channel, country, device_type, is_bounce, frustration_count, has_replay (1 when a replay with the same session_id exists). The id of a session and of its replay are the same value.
13.9 Heatmaps
Points come from the SDK ($$heatmap events with $heatmap_data, and replay-derived clicks). Pages are keyed by the normalized path of url: pass /pricing or a full URL. Click and move points land in 50 columns by default (x_bins) and 20 px rows (y_bin_px).
Read:
Method and path | Purpose |
|---|---|
| bins |
| sessions behind one bin, most points first (same filters) |
| element click rank ( |
| scroll fold per device bucket ( |
| sampled click dots coloured by |
| per-page summary ( |
| pages viewed with points and whether the capture allow-list covers them |
| up to three recent replays of the page. |
| background chunk for drawing the map ( |
Common query for the reads above: from, to (RFC 3339; default last 30 days), viewport (device bucket), min_width, max_width, cohort, compare (previous or cohort:<id>), goal, flag with variant, fixed (only or exclude, for sticky elements). Segment filters: channel, utm_source, utm_medium, utm_campaign, referrer, country, language, screen, entry_page, exit_page, visitor (new, returning), person_property with person_value, experience (happy, neutral, unhappy), article_read (finished, abandoned_headline), reader_type (single, few, many). List values are comma separated.
Manage:
Method and path | Body |
|---|---|
|
|
| per zone clicks, share and conversion ( |
|
|
| register a page for daily frozen bins: |
|
|
| read frozen days, compare two |
# send click points from a server (the SDK sends the same event)
curl -sS -X POST "$LUCIDA_CAPTURE/v1/batch" -H "Content-Type: application/json" -d '{"api_key":"'"$PK"'","batch":[{
"uuid":"'"$(uuidgen | tr A-Z a-z)"'","event":"$$heatmap","distinct_id":"anon_1","properties":{
"$current_url":"https://acme.test/pricing","$session_id":"'"$SID"'","$viewport_width":1280,"$viewport_height":720,
"$heatmap_data":{"https://acme.test/pricing":[{"x":300,"y":200,"type":"click"},{"x":900,"y":640,"type":"click"}]}}}]}'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/heatmaps?url=/pricing" | jq '{total,max,bins:.bins[0:3]}'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/heatmaps?url=/pricing&type=scroll" | jq '{avg_depth}'Limits: 20 URLs and 1000 points per event; only click and mousemove types are read from $heatmap_data. Rage and dead clicks are derived by Lucida, not taken from the SDK.
13.10 Accessibility
GET {p}/accessibility (replay:read) lists accessibility rule violations found in recorded DOM snapshots. Query: from, to, url, rule, impact, goal, limit. Each issue has rule (for example document-title), impact (serious ...), level, help, sessions affected, converted_sessions and a sample_session_id with sample_offset_ms to jump to the moment.