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.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/cc326868-3da8-44c3-92c4-1468318ae8d9/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: control Lucida from code" width="600" height="315"></a>

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:

  1. Set up the shell (section 0). Everything below reuses lc, $LUCIDA_API, $LUCIDA_CAPTURE, $ORG_ID, $PROJECT_ID, $PK and $SK.

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

  3. Find or create the org and project (sections 1 and 2). The project id is in every URL after that.

  4. Send data (section 3), then check it arrived (section 4).

  5. Read the capability sections (queries, flags, experiments, replay, web analytics) in the later sections.

  6. 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 lc_pat_...

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

capture

Send events from a browser or app

project public key lc_pk_...

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 (lc_pat_...)

API /mcp

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.

Updated