Send events over HTTP
The capture wire format: POST /v1/batch and /v1/capture, event fields, keys, timestamps, dedupe, limits and responses.
You do not need an SDK to send events. The capture host (the apiHost your SDK uses) accepts JSON over HTTPS. The same contract is in GET /v1/openapi.json under the capture tag.
Send a batch
curl -X POST "https://<your capture host>/v1/batch" -H "Content-Type: application/json" -d '{
"api_key": "lc_pk_...",
"batch": [
{
"uuid": "0192f4c4-7f0e-7c3a-9d21-5b1f0e8a4c11",
"event": "purchase",
"distinct_id": "user_123",
"timestamp": "2026-11-02T10:15:00Z",
"properties": {"amount": 49.5, "currency": "EUR"}
}
]
}'See also Evaluate flags over HTTP. Success is 200 with {"status":1}. Capture and flag responses carry ratelimit-limit, ratelimit-remaining and ratelimit-reset, so a server sender can slow down before a 429.
Route | Body | Keys | Notes |
|---|---|---|---|
|
| public or secret | up to 1000 events, 20 MB |
| one event, plus | public or secret | 1 MB |
| as | secret only ( | for servers and imports; historical timestamps are kept and events drain behind live traffic |
POST /v1/batch also accepts "historical_migration": true with a secret key to take the backfill lane.
Authentication
Send the project key as api_key in the body, or as Authorization: Bearer <key>, or as ?api_key=. The public key (lc_pk_...) is the one that ships in browsers and apps; the secret key is for servers. The public key is on Settings > Project > Keys from the day the project is created (GET /v1/projects/{id}/keys). Mint a secret key there when a server needs one: POST /v1/projects/{id}/keys with {"kind":"secret","scopes":["capture"]} sends events and reads nothing; a secret key without scopes is refused. Check what a key can do with GET /v1/keys/self on the capture host (kind, scopes, project_id, environment, expires_at, name, prefix; never the secret). The project and organization always come from the key; any $lc_* property you send is stripped.
Event fields
Field | Required | Meaning |
|---|---|---|
| yes | name; names starting with |
| yes | who did it; a string or number |
| recommended | a UUID. Lucida is at-least-once: retry with the same |
| no | RFC 3339 ( |
| no | JSON object; strings longer than 64 KiB are cut, an event over about 1 MiB is rejected |
Identify a person with {"event": "$identify", "distinct_id": "user_123", "properties": {"$anon_distinct_id": "<anonymous id>", "$set": {"email": "a@b.co"}}}; set person properties on any event with $set / $set_once / $unset. Each works at the top level of the event or inside properties (the form SDKs send); when both name a key, the top-level value wins.
Attach an event to a group (account, company) with "$groups": {"company": "co3"}, at the top level or inside properties. Group analytics (unique_groups, group filters and breakdowns) read it.
Properties Lucida sets for you
Which value wins. When the request carries a browser User-Agent, the value Lucida derives from it wins: it replaces anything you sent for $browser, $browser_version, $os, $os_version, $device_type, $device_brand and $device_model (so $device_type: "Desktop" is stored as desktop). $device_type is one of desktop, mobile, tablet, bot, tv, console.
Server events keep what they send. A request from a server library (a User-Agent such as node, python-requests or Go-http-client) or with no User-Agent derives nothing, so a server event is stored with the $browser, $os and $device_type it carries, and without them if it carries none. To keep your own value on an event a browser sends, use a different property name.
Sending from a server
A server sends the same events as a browser, with a few properties that change how Lucida stores them. The first three go inside properties.
Property | Effect |
|---|---|
| Skip the GeoIP lookup for this event. Without it Lucida looks up the request's IP, which for a server is the server's own address, so every event gets the server's country, region, city and timezone. Set it on every server event that is not about the server itself. |
| Store the event without creating or updating a person. Use it for system events with no real user. If you send no |
| Free text naming what sent the event, for example |
| A UUID for the event. A retry with the same |
Properties that begin with $lc_ are Lucida's own and are removed from what you send. To name the end user's address instead of your server's, send the event to POST /v1/s2s/batch with a secret key and set $client_ip to that address; geolocation then uses it.
One event you can copy (replace the key, and use a new uuid per event):
curl -X POST "https://capture.lucidace.com/v1/batch" -H "Content-Type: application/json" -d '{
"api_key": "lc_sk_...",
"batch": [{
"uuid": "0192f4c4-7f0e-7c3a-9d21-5b1f0e8a4c11",
"event": "order_paid",
"distinct_id": "user_123",
"timestamp": "2026-11-06T10:15:00Z",
"properties": {"$lib": "billing-service", "$geoip_disable": true, "plan": "pro", "amount": 49.5}
}]
}'The Node SDK (@lucida-analytics/node) writes these for you: disableGeoip: true on the client, or on one capture call, sends $geoip_disable; processPersonProfile: false sends $process_person_profile: false; it sets $lib and a uuid on every event.
const lucida = new Lucida("lc_pk_...", { host: "https://capture.lucidace.com", disableGeoip: true });
lucida.capture({ distinctId: "user_123", event: "order_paid", properties: { plan: "pro", amount: 49.5 } });
await lucida.shutdown(); // flush before the process exitsTo assign flags from a server without a network call per read, see Local flag evaluation in the Node SDK.
Send a session recording
POST /v1/replay takes rrweb chunks: {"api_key": "lc_pk_...", "session_id": "<uuid>", "window_id": "<tab id>", "seq": 0, "events": [...]}; answer 200 {"status":1}. session_id, seq and events are required (400 otherwise); window_id is optional. Three equivalent ways to compress: send events as a base64 gzip string of the JSON array together with ?compression=gzip; gzip the whole body (Content-Encoding: gzip, or ?compression=gzip on a gzipped body); or send plain JSON. Limits: 10 MB decompressed per chunk.
Start a session with an rrweb Meta event (
type: 4) and a FullSnapshot (type: 2), then Incremental events (type: 3).seqrises by one per chunk within a window and restarts when you start a new session.To link a recording to your events, set
$session_idon those events to the samesession_id.Inputs are masked by the SDK; a non-SDK sender is responsible for masking before sending, see Replay privacy.
The recordings list is
POST /v1/projects/{id}/replays/searchwith a JSON body. Every field is optional; withoutdate_rangeit covers the last 30 days.limit(1 to 500, default 50) andcursorpage it: the answer is{data, next_cursor}.
Responses and retries
Status | Meaning | Retry? |
|---|---|---|
| accepted. | no |
| malformed body, empty batch, or on | fix it first |
| missing or unknown key, or a public key on | no |
| body, batch (over 1000 events) or single event too large | split it |
| rate or plan quota; see | yes, with backoff |
| try again | yes, same |
How uuid dedupe works
Delivery is at least once, so duplicates are removed in two places. /v1/batch and /v1/s2s/batch take the same path, so the same rules apply to both. The gateway itself does not dedupe.
Ingest worker, 10 minutes. The worker drops an event whose
uuidit saw in the last 10 minutes. By default the memory is per worker process. A deployment can share it across workers with Redis (LC_DEDUPE_REDIS_URL); that key includes the project. If that store is down, events pass through and the next step dedupes.Storage, no time limit but not immediate. Events are stored in a ClickHouse
ReplacingMergeTreetable. Rows are collapsed when they have the same project, the same UTC day oftimestamp, the same event name, the samedistinct_idand the sameuuid. A repeat with the sameuuidbut a different event name,distinct_idor day is a different row and is not collapsed. Collapsing happens in background merges, so for a short time both rows can exist. Lucida's event queries read withFINAL, which collapses them at read time, so query results count the event once. A direct read of the table withoutFINALcan still see both until the merge.Scope. The match is inside one project, whoever sent the event: two senders that use the same
uuidwith the same event name,distinct_idand day are one event. The project is taken from the key and is part of the storage key.Retried batches. A batch that the pipeline redelivers is also protected by a ClickHouse insert deduplication token built from the queue offsets (the last 1,000 inserts per table). You do not set it.
Retrying safely (server integrations)
Retry only these, and always with the same uuid on every event so a repeat is dropped, not counted twice:
no response at all (network error, timeout, connection reset), and
408429: the response carriesRetry-Afterin whole seconds; wait at least that long500,502,503,504. During a Lucida deploy the edge answers502or503with a plain-text body, noRetry-Afterand nox-request-id. The gateway itself answers503(problem+json, noRetry-After) when it cannot look up the key or reach the ingest queue.
Do not retry 400, 401, 413 or any other 4xx; the same request fails the same way. Split a 413.
Back off exponentially with jitter: 1 s, 2 s, 4 s, 8 s, 16 s, then 30 s steps, each randomised to 50-100%. If Retry-After is longer, wait for it (cap it at 60 s). The Node and browser SDKs honour it from 0.1.1. Our server SDKs (Python, Go, and Node 0.1.1 and later; 0.1.0 on npm ignores Retry-After) do exactly this, with 5 retries by default, which is about 15-31 s of waiting plus up to 10 s per request. After that the batch is given up on and your onError / OnError / on_error hook receives it, so a longer outage loses events. A deploy can interrupt capture for several minutes, so a server that must not lose events should retry for about 10 minutes: raise the retry count (fetchRetryCount in Node, max_retries in Python, MaxRetries in Go; 16 retries is about 3 to 6 minutes) or keep the events in your own outbox and resend. The SDK queue holds 1000 events and drops the oldest beyond that, so size your own outbox if you send faster than that during the wait. The browser SDK retries 5xx, 429 and network failures with the same backoff but cannot read Retry-After across origins; captureImmediate in Node makes 3 attempts within about a second.
Errors are RFC 9457 application/problem+json with type https://lucidace.com/help/problems#<class>, the same scheme as the app API. Browser callers need the capture host in connect-src, see Content Security Policy.