Developer guide: 12. In-product experiences

Guides, tours, announcements, early access and other in-product experiences over the API.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-in-product-experiences"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/5589cd81-92fc-4b2e-8dd8-6b7fff3c6aef/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 12. In-product experiences" width="600" height="315"></a>

12. In-product experiences

Guides show tours, banners, checklists and other in-app UI. Interventions fire a payload to the SDK or a webhook when an event happens. Early-access programs let people opt in to a flagged feature. The toolbar is the in-page editor. Experience is the satisfaction score.

12.1 Guides

Route

Scope

Purpose

GET {p}/guides?status=&q=&folder=&tag=&limit=&cursor=

*:read

list

POST {p}/guides

*:write

create (a draft)

`GET

PUT

DELETE {p}/guides/{id}`

POST {p}/guides/{id}/start

*:write

publish: status becomes live, published_at set; on a paused guide it resumes it (live again)

POST {p}/guides/{id}/stop

status becomes paused

POST {p}/guides/{id}/archive, /duplicate

duplicate {name?, project_id?} answers {guide, dropped}

POST {p}/guides/bulk

{action, ids, add_tags?, remove_tags?, folder?}; action is start, stop, archive, delete, move, tag; answer {updated, skipped:[{id, reason}]}

POST {p}/guides/draft

{prompt?, recorded_steps?:[{selector, url, text?}]} returns a draft body {kind, name, source, steps, targeting} (not saved)

GET {p}/guides/facets

{folders, tags}

GET {p}/guides/{id}/results?from=&to=

shown, completed, dismissed people, daily series

GET {p}/guides/{id}/results/accounts

per account

GET {p}/guides/{id}/reach

{audience_people, estimated_people, sample_pct, holdout_pct, ab_share, page_rules}

GET {p}/guides/{id}/impact?goal_event=&window_days=&from=&to=

holdout and A/B arms vs a goal event

GET {p}/guides/{id}/explain?distinct_id=&url=&tz=

why a person does or does not see it: {guide_id, distinct_id, eligible, gates:[{rule, outcome, detail?}]}. distinct_id is required (422 without). A guide that is not live (paused, draft) fails the status gate with a detail and eligible is false, even for a QA user (who only sees it as a preview). Rules seen: status, project_exclusions, cohorts, schedule, recurrence_frequency_ab, pacing, url, url_match; outcome is pass, or client for checks only the SDK can make on the page (url, url_match)

GET {p}/guides/{id}/dependencies

what references it

GET {p}/guides/{id}/revisions, .../revisions/{rid}, .../diff, POST .../restore

history

`GET

PUT {p}/settings/guides`

admin to write

`GET

POST {p}/guide-themes, GET

PUT

`GET

