Developer guide: control Lucida from code
Everything Lucida does, over HTTP, from one account API key: keys, organizations and projects, capture, data management, queries and SQL, insights and dashboards, cohorts and metrics, alerts and exports, flags, experiments, guides, replay, heatmaps, web analytics, connectors, webhooks, CLI, SDKs and MCP. Written so an AI agent can implement any of it end to end.
This page takes you from a single account API key (lc_pat_...) to any Lucida capability without opening the app. Every step is a curl call you can paste, and the main flows were run against the live API before publishing. The short endpoint list by area is in API reference map; the complete machine-readable description is GET /v1/openapi.json.
The guide is one page per section so you can fetch only the part you need; this page is the index and the agent instructions.
Contents: How to use this guide · Sections
How to use this guide (for AI agents)
This page is written so an agent can implement any Lucida capability with curl and nothing else. Follow this order:
Set up the shell (section 0). Everything below reuses
lc,$LUCIDA_API,$LUCIDA_CAPTURE,$ORG_ID,$PROJECT_ID,$PKand$SK.Pick the key with the table below. When in doubt, use the account key for management calls and the project secret key for sending data.
Find or create the org and project (sections 1 and 2). The project id is in every URL after that.
Read the capability sections (queries, flags, experiments, replay, web analytics) in the later sections.
Handle errors with section 5 before you retry anything.
Discover anything this page does not spell out from the machine-readable contracts. Both are public (no key):
# Every route: path, method, security (session / bearer), x-required-scopes, request and response schemas
curl -sS "$LUCIDA_API/v1/openapi.json" -o openapi.json
jq -r '.paths | keys[]' openapi.json | grep '/flags' # find routes
jq '.paths["/v1/projects/{project_id}/flags"].post' openapi.json # one operation
jq '.components.schemas.CreateKey' openapi.json # one schema
# The analytics query language (trends, funnel, retention, ...) as JSON Schema
curl -sS "$LUCIDA_API/v1/query.schema.json" | jq '.oneOf | length'
# The scope catalogue and the OAuth metadata
curl -sS "$LUCIDA_API/v1/scopes" | jq -r '.[].name'
curl -sS "$LUCIDA_API/.well-known/oauth-authorization-server" | jq .Read an operation like this: security lists bearer (a key works) and/or session (a signed-in browser session works). An operation that lists only session is meant for people in the app. x-required-scopes lists scopes that must all be held; x-required-scopes-any lists scopes of which one is enough (and admin always passes a project route). For org and account routes this field is accurate (checked against the live service): an operation marked only session is not available to a key (PATCH org settings answers a key 404), and an operation that lists bearer accepts a key holding the scope in x-required-scopes. Section 2 lists the org routes a key can use.
Which key do I use?
I want to... | Use | Host |
|---|---|---|
Create orgs and projects, mint project keys | account key | API |
Read or change anything inside one project | account key, or a project secret key with scopes | API |
Send events from a server, import history | project secret key | capture |
Send events from a browser or app | project public key | capture |
Evaluate flags for a user | public key (or secret key) | capture |
Give a CI job or BI tool narrow access to one project | project secret key with chosen scopes | API |
Run an AI agent over MCP | account key ( | API |
Create account keys, change password, delete an org | a signed-in browser session; no key can | API |
Paths in tables use {p} for /v1/projects/{project_id}. Placeholders such as {org_id} are path parameters. "Session only" means an account key or project key gets 404 (or 403 with a message) and you must ask the user to do it in the app.
Sections
Each section is its own page, so an agent can fetch only the part it needs.
0. Set up your shell: Define the lc helper, the API and capture hosts and the key variables every later call reuses.
1. Keys and authentication: Key types, scopes, environments, project keys, account keys, sessions versus keys, OAuth apps and the versioning header.
2. Organizations and projects: Orgs, creating projects, project routes, org administration and the routes only a session can call.
3. Sending data (capture host): The capture host: batch and capture wire format, responses, identity, reserved properties, flag exposure events, limits, consent and the browser script contract.
4. Events, persons, groups and data management: Events, persons, groups, definitions and the data catalogue, privacy and deletion.
5. Errors, pagination, rate limits, idempotency, async patterns, versioning: Problem+json errors, cursor pagination, rate limits, idempotency, async patterns and API versioning.
6. Querying: The query endpoint, query building blocks, funnels, retention, SQL, saved queries and endpoints.
7. Insights, dashboards and notebooks: Saving queries as insights, dashboards, notebooks and sharing them.
8. People analysis: Cohorts, actions, metrics, lifecycle, paths and other people analysis over the API.
9. Alerts, subscriptions, reports and exports: Alerts, subscriptions, scheduled reports, exports and share links.
10. Feature flags: Create and evaluate feature flags: conditions, rollouts, payloads, exposure, scheduling and approvals.
11. Experiments: Create, run and read experiments: metrics, exposures, power and results.
12. In-product experiences: Guides, tours, announcements, early access and other in-product experiences over the API.
13. Session replay and heatmaps: Session replay ingest, search, retention, playlists and heatmaps over the API.
14. Web analytics, live view and Replay Vision: Web analytics reports, the live view and Replay Vision over the API.
15. Integrations, webhooks, CLI and SDKs: Connectors, destinations, warehouse sources, outbound webhooks, the CLI and the SDKs.
16. AI and agents: The MCP server, agent runs and records, and the AI routes.