Developer guide: 13. Session replay and heatmaps

Session replay ingest, search, retention, playlists and heatmaps over the API.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-session-replay-and-heatmaps"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/c5969ecd-0cb5-4a7f-9928-e8ecf0f38a72/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 13. Session replay and heatmaps" width="600" height="315"></a>

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 late replay.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

POST $LUCIDA_CAPTURE/v1/replay

public or secret key (api_key in the body, bearer header or ?api_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

session_id

required. A UUID you choose; it is the replay id in every later call. Put the same value in $session_id on your events so the replay links to them

events

required. rrweb events: type 4 meta (carries href, width, height), 2 full snapshot, 3 incremental (source 2 is a mouse interaction, 3 scroll). A session needs a type 4 and a type 2 event in its first chunk or it cannot be played

seq

required. Chunk number within the session, 0, 1, 2 ... Send them in order. Chunks are stored by seq; a chunk without it is 400

window_id

tab id. One session can have several windows. Optional (omitted is accepted)

compression

optional, three forms. (1) Plain JSON. (2) ?compression=gzip (or the body field "compression":"gzip") with events as a base64 gzip string of the JSON array. (3) The whole body gzipped, with Content-Encoding: gzip or ?compression=gzip

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, seq or events is 400. A bad key is 401.

  • /v1/replay exists on the capture host only; the API host answers 404.

  • Replays are retained for 30 days by default (retention_until on 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

date_range

{"from":"2026-11-01T00:00:00Z","to":"2026-11-10T00:00:00Z"}. Sessions that started inside it. Default: last 30 days. Relative values work too: {"from":"-7d","to":"now"}, "today" (same forms as section 6)

events

[{"name":"$pageview","filters":<property group>,"negate":false}]. The session must (or with negate, must not) contain the event

person

property group over person properties and cohorts

device_type, browser, os, country

arrays of strings; any value matches

duration, active_time

{"min":10,"max":600} in seconds

clicks, keypresses

{"min":1} counts

group

{"index":0,"key":"acme"}; index 0 to 4

url_visited

case-insensitive substring of any URL in the session

min_frustration

minimum frustration signals (rage and dead clicks)

min_scroll_depth

1 to 100 percent

experience_score

{"min":0,"max":50}, score 0 to 100

experiment, flag

{"key":"new-pricing-page","variant":"test"} (variant optional; matched per person)

has_console_error, has_network_5xx, has_external_error

booleans

session

{channel[], utm_source[], utm_medium[], utm_campaign[], referrer[], country[], language[], screen[], entry_page, exit_page, visitor:"new"|"returning", experience:"happy"|"neutral"|"unhappy", article_read:"finished"|"abandoned_headline", reader_type:"single"|"few"|"many"}

expiring_within_days

only replays that expire soon and are not on hold

session_ids, exclude_session_ids

restrict to or leave out these ids

order_by

recency (default), activity, frustration, experience

direction

desc (default) or asc

limit, cursor

paging; next_cursor is null on the last page

funnel

a funnel_persons query document (step, converted); only its sessions are listed

hide_viewed

true leaves out replays the calling user watched (users only)

collection

watch_history, with_comments, shared, exported, expiring_soon

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

GET {p}/replays/{session_id}

replay:read

{replay, chunks, markers, comments, external_markers, tags}. chunks[] have seq, window_id, url, expires_at; markers[] are timeline events (kind, event, offset_ms, path, properties)

GET {p}/replays/{session_id}/chunk_index

replay:read

per chunk seq, start_ms, end_ms, size_bytes, event_count, click_count, has_snapshot, sealed

GET {p}/replays/{session_id}/chunks/{seq}

replay:read

the chunk body, content-type: application/gzip (gzip of the rrweb event JSON array)

GET {p}/replays/{session_id}/snapshots?from_ms=&to_ms=

replay:read

decoded rrweb events in [from_ms, to_ms); a long window is cut and next_from_ms says where to continue

GET {p}/replays/{session_id}/transcript

replay:read

text timeline for agents: {session_id, duration_ms, lines:[{t_ms, kind:"page"|"signal"..., text}]}. The first line is always the first page (viewed <path>), even for a minimal recording

GET {p}/replays/{session_id}/live

replay:read

the same chunk list plus live:true while the session is open

GET {p}/replays/{session_id}/experiment-markers

replay:read

{data:[]} flag and experiment exposures on the timeline

GET {p}/replays/{session_id}/export

replay:read + pii:read

JSON bundle: format, chunk_range, chunks[].gzip_base64

GET {p}/replays/{session_id}/export/html?start_ms=&end_ms=

replay:read + pii:read

one self-contained HTML player that plays offline; the two params clip it

POST {p}/replays/{session_id}/exports/video

replay:read + pii:read

queue an MP4 or GIF render

GET {p}/replays/video-exports, .../{id}, .../{id}/download

replay:read + pii:read

list, poll and download renders

GET {p}/replays/{session_id}/sensitive

replay:read

captured values that were encrypted by a masking rule (metadata only)

POST {p}/replays/{session_id}/sensitive/reveal

admin + pii:read

decrypt one value; audited with its reason

GET, PUT {p}/replays/{session_id}/ai

replay:read / replay:write

the AI summary and tags for the replay; 404 until one exists

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.html

Video 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.

# 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

GET, POST {p}/replays/{session_id}/comments

read / write

{at_ms, body, point_x?, point_y?, point_node?, point_node_x?, point_node_y?, is_task?, assignee_id?}; points are fractions 0 to 1, both of a pair or none

PATCH, DELETE {p}/replays/{session_id}/comments/{id}

write

{at_ms?, body?, is_task?, assignee_id? (null unassigns), done?}

GET {p}/replays/comments/search, GET {p}/replays/tasks

read

search comments; open comment tasks (limit, cursor)

POST {p}/replays/{session_id}/moments

write

{start_ms, end_ms, title, note?, playlist_id?}; end_ms after start_ms, at most a day long

GET {p}/replays/moments?session_id=&playlist_id= , PUT, DELETE {p}/replays/moments/{id}

read / write

list, change, delete saved clips

GET, POST {p}/replays/{session_id}/issues

read / write

file a tracker issue: {connection_id, title, body?, at_ms?} (connection from issue-trackers, section 15)

POST {p}/replays/{session_id}/evidence

write

no body. A signed bundle of chunks plus a SHA-256 manifest (format: lucida-replay-evidence/1); GET lists past exports

GET {p}/replay-evidence/key

read

the project's Ed25519 public key (key_id, public_key). Check a bundle with lucida replay verify bundle.json --public-key <key>

GET, POST {p}/replays/{session_id}/shares; DELETE .../shares/{id}

read / write

public link, see below

GET {p}/replays/{session_id}/ai

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

GET, POST {p}/replay-playlists

read / write

list, create

GET, PATCH, DELETE {p}/replay-playlists/{id}

read / write

read, change (name, filters, pinned), delete

GET {p}/replay-playlists/{id}/sessions

read

sessions matching now, in search order (limit, cursor)

GET {p}/replay-playlists/{id}/pinned; PUT, DELETE .../pinned/{session_id}

read / write

pinned sessions

GET, POST {p}/replay-playlists/{id}/shares; DELETE .../shares/{share_id}

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

GET, POST {p}/replays/notify-rules; PUT, DELETE .../{id}

read / write

{name, kind:"frustrated"|"tagged"|"capture_cliff", min_frustration (default 3), tag, drop_ratio (default 0.5), channels[], enabled}. channels needs at least one entry (400 at least one channel)

GET {p}/replays/capture-health

read

replays per session in the last 24 h against the 7 days before: recent_ratio, baseline_ratio, cliff

GET {p}/replays/storage

read

used_bytes, sessions, budget_bytes, pct_used, state, policy, recording_stopped

PUT {p}/replays/storage/budget

admin

{budget_bytes (0 to 1 PB, null removes), policy:"evict"|"stop"}; evict deletes the oldest replays, stop switches recording off in the SDK settings

POST {p}/replay-privacy/scan

admin

{sessions} (default 50, at most 200). Scans recent replays for visible personal data: {findings, sessions_scanned}

GET {p}/replay-privacy/findings?status=open|accepted|dismissed

settings:read

findings

PATCH {p}/replay-privacy/findings/{id}

admin

{status:"accepted"|"dismissed"|"open"}. Accepting adds the selector to the project's mask selectors

POST {p}/replay-privacy/findings, GET .../text-samples

admin

used by the AI pass: record findings ({selector, kind: name|address|id_number|email|card|phone|other, reason}), read visible text samples (also needs pii:read)

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

GET {p}/heatmaps?url=

bins [{x,y,count,sessions,users}], max, total. type: click (default), rage, dead, move, scroll, attention. scroll returns {avg_depth, reach:[{depth_pct,sessions}]}

GET {p}/heatmaps/cell?url=&x=&y=

sessions behind one bin, most points first (same filters)

GET {p}/heatmaps/elements?url=

element click rank (key default selector) with conversion lift when goal is set; limit, cursor

GET {p}/heatmaps/fold?url=

scroll fold per device bucket (fold_px, below_fold_rate); breakpoints=480,768,1024

GET {p}/heatmaps/confetti?url=&breakdown=

sampled click dots coloured by channel, referrer, device, country, browser, os, visitor, event:<key> or person:<key>; dots default 5000, max 20000

GET {p}/heatmaps/compare?urls=/a,/b

per-page summary (clicks, ctr, avg_scroll_depth, rage_clicks, frustration_rate) across pages

GET {p}/heatmaps/coverage?days=

pages viewed with points and whether the capture allow-list covers them

GET {p}/heatmaps/recordings?url=

up to three recent replays of the page. url is matched as an exact path (after normalisation), with * as a wildcard; / matches only the home page

GET {p}/heatmaps/snapshot?url=&session_id=

background chunk for drawing the map (replay:read)

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

GET, POST {p}/heatmaps/zones; PUT, DELETE .../zones/{id}

{url, name, x0, x1, y0, y1}; x0 < x1 are page-width ratios 0 to 1, y0 < y1 are document px

GET {p}/heatmaps/zones/report?url=

per zone clicks, share and conversion (goal, revenue_property) plus page_height_px

GET, POST {p}/heatmaps/shares; DELETE .../shares/{share_id}

{url, expires_in_days?, password?}; GET needs ?url=. Public: GET /v1/public/heatmaps/{token}?type=&viewport=&days=

GET, POST {p}/heatmaps/snapshots/pages; DELETE .../pages/{id}

register a page for daily frozen bins: {url, x_bins? (1 to 200), y_bin_px? (1 to 1000)}

GET, PUT {p}/heatmaps/snapshots/settings

{viewports[] (max 5), refold_days (0 to 7), auto_top_n (0 to 50)}

GET {p}/heatmaps/snapshots?url=, .../snapshots/{day}?url=, .../snapshots/compare?url=&a=&b=

read frozen days, compare two YYYY-MM-DD days

# 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.


Updated