POST {p}/guide-templates, DELETE .../{id}`

Body: name, kind (exactly tooltip, modal, banner, tour, checklist, resource_center, announcement, hotspot, beacon, badge, launcher, slideout, inline, carousel, form_validation), steps, targeting, appearance, tags (max 20, 1-50 chars), folder (1-100 chars).

  • Kinds tooltip, modal, banner, announcement, hotspot, beacon, badge, slideout, inline have exactly one step (else 400); the others take many.

  • Every step needs a title or a body (400 otherwise). Steps of kind tooltip, tour, hotspot, beacon, badge and inline also need a non-empty selector (400 step N: tour steps need a selector, at most 500 characters).

  • Step: {id, title?, body?, selector? (required for tour, tooltip, hotspot, beacon, badgeandinline steps), placement? (top|bottom|left|right), fallback_selectors? (max 5), wait_ms? (0-15000), advance? (button|click|input), auto_close_s? (1-600), confetti?, native_id?, url?, buttons?, branch?, complete_on?, i18n?, media?, automation?, validation?}. Button: {label, action, url?, event?, goto?, snooze_hours?} with action one of next, back, dismiss, link, event, start_tour, snooze. Branch: {key, op (eq|neq|contains|exists|element_present|element_absent|flag_on|flag_off), value?, goto}; goto only goes forward. automation: {action: click|focus|fill, selector, value} (fill needs a constant value of 1-200 chars). validation rules (form_validation): required, email, url, phone, regex, min_length, max_length, number.

  • Targeting keys: url, url_match (exact|contains|regex), flag_key, flag_variant, sample_pct, wait_days, delay_seconds, devices (desktop|mobile|tablet), cohort_ids, exclude_cohort_ids, group_filters, seen_guides, not_seen_guides, schedule ({start,end} RFC 3339, days 0-6 Sunday=0, hours:{from 0-23,to 1-24}, timezone IANA), frequency ({max_views 1-1000, per_days 1-365}), goal ({event, window_days 1-90}), holdout_pct (0-90), holdout_scope (group|variant), ab_group, ab_weight (1-1000), qa_users (distinct ids who see a draft), pacing (asap|even; even needs schedule.start and end).

  • appearance: {tokens, font_family, theme_id, theme_mode (auto|light|dark), dark:{tokens}, launcher_label, side (left|right), custom_css}.

THEME=$(lc -X POST "$P/guide-themes" -d '{"name":"Brand","tokens":{"background":"#ffffff","text":"#111111","accent":"#0a7","radius":8}}' | jq -r .id)
GUIDE=$(lc -X POST "$P/guides" -d '{"name":"Welcome tour","kind":"tour","folder":"Onboarding","tags":["onboarding"],
  "steps":[{"id":"s1","title":"Welcome","body":"Start here","selector":"#nav","placement":"bottom","buttons":[{"label":"Next","action":"next"},{"label":"Skip","action":"dismiss"}]},
           {"id":"s2","title":"Create a report","body":"Click new","selector":"#new-report","placement":"right","advance":"click","buttons":[{"label":"Done","action":"dismiss"}]}],
  "targeting":{"url":"/app","url_match":"contains","sample_pct":100,"frequency":{"max_views":3,"per_days":7},"goal":{"event":"report_created","window_days":7},"qa_users":["qa1"]},
  "appearance":{"theme_id":"'$THEME'","theme_mode":"auto"}}' | jq -r .id)
lc "$P/guides/$GUIDE/reach"
lc -X POST "$P/guides/$GUIDE/start"          # status: live
lc "$P/guides/$GUIDE/results"
lc -X POST "$P/guides/$GUIDE/stop"           # status: paused

Delivery to browsers: GET $LUCIDA_CAPTURE/v1/guides?api_key=$PK&distinct_id=<id>&url=<page url> returns {guides:[{id, name, kind, steps, conditions, ...}]} for live guides that match (draft guides show only to qa_users). The route does not filter strictly by page: the url is a hint, and the SDK checks the page rules again in the browser, so a response can include guides for other URLs. A guide started in the API reaches visitors within about 15 seconds (cache refresh). SDKs report progress to POST /v1/guide-state; POST /v1/guides/answer serves resource-center AI answers. PUT replaces the whole guide: send every field (read, change, write back). Events the SDK sends are $guide_*; use them in insights.

12.2 Interventions

An intervention fires when a matching event arrives for a person and delivers payload to their SDK (server-sent events), to webhooks, or both.

Route

Scope

Purpose

`GET

POST {p}/interventions`

person:read / person:write

`GET

PUT

