Developer guide: 2. Organizations and projects

Orgs, creating projects, project routes, org administration and the routes only a session can call.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-organizations-and-projects"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/b63a715f-22c8-411a-b3ca-0233bdd63d59/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 2. Organizations and projects" width="600" height="315"></a>

2. Organizations and projects

An org holds people, billing and projects. A project (a "site") holds all data and is the unit of keys, events, flags and settings. The usual agent flow: pick or create an org, create a project, keep PROJECT_ID, PK, SK.

Orgs: what an account key can do

Method and path

Scope

Purpose

GET /v1/orgs

org:read (or *:read)

orgs you belong to (and, for a restricted key, only its org_ids): {data, next_cursor}. Each org also carries your role in it (owner, admin, member, viewer or a custom role name), so a key can tell whether it may use the org admin routes without trying them

POST /v1/orgs

org:write, key not restricted to orgs

create an org, {"name"}; you become owner; the org has no project and plan free. Creating one is permanent for a key (see below)

GET /v1/orgs/{org_id}

org:read

{id, name, slug, plan, ip_capture_default, created_at}

PATCH /v1/orgs/{org_id}

org:write

{name?, ip_capture_default?}

GET /v1/orgs/{org_id}/settings

org:read

{members_can_invite, hide_members, logo_url, permanent_shares, brand_name, brand_accent, white_label}

PATCH /v1/orgs/{org_id}/settings

session only

any of those fields; an account key gets 404 (verified), so hand this one to the user

GET, PUT /v1/orgs/{org_id}/login-security

org:read / org:write

{confirm_new_device_logins}

GET /v1/orgs/{org_id}/projects

project:read

projects in the org ({data, next_cursor})

POST /v1/orgs/{org_id}/projects

project:write

create a project (below)

GET /v1/orgs/{org_id}/custom-fields

org:read

org-defined custom field definitions (writes are session only)

lc "$LUCIDA_API/v1/orgs" | jq '.data[] | {id, name, plan}'
ORG_ID=$(lc "$LUCIDA_API/v1/orgs" | jq -r '.data[0].id')     # or create one:
# ORG_ID=$(lc -X POST "$LUCIDA_API/v1/orgs" -d '{"name":"Acme Dev"}' | jq -r .id)
lc "$LUCIDA_API/v1/orgs/$ORG_ID/settings" | jq .                        # read; writing settings needs a session

Safe provisioning. Add ?dry_run=true to POST /v1/orgs, POST /v1/orgs/{org_id}/projects, POST /v1/projects/{project_id}/keys and POST /v1/me/keys: everything is validated (limits, slug conflicts, scopes) and you get 200 with the would-be object, "dry_run": true, no ids and no secrets; nothing is written. Add an Idempotency-Key: <unique string> header to retry a create safely: the same key and body from the same account within 24 hours returns the first response with "replayed": true, "secrets_omitted": true and the header Idempotent-Replayed: true. Secrets are never stored, so a replay does not contain the key secret: if you lost it, rotate the key. The same Idempotency-Key with a different body is a 409.

An account key creating an org whose name (case-insensitive) matches an org you already own gets 409; send "allow_duplicate_name": true to create it anyway. An account key holding admin can DELETE /v1/orgs/{org_id} (you must be its owner) only within 24 hours of creating it, or while none of its projects has ingested events; otherwise it is a 409 and the org is deleted from a signed-in session. Still, do not create orgs to "test" something: use ?dry_run=true.

A slug conflict on project create is a 409 whose body carries existing_project_id; GET /v1/orgs/{org_id}/projects?slug=acme-com finds a project by slug.

Create a project

RESP=$(lc -X POST "$LUCIDA_API/v1/orgs/$ORG_ID/projects" -d '{"name":"acme.com"}')   # 201
PROJECT_ID=$(echo "$RESP" | jq -r .project.id)
PK=$(echo "$RESP" | jq -r '.keys[] | select(.kind=="public") | .value')
SK=$(echo "$RESP" | jq -r '.keys[] | select(.kind=="secret") | .value')   # shown once: store it now
echo "$RESP" | jq '.environments'

The answer is {project, keys, environments, server_key_hint}: project has id, org_id, name, slug, region, timezone, week_start, fiscal_year_start_month, retention_days, replay_retention_days, compliance_profile, ip_capture, ip_truncate, ai_enabled, replay_mask_floor, geo_enabled, company_enabled, group_label, logo_url, tags, is_test, created_at. Two keys come with it (a public key, and a secret key named Secret key with scopes ["capture"], so it sends events and reads nothing), two environments (production, development) and a server_key_hint string:

