Developer guide: 1. Keys and authentication
Key types, scopes, environments, project keys, account keys, sessions versus keys, OAuth apps and the versioning header.
1. Keys and authentication
Lucida has two kinds of principal: a person (a browser session, cookie lc_session) and a key (a bearer token). Every management call sends Authorization: Bearer <key>. Tenant identity (organization and project) always comes from the key or the URL you are allowed to reach, never from a request body.
Key types
Key | Looks like | Made by | Scope | Can do |
|---|---|---|---|---|
Account key |
|
| all orgs you belong to, or the | acts as you, capped by its scopes; creates orgs and projects, mints project keys, then uses the project API |
Project public key |
| project create, or | one project, no scopes | send events and replays, evaluate flags. Safe to ship in a browser |
Project secret key |
|
| one project | everything a public key does, plus |
Project personal key |
|
| one project, at least one scope | a scoped token bound to a project (for tools that expect a |
OAuth access token |
|
| one project, granted scopes | an app or CLI acting as a user; expires |
Secrets are shown once in the create answer; Lucida stores only a SHA-256 hash. A public key's full value stays visible as public_value in GET {p}/keys. Lost a secret: mint a replacement and revoke the old one.
Scopes: GET /v1/scopes
The catalogue has 53 entries: {name, level, resource}. Read access is implied by write for the same resource. Read the live list with curl -sS $LUCIDA_API/v1/scopes | jq -r '.[].name'.
Scope | Opens |
|---|---|
| read every project resource except |
| write every project resource including settings, webhooks, transformations; never keys, members, billing, PII, |
| the older broad names: read access to every project resource |
| insights, queries, events list, event and property definitions, data-quality, saved queries |
| exactly that resource. |
| unmasked personal data (person properties, replay ids). No write |
| propose catalog objects (metrics, table marks, relationships); approve what was proposed |
| secret keys only: send events and read nothing |
| run / create-edit query endpoints |
| data pipeline (transformations, destinations, exports) without project admin |
| the gateway Profile API ( |
| secret keys may hold it: person erasure ( |
| bundle for provisioning from code: |
| acts as org admin on the project: keys, members, access policy, retention, deletion |
| account keys: list and read orgs; create orgs and rename them (write implies read) |
| account keys: list projects and settings; create projects, mint project keys, manage project settings |
| org admin API: account key restricted to exactly one org (see section 2). There is no |
| send |
Rules that always apply:
A personal key with
scopes:["admin"]acts as a project admin: it can mint, rotate and revoke project keys and it sees person emails unmasked. Giveadminonly to keys you would trust with a signed-in admin's session.A capture-only key (a secret key whose scopes are only
capture, such as the one project create mints) that calls any other route of its own project gets403 this key can only send events. Another project's routes are404, as for every key.A key never exceeds its minter. A key minted through an account key can only carry scopes the account key holds. Your org role is also the ceiling, at creation and on every call.
A wrong scope on an org route gives
403naming the scope (for examplethis key needs the members:write scope). On a project route, a key that lacks the scope gets404, not403: Lucida answers404for anything the key cannot reach, so a wrong project id and a missing scope look the same. Check the key withGET /v1/keys/self(orGET /v1/me/keysfor account keys,GET {p}/keysfor project keys) before suspecting the id.An account key can mint a narrower account key with
POST /v1/me/keys, only with scopes it holds; an all-orgs admin key can mint any.Erasure key. A server that erases people should hold a key that can do only that:
POST /v1/projects/{p}/keys {"kind":"secret","name":"erasure","scopes":["privacy:execute"]}. It allowsPOST {p}/persons/bulk_delete,DELETE {p}/persons/{id}and the/privacy/*rights routes for that project only.adminalso works but is project admin (keys, members, retention), so do not use it for this. Secret keys cannot holdadminordelegate(400).org:*,*:*andadmindo not open the org admin routes (members, roles, audit, billing, SSO, SCIM); only the matching area scope does.
Environments
Each project starts with production (default) and development: GET {p}/environments returns {data:[{id,name,is_default}],next_cursor}. A public or secret key may be bound to one environment with environment (its name) at creation; flags and remote config are then served for that environment and events carry it. Default: the project's default environment; in GET {p}/keys an unbound key shows environment: null, which means that default. A name that does not exist, or environment on a personal key, is 400.
Project keys: mint, list, rotate, revoke
Method and path | Scope | Purpose |
|---|---|---|
|
| metadata only, usable keys only (revoked keys too with |
|
| mint; the answer carries |
|
| issue a replacement with the same name, kind, scopes, environment and expiry, and revoke the old key at once (rotating a legacy read-all secret key needs |
|
| revoke ( |
# A server key that reads and writes the project (no admin)
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/keys" \
-d '{"name":"ci-server","kind":"secret","scopes":["*:read","*:write"],"expires_at":"2027-06-01T00:00:00Z"}' \
| jq '{id, key_prefix, expires_at, value}'
# A key that can only send events (secret keys with the capture scope read nothing)
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/keys" \
-d '{"name":"ingest-only","kind":"secret","scopes":["capture"]}' | jq -r .value > ingest.key && chmod 600 ingest.key
# A browser key bound to the development environment
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/keys" \
-d '{"name":"web-dev","kind":"public","environment":"development"}' | jq '{public_value, environment}'
# Rotate, then revoke
KEY_ID=$(lc "$LUCIDA_API/v1/projects/$PROJECT_ID/keys" | jq -r '.data[] | select(.name=="ci-server") | .id')
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/keys/$KEY_ID/rotate" | jq '{id, secret}' # 201, new id and secret
lc -X DELETE "$LUCIDA_API/v1/projects/$PROJECT_ID/keys/$KEY_ID" -w '%{http_code}\n' # 404: rotation already revoked itRules verified against the live API:
kindispublic,secretorpersonal; anything else is400 kind must be public, secret or personal.public: scopes forbidden (400 public keys take no scopes).secret: at least one scope. Empty or missingscopesis400(secret keys need scopes: ["capture"] to send events only, or read scopes such as ["*:read"], ["flag:read"] or ["profiles:read"]). To send events and read nothing, use["capture"].adminanddelegateare refused (400).Legacy secret keys. Secret keys minted before this rule, with empty
scopes, keep working and still read the whole project.GET {p}/keysmarks themlegacy_read_all: true(it isfalseon every other key). Rotate one to a scoped key when you can; no new key is made that way.personal: at least one scope (400 personal keys need at least one scope).Unknown scope names are
400 unknown scope. A missingkindis422witherrors[].expires_atis RFC 3339; the key stops working at that time (401). A past value is rejected at creation with400 expires_at must be in the future(project keys andPOST /v1/me/keysalike). There is no automatic rotation: schedulerotateyourself.Key names are not unique; use the
id.A revoked or rotated-out key answers
401withdetailAPI key revoked; an expired one,API key expired. A key Lucida has no record of (never issued, or deleted before revocation was kept, 2026-11-12) getsmissing or invalid credentials. Every such401also carries a machine-readablecodemember:key_revoked,key_expiredorkey_unknown, and nothing else differs.GET /v1/me/keyslists your account keys withlast_used_at(set on every authenticated call). For a read-only integration mint{"kind":"secret","scopes":["query:read"]}: it reads every project resource through the API and cannot change experiments, flags or settings. Every key create (POST /v1/projects/{id}/keys,POST /v1/me/keys) returns the secret asvalue;secretis a deprecated copy.last_used_atupdates lazily. Use it to find unused keys to revoke.
Which key an integration needs
Integration | Key | Minted with |
|---|---|---|
Browser or app capture, flags | project public key | project create |
Server events ( | project secret key with | project create, or |
Rights requests (Cookie Munch executor | project secret key with |
|
Creating orgs and projects, minting keys, MCP | account key |
|
A project key cannot mint keys, and a capture-only key refuses everything else with 403 this key can only send events plus the key it needs. When in doubt, ask the key: GET /v1/whoami.
Check a key: GET /v1/keys/self (or GET /v1/whoami)
GET /v1/whoami is the same route under the name other platforms use, on both hosts.
Checking a capture key needs no test event. GET https://capture.lucidace.com/v1/whoami with the key answers 200 with its kind and scopes (a revoked or wrong key: 401) and stores nothing, so no provisioning_check event lands in production data.
A key describes itself, so an integration can verify a key it was handed without guessing from a failing call. It needs no scope: any valid key may read its own description, and it never returns the secret or its hash. A session or a missing key gets 401/404 (a session is not a key). The same path answers on both hosts with the same shape: the API host for account keys and project keys, the capture host for public and secret project keys. A public key answers keys/self only on the capture host; the API host answers it 401.
curl -sS "$LUCIDA_API/v1/keys/self" -H "Authorization: Bearer $LUCIDA_ACCOUNT_KEY" | jq .
curl -sS "$LUCIDA_CAPTURE/v1/keys/self" -H "Authorization: Bearer lc_sk_..." | jq .Field | Meaning |
|---|---|
|
|
| the key's scopes ( |
| account keys: the orgs the key is limited to, or |
| project keys: the project; |
| public and secret keys: the environment the key serves (its binding, else the project default); |
| RFC 3339 or |
| the key's name and its non-secret prefix |
whoami and keys/self are read-only and store nothing, so they are the safe way to see what a key is. For example, to check that a key for rights requests holds privacy:execute, call GET /v1/whoami with it and look for that scope in scopes. Only a key can ask: a session gets 404.
Is this account key still alive: GET /v1/keys/lookup
When all you have is the key's display prefix (a log line, a ticket), ask for its status without the key itself:
curl -sS "$LUCIDA_API/v1/keys/lookup?prefix=lc_pat_AbCd" -H "Authorization: Bearer $LUCIDA_ACCOUNT_KEY" | jq .It needs a session or an account key. The prefix must start with
lc_pat_and have at least 4 characters after it (11 characters in all, at most 64), else400. A project key gets404.The answer is
{status, revoked_at, created_at, name, owner_email}.statusisactive,revokedorunknown.unknownalso covers a key that belongs to someone else.You see only your own account keys. An instance admin sees any account key, and
owner_emailis set only for them.An account key's
key_prefix(11 characters, for examplelc_pat_AbCd) is in each row ofGET /v1/me/keys. A longer prefix than the stored one still matches.
Account keys and /v1/me
GET /v1/me works with an account key and returns {user:{id,email,name,created_at,is_disabled}, orgs:[{id,name,slug,plan,ip_capture_default,created_at}], mfa_enabled, passkey_count}; for an account key it also returns key_scopes (the key's own scopes, which the hosted MCP uses to list only the tools they allow) and key_org_ids (the org_ids the key was restricted to; empty when it is not restricted). A restricted key sees only those orgs in orgs. A capture-only project key (secret key with only the capture scope) reads nothing, so GET /v1/me with it is 404. Everything else under /v1/me needs a session.
Method and path | Auth | Purpose |
|---|---|---|
| key or session | who am I, my orgs |
| session | delete my account |
| session | name |
| session | start an email change (mails a confirmation link to the new address) |
| session | change password; signs out every other session |
| session | UI and notification preferences |
| session, or an all-orgs account key holding | list, create account keys (a key grants only scopes it holds). Any other key: |
| session | rotate (same name, scopes, org list, expiry; old key revoked) or revoke |
| session | apps I authorised; revoke one |
An account key is created in the app (Personal settings > API keys) or with a session:
POST /v1/me/keys {"name":"provisioning","scopes":["org:read","org:write","project:write","*:read","*:write"],"org_ids":[],"expires_at":null}Never hand an unrestricted account key to an integrator, vendor or any third party. An account key with empty
org_idssees every org of the person who minted it. For a third party, mint a key restricted to their org from a session:POST /v1/me/keyswith"org_ids":["<their org id>"]and only the scopes they need. Then check it before you hand it over:GET /v1/orgswith the new key must list exactly one org.
org_ids limits the key to those orgs (each must be one you belong to); empty means all of yours, except that the org admin scopes need exactly one. If you are removed from an org, the key stops seeing it at once (404). The full first-key walkthrough (including the browserless device flow) is in Account API keys.
Sessions versus keys: what only a session can do
Sign-in routes (/v1/auth/signup, login, mfa, passkeys/*, password/*, email/*, sso/*, social/*, logout, sessions) belong to people, not scripts. Cookie-authenticated mutations are checked against CSRF: the Origin header must be the API host or an allowed origin, else 403 (bearer-key requests are exempt). Prefer keys for automation. Session-only actions an agent must hand to the user:
create, list, rotate or revoke account keys (
/v1/me/keys); delete the account; change password or email; enrol MFA or passkeysdelete an org (
DELETE /v1/orgs/{org_id}, owner only; a key gets404); leave an org; impersonate a memberbilling checkout, portal, spend limits; org domains, IP allow-list, security policy, audit sinks, OAuth apps, trusted IdPs, region pin
move a project to another org; create a test project
the
/v1/instance/*operator routes
OAuth apps and tokens
Use OAuth when an app acts for a user on one project (the CLI, MCP clients, third-party tools). Endpoints (metadata at /.well-known/oauth-authorization-server and /.well-known/oauth-protected-resource, both public):
Method and path | Auth | Purpose |
|---|---|---|
| none | dynamic client registration (RFC 7591): |
| session | consent screen validation and the user's decision (PKCE |
| none | device grant (RFC 8628): form |
| session | the page where the user approves a |
| client | form-encoded. |
| client | RFC 7009 |
| session | org-owned registered apps ( |
| session | enterprise IdPs trusted for the JWT-bearer (ID-JAG) grant |
Access tokens last 1 hour (15 minutes for the JWT-bearer grant); refresh tokens last 30 days and rotate on use (reusing one revokes the whole authorisation). Token errors use RFC 6749 names. Verified live:
R=$(curl -sS -X POST "$LUCIDA_API/v1/oauth/register" -H 'Content-Type: application/json' -d '{
"client_name":"my-cli","grant_types":["urn:ietf:params:oauth:grant-type:device_code"],
"token_endpoint_auth_method":"none","scope":"flag:read"}')
CID=$(echo "$R" | jq -r .client_id)
D=$(curl -sS -X POST "$LUCIDA_API/v1/oauth/device_authorization" -d "client_id=$CID&scope=flag:read")
echo "$D" | jq '{user_code, verification_uri_complete, interval}' # show this to the user
curl -sS -X POST "$LUCIDA_API/v1/oauth/token" \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code=$(echo "$D" | jq -r .device_code)&client_id=$CID"
# 400 {"error":"authorization_pending"} until the user approves; then access_token, refresh_token, scope, project_idAn unauthorised call to /mcp answers 401 with a WWW-Authenticate header pointing at /.well-known/oauth-protected-resource.
Versioning header
Send Lucida-Version: YYYY-MM-DD on management calls to pin the API; the response echoes the version served. No header means the newest. A non-date or too-old value is 400; a future date resolves to the newest (verified: 2026-11-01 today). Capture-host routes have a fixed wire format. Details and the deprecation policy (Deprecation and Sunset headers, six months minimum): API versioning.