DELETE {p}/interventions/{id}`

POST {p}/interventions/{id}/test

person:write

{distinct_id}: fire for one person, skipping trigger and caps; event $intervention_test

GET {p}/interventions/fires?intervention_id=&distinct_id=&limit=&cursor=

person:read

last 35 days of fires {seq, id, intervention_id, distinct_id, event, deliver_sdk, webhook_state, fired_at, expires_at}

GET /v1/interventions?distinct_id=&cursor= (capture host, project key)

poll {data, next_cursor}; GET /v1/interventions/stream is the SSE form

Body: name (required), description, enabled, steps (up to 20 action steps, any one matches), action_id (an existing action instead of or with steps), payload (object, at most 8 KB), cap_per_user (1-1000, default 1), cap_window_secs (60 s to 30 days, default 1 day), cooldown_secs (0-30 days), deliver_sdk, deliver_webhook, ttl_secs (10 s to 1 day, default 300). With neither steps nor action_id the answer is 400 give steps or an action_id.

An action step: {event?, selector?, tag_name?, text?, text_match?, href?, href_match?, url?, url_match?, screen_name?, screen_name_match?, properties?}. properties is a nested filter group {"and":[{key, type, op, value}]} (or or), with type event or person. Unknown step fields are 400 invalid steps.

IV=$(lc -X POST "$P/interventions" -d '{"name":"Rescue checkout","description":"help after checkout error",
  "steps":[{"event":"checkout_error","properties":{"and":[{"key":"code","type":"event","op":"eq","value":"card_declined"}]}}],
  "payload":{"offer":"chat"},"cap_per_user":1,"cap_window_secs":86400,"deliver_sdk":true,"deliver_webhook":false,"ttl_secs":300,"enabled":true}' | jq -r .id)
lc -X POST "$P/interventions/$IV/test" -d '{"distinct_id":"qa1"}'
lc "$P/interventions/fires?intervention_id=$IV" | jq '.data[0]'
curl -sS "$LUCIDA_CAPTURE/v1/interventions?api_key=$PK&distinct_id=qa1"

The worker only fires for events younger than 10 minutes. For webhooks subscribe an endpoint to intervention.fired (section on webhooks) and dedupe on fire_id.

12.3 Early-access programs

An early-access program wraps an existing flag so people can opt in. Scope flag:write for writes.

Route

Purpose

`GET

POST {p}/early-access`

`PATCH

DELETE {p}/early-access/{id}`

POST {p}/early-access/{id}/enrol

{distinct_id, enrolled?: bool} opt a person in or out (204)

GET {p}/early-access/{id}/enrolled

{data:[{distinct_id, person_id, enrolled_at}]}

GET {p}/early-access/{id}/snippet

{html} ready-made opt-in widget

GET /v1/early-access?api_key=&distinct_id= (capture host)

what the SDK lists: {features:[{flag_key, name, description, stage, payload, documentation_url}]}

Create body: flag_key (an existing flag, required), name, description, stage (draft, concept, alpha, beta, ga; default beta; a draft is hidden from the SDK), payload (object shown by widgets), documentation_url.

EA=$(lc -X POST "$P/early-access" -d '{"flag_key":"cta-color","name":"New editor","description":"Try the new editor","stage":"beta","documentation_url":"https://example.com/docs/editor","payload":{"cta":"Join beta"}}' | jq -r .id)
lc -X POST "$P/early-access/$EA/enrol" -d '{"distinct_id":"user_123","enrolled":true}'
lc "$P/early-access/$EA/enrolled"
lc -X PATCH "$P/early-access/$EA" -d '{"stage":"ga"}'
  • Toolbar: PUT {p}/toolbar/origins (admin) {"origins":["https://example.com"]} replaces the allowed origins. POST {p}/toolbar/session {"origin"} mints a short-lived token {token, scopes, expires_at} for an allowed origin (a different origin is rejected); scopes are actions:write, heatmaps:read, flags:read, guides:write, experiments:write. GET {p}/toolbar/launch?url= redirects to the page with ?__lc_toolbar=<token>; the page calls POST /v1/toolbar/exchange {origin, token} once. See Chrome extension.

  • Link templates: GET|POST {p}/link-templates (write needs admin), DELETE .../{id}. Body {kind, object_type (flag|experiment), title, url_template}; url_template is an http(s) URL with {key}, {project}, {name}; it is expanded on every flag or experiment (GET .../flags/{id}/links returns templated).

  • Experience score: GET {p}/experience?by=&dim=&steps=&from=&to= plus the same segment filters as heatmaps (channel, utm_source, country, url, ...). by is summary (default), trend, page, segment (with dim: channel, device_type, country, browser, os, referring_domain) or funnel (with steps, 2-10 ordered events). GET|PUT|DELETE {p}/experience/weights read, set and reset the score weights (defaults: rage 15, not_found 15, bounce 20, dead 6, failed_action 12, form_abandon 12, backtrack 6, speed_browsing 10, cap 3, happy_from 80, unhappy_below 50, custom []).

Updated