{"project": {"id": "..."}, "environments": [...],
 "keys": [{"kind": "public", "name": "Public key", "value": "lc_pk_...", "public_value": "lc_pk_..."},
          {"kind": "secret", "name": "Secret key", "value": "lc_sk_...", "scopes": ["capture"]}]}

The secret key is send-only (POST /v1/s2s/batch) and its value is shown once, in this answer. Read the key string from keys[].value for both kinds and pick the key by kind. The secret field is deprecated: it repeats value, and on a public key it holds the public value, which is not a secret. For a lost secret, mint a new one: POST {p}/keys {"kind":"secret","name":"...","scopes":["capture"]} (section 1). Create takes name, an optional slug and an optional settings_from template (below); set the rest with PATCH.

Setup steps after create. A new project is created with consent_mode: "opt_in" stored in its SDK settings: the SDK stores and sends nothing until the visitor consents, so wire a consent banner (or call optIn()) before you expect data. A site that needs no consent runs PATCH {p}/settings/sdk {"consent_mode":"off"}. Projects created before 2026-11-16 keep what they had (unset means off). Turning session_recording on sets replay_sample_rate to 1.0 when it was 0.

Settings templates (start a project from another project's settings)

Give a new tenant project the privacy and capture settings of a template project in the same org, in the same transaction as the create:

lc -X POST "$LUCIDA_API/v1/orgs/$ORG_ID/projects?dry_run=true" \
  -d '{"name":"shop-42","slug":"shop-42","settings_from":"'$TEMPLATE_ID'","sections":["privacy","replay"]}'   # 200, nothing written
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/settings/copy" \
  -d '{"from_project_id":"'$TEMPLATE_ID'","sections":["ingest","sdk"]}'   # onto an existing project
  • sections (default all): sdk, ingest, replay, privacy, identity, profiles, guides. replay is the replay_*, session_recording and mask_all_inputs SDK keys plus the project columns replay_retention_days and replay_mask_floor. privacy is the consent keys of the SDK settings (consent_mode, cookieless_mode, respect_gpc, consent_banner, consent_geo_rules, autocapture_inputs), the server-event consent keys of the ingest settings, and the project columns ip_capture, ip_truncate, geo_enabled, company_enabled, retention_days. sdk and ingest copy every key those settings hold except the ones below. The sections overlap on purpose.

  • The keys the source sets overwrite; keys it does not set stay as they are on the target.

  • Never copied: keys, members, data, capture_allowed_origins (it names one tenant's origins), log-drain secrets and the replay exposure key.

  • The copy needs read on the source and admin on the target. A source that is inaccessible, or in another org, is 404. A target under the hipaa profile refuses privacy and replay with 409.

  • The answer (200) is {from_project_id, sections, settings: {<name>: [keys copied]}, columns: [...], dry_run}; on create it comes back as settings_copy next to project and keys. ?dry_run=true reports the same without writing. The copy is audited as project.settings_copy.

Project routes

Method and path

Scope

Purpose

GET {p}

settings:read

the project object above

PATCH {p}

settings:write

any of: name, timezone, week_start, fiscal_year_start_month, retention_days, replay_retention_days, region, tags, group_label, logo_url, ip_capture, ip_truncate, geo_enabled, company_enabled, ai_enabled, replay_mask_floor, compliance_profile

POST {p}/settings/copy

admin

{from_project_id*, sections?} copy settings sections from a project of the same org (settings templates); ?dry_run=true

DELETE {p}

admin

204; removes the project and all its data. Irreversible

GET {p}/environments

settings:read

project environments

GET, PUT, PATCH {p}/settings/sdk

read: settings:read; write: admin

SDK behaviour served at GET /v1/config: autocapture, heatmaps, session_recording, consent_mode, respect_gpc (honour the browser's Global Privacy Control signal as an opt-out; unset means on when consent_modeisopt_in, else off), consent_geo_rules, cookieless_mode, mask_all_inputs, replay_* (masking, sampling, URL rules), session_idle_minutes, session_max_minutes, snapshot_properties, ... merged into the stored settings. A key sent as null is unset (back to its default; an unknown key with null is 400). GET returns every setting with its effective value (stored values over the defaults) plus defaults, the default of each key, so a stored value can be told from a default; defaults is ignored if sent back. Turning session_recording on while the stored replay_sample_rate is 0 or unset (and the write sends none) sets it to 1.0: a rate of 0 records nothing

GET, PUT {p}/settings/ingest

read: settings:read; write: admin

ingestion switches; every key is in Ingest settings reference below (gateway and worker pick changes up in 30 to 60 s)

GET, PUT {p}/settings/quota

read: settings:read; write: admin

per-project monthly caps: {monthly_event_limit, replay_limit} (integers of at least 1; null or a missing key means no cap). PUT replaces both. At the event cap the project's events are dropped with a project_quota_exceeded warning (200, so retries do not pile up); at the recording cap only replay chunks are dropped, with project_replay_quota_exceeded, and events keep flowing. Both last until the month turns or you raise the cap. Counts come from the metering job, so the stop lands within a few minutes of the cap and the gateway sees it within 30 s. A provisioning script can set it right after creating the tenant's project

GET {p}/storage

settings:read

the browser storage the SDK writes for this project, from the SDK manifest: {version, updated, default_persistence, cross_subdomain, suffix_rule, items: [{name, store, category, purpose, expiry, gated_by}]}; follows session_recording and cookieless_mode; optional ?persistence= (default cookie) and ?cross_subdomain=true for what the site passes in code

GET, PUT {p}/settings/profiles

settings:read / admin

Profile API allow-lists

GET, PUT {p}/settings/guides; GET, PUT {p}/settings/logdrain, PUT/DELETE .../logdrain/{source}

*:read or settings:read / admin

guide and log-drain settings

GET, PUT {p}/branding

settings:read / admin

{name, accent, logo_url, white_label}

GET, PUT {p}/ai/share-settings

settings:read / admin

what AI features may see

GET, PUT {p}/retention

settings:read / admin

{person_days, audit_days, export_days*} data retention policies

GET {p}/members

settings:read

project members

PUT {p}/members/{user_id}

admin

{"level":"member"|"admin"}: add or change a project member (needed when access policy is none); DELETE removes

PUT {p}/members/{user_id}/role

session only, admin

{role_id} per-project role override; null clears

GET, PUT {p}/access-policy; GET, PUT {p}/access-settings

settings:read / admin

who in the org can open the project: default member or none, per-resource overrides

GET {p}/access-rules/{kind}, PUT/DELETE .../{kind}/{target}

settings:read / admin

{allowed_roles, allowed_users} per object

GET, POST {p}/proxy-records, DELETE .../{id}, POST .../{id}/check

settings:read / settings:write

first-party proxy domains ({domain*, path_prefix}; the answer has a one-time proxy_secret to send as X-Lucida-Proxy-Secret), DNS check; POST .../{id}/secret makes a new secret

GET, PUT {p}/toolbar/origins

*:read / admin

origins allowed to launch the toolbar

POST {p}/test-project

session only

{name?} copy actions, cohorts, flags (disabled), insights, dashboards into a non-metered test project; no events or persons

POST {p}/move

session only

{org_id*} move to another org; custom roles, team grants and cross-project views that list it are dropped

POST {p}/transfers

dashboard:write, insight:write, flag:write or cohort:write

copy one object to another project: {resource_type*, resource_id*, target_project_id*, mode?, dependencies?}

GET, POST {p}/namespaces; GET, DELETE {p}/namespaces/{id}; PUT {p}/namespaces/{id}/parameters

experiment:read / experiment:write / delete admin

experiment layers: create {name*, total_buckets?, parameters?}; the list answers {data, next_cursor} (?limit=&cursor=); see the experiments part

Notes:

  • GET {p}/keys and key minting need admin (or project:write to mint). Section 1 has the key rules.

  • PATCH {p} validates name (1 to 120 characters), retention_days and replay_retention_days (1 to 3650), week_start (0 to 6), fiscal_year_start_month (1 to 12) and timezone, which must be a real IANA zone such as Europe/Berlin or UTC; a malformed or too-long timezone (anything outside letters, digits and _/+-, or over 64 characters) is 422 with errors[].field timezone, like the other fields above; a well-formed name that is not an IANA zone is 400 timezone: unknown IANA timezone "Mars/Olympus" with the same errors[] entry.

  • IP handling is off by default (ip_capture:false); turn on ip_capture only after consent rules are settled. compliance_profile is standard by default; other profiles restrict some features and answer a compliance problem when blocked.

  • Settings PUTs merge the keys you send; read first, send only the keys you change.

Ingest settings reference

GET {p}/settings/ingest returns every key below, with its default when you have not set it, plus a defaults block. PUT merges: a key you send replaces the stored value, null clears it back to the default, a key you leave out stays. Unknown keys are rejected with 400, and defaults in a body is ignored, so you can send a fetched document back. Changes are written to the audit log.

Key

Type

Default

Effect

person_last_seen

boolean

false

Record persons.last_seen_at, floored to person_last_seen_minutes, so there is at most one extra person write per active step. An event can opt out with $update_person_last_seen_at: false

person_last_seen_minutes

integer, 1 to 1440

60

Precision of last_seen_at in minutes

hot_distinct_id_per_minute

integer, 0 to 1,000,000

6000

Events per minute one distinct id may send. The excess goes to the overflow lane: no person processing and an overflow ingestion warning. 0 means never

drop_agent_text

boolean

false

Drop $ai_text and $ai_feedback_comment at ingestion even when an SDK sends them. Unset keeps what the SDK sent (the SDK sends redacted text only with captureText on)

server_event_consent

string: off, drop_denied or require_granted

"off"

Consent gate for events sent with a secret key. drop_denied drops events of persons whose $consent_analytics is denied (consent_denied warning). require_granted also drops events with no grant: kept only when the event's own or the person's $consent_analytics is granted, otherwise a consent_missing warning. Browser events are not touched. See Consent-aware server events

drop_server_events_without_consent

boolean

false

Legacy alias of server_event_consent: "drop_denied" when true. Ignored when server_event_consent is set

consent_exempt_events

list of strings, at most 100 names of 1 to 200 characters

[]

Event names the server-event consent gate never drops

nps_person_properties

boolean

true

Keep the person properties nps_latest, nps_band and nps_at up to date from NPS answers; the latest timestamp wins and personless events are skipped. false stops it; properties already set stay. See NPS and rating responses

capture_exclude_urls

list of strings, at most 100 patterns of 1 to 200 characters

[]

Drop every event, not just replay, whose $current_url matches. Syntax as the replay URL lists: substring, * wildcard, case-insensitive, a re: prefix for a regular expression. Counted as capture_excluded

capture_include_urls

list of strings, at most 100 patterns of 1 to 200 characters

[] (capture everywhere)

Allow-list: when set, keep only events whose $current_url matches one entry and drop the rest. A path pattern starting with / matches the path from its start (/ is the home page only, /dashboard/* covers everything under it); a full URL prefix (https://example.com/shop-a/) matches from the start of the URL; anything else uses the exclude syntax. Events with no $current_url (most server events) are kept. Counted as url_not_included

capture_allowed_origins

list of strings, at most 100 origins of 200 characters

[]

Accept public-key events only from these origins, for example https://example.com, *.example.com or http://localhost:*. Empty means any origin. Dropped events answer 200 with an origin_not_allowed warning. Secret keys are never filtered. See Limit public-key capture

Org administration (members, roles, SSO, SCIM, audit, billing)

These are the org admin API: use an account key restricted to exactly one org with the matching area scope. Full detail and Terraform: Org admin API. Every call is also checked against the key owner's role (an admin's key cannot grant ownership or remove an owner).

# 1. Create the key with a session, or with an account key that holds these scopes (a key can mint a narrower key).
#    POST /v1/me/keys {"name":"provisioning","scopes":["members:write","roles:read","audit:read"],"org_ids":["<org_id>"]}
# 2. Then, with that key:
curl -sS -H "Authorization: Bearer $ORG_ADMIN_KEY" "$LUCIDA_API/v1/orgs/$ORG_ID/members" | jq '.data'
curl -sS -X POST -H "Authorization: Bearer $ORG_ADMIN_KEY" -H 'Content-Type: application/json' \
  -d '{"email":"new@example.com","role":"member"}' "$LUCIDA_API/v1/orgs/$ORG_ID/invites" | jq '{id, token}'

An all-orgs account key gets 403 this route needs an account key restricted to this one organization with the members:read scope on these routes (verified); another org gets 404.

Method and path

Scope

Purpose

GET /members, GET /members/{user_id}

members:read

members with role

PATCH /members/{user_id}

members:write

{role} one of owner, admin, member, viewer, billing; only an owner can grant or remove owner; the last owner cannot be removed or demoted (409)

DELETE /members/{user_id}

members:write

remove from this org only

GET /invites

members:read

open invites; tokens are never listed

POST /invites

members:write

{email*, role*} role admin, member, viewer or billing; answers the one-time token. Lucida does not email it from this route; deliver it yourself. Seat limits answer a seat-limit problem

DELETE /invites/{id}

members:write

revoke

GET /roles, GET /roles/{id}

roles:read

built-in and custom roles

POST /roles, PATCH /roles/{id}, DELETE /roles/{id}

roles:write

custom role {name*, permissions*}; permissions is {resource: "none"|"read"|"write"|"admin"} over insight, dashboard, replay, flag, experiment, cohort, person, connector, settings, members, billing, pii, toolbar

PUT /members/{user_id}/role

roles:write

{role_id} assign a custom role

GET /audit

audit:read

newest first. Filters: since, until, project_id, user_id, actor_kind (user|api_key|system|scim), action, resource_type, resource_id, ip, api_key_id, client, impersonated, q, limit, cursor

GET /audit/export

audit:read

NDJSON, oldest first; resume with the X-Next-Cursor response header

GET /audit/export.csv

audit:read

the filtered log, newest first, at most 50 000 rows; the download is itself audited

GET /audit/verify

audit:read

recompute the tamper-evident hash chain

GET /usage?from=&to=&by=project

billing:read

plan, daily usage, limits, quota. With by=project the response also has projects: for every project this month's events, replays, flag_requests, ai_calls, its monthly_event_limit and replay_limit (or null) state (events) and replay_state (recordings), each ok or hard

GET /billing/invoices

billing:read

invoices (limit, cursor)

GET /sso, GET /sso/{id}

sso:read

SSO connections (secrets are write-only)

POST /sso

sso:write

{protocol* "oidc"|"saml", domains*, default_role?, jit?, oidc? | saml?}

PATCH /sso/{id}

sso:write

{default_role, jit, oidc, saml}; the protocol cannot change

POST /sso/{id}/verify-domain

sso:write

checks the _lucida-challenge.<domain> TXT record equals the connection's domain_token; 409 if missing or another org verified it first

PUT /sso/{id}/enforce

sso:write

{enforced} refuse password login for verified domains

DELETE /sso/{id}

sso:write

delete

GET /scim/tokens

scim:read

metadata only

POST /scim/tokens, DELETE /scim/tokens/{id}

scim:write

issue (shown once) / revoke SCIM bearer tokens

All paths above are under /v1/orgs/{org_id}. Your IdP then provisions with /v1/scim/v2/Users and /v1/scim/v2/Groups (SCIM 2.0, SCIM bearer token; PATCH Users/{id} active:false deprovisions): SCIM setup.

Session-only org routes (hand these to the user)

Area

Routes (all under /v1/orgs/{org_id})

Delete, leave, impersonate

DELETE / (owner), POST /leave, POST /members/{user_id}/impersonate, POST /impersonation/end, GET/PUT /members/{user_id}/notifications

Billing

POST /billing/checkout {plan: "team"|"business"}, POST /billing/portal-session, GET /billing/projection, GET /billing/alerts, GET/PUT /billing/spend-limits {limits*}, GET /seats, GET /app-usage

Security

PUT /security {require_2fa}, GET/PUT /security/policy (password_min_length, password_require_mixed, seat_limit, session_idle_minutes, session_max_hours), GET/POST /security/ip-allowlist {cidr*, label}, DELETE .../{id} (the first block must contain your own address)

Domains and identity

GET/POST /domains {domain*}, PATCH/DELETE/POST .../{id}/verify, GET/POST /trusted-idps, GET /atlas-sso, POST /atlas-sso/setup-link (a session, or an account key holding sso:read / sso:write or admin for that org)

Audit delivery

GET/PUT /audit/policy {require_sink}, /audit/sinks, /audit/siem-sinks (kind https, splunk_hec, datadog, s3, gcs, azure), /audit/subscriptions

People

GET/POST /teams, GET/PATCH/DELETE /teams/{id}, PUT /teams/{id}/members {user_ids*}, GET /keys (every key in the org, no secrets)

Apps and config

GET/POST /oauth-apps, GET/PUT /ai/settings, GET/PUT/DELETE /chart-theme, GET/POST /cross-project-views, PUT /region {region} (us, eu or selfhost; only while the org has no projects), GET /web/rollup, org custom fields writes

Read-only discovery that works with any key: GET /v1/plans (public plan catalogue), GET /v1/regions (public; empty on single-region deployments).

Updated