Send events over HTTP

The capture wire format: POST /v1/batch and /v1/capture, event fields, keys, timestamps, dedupe, limits and responses.

Embed
Preview of the card
<a href="https://lucidace.com/help/capture-wire"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/be6b02c6-8312-4af6-b3a5-e714bedbf191/social-card.svg?v=3e7ae33eec8b" alt="Send events over HTTP" width="600" height="315"></a>

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

POST /v1/batch

{api_key, batch: [event, ...], sent_at?}

public or secret

up to 1000 events, 20 MB

POST /v1/capture

one event, plus api_key

public or secret

1 MB

POST /v1/s2s/batch

as /v1/batch

secret only (401 otherwise)

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

event

yes

name; names starting with $ are Lucida's own ($pageview, $identify, ...)

distinct_id

yes

who did it; a string or number

uuid

recommended

a UUID. Lucida is at-least-once: retry with the same uuid and the duplicate is dropped (rules and limits: How uuid dedupe works). A value that is not a UUID discards that event; the 200 body then carries a warnings array (see below)

timestamp

no

RFC 3339 (2026-11-02T10:15:00Z). Omitted: arrival time. Public key: outside 30 days back to 1 hour ahead it is replaced by arrival time. Secret key: past values are kept, except those older than the project's retention, which are rejected (reason: "older_than_retention", nothing is stored); more than 23 hours ahead is replaced

properties

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

$geoip_disable: true

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.

$process_person_profile: false

Store the event without creating or updating a person. Use it for system events with no real user. If you send no distinct_id, Lucida uses the event's uuid (or a fresh one).

$lib

Free text naming what sent the event, for example "billing-service". Lucida does not validate it. The SDKs set $lib and $lib_version themselves.

uuid (top level)

A UUID for the event. A retry with the same uuid is dropped as a duplicate, so always set it when you may resend. A value that is not a UUID discards the event and the 200 body carries a warning.

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 exits

To 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).

  • seq rises by one per chunk within a window and restarts when you start a new session.

  • To link a recording to your events, set $session_id on those events to the same session_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/search with a JSON body. Every field is optional; without date_range it covers the last 30 days. limit (1 to 500, default 50) and cursor page it: the answer is {data, next_cursor}.

Responses and retries

Status

Meaning

Retry?

200 {"status":1}

accepted. /v1/batch and /v1/s2s/batch also answer "accepted":N,"rejected":[{"index":0,"reason":"..."}]: valid events are stored and each invalid one is listed by position, so check rejected and do not resend the batch (events dropped by an ingest rule or a traffic shield are accepted too). If the gateway discarded individual events (for example a uuid that is not a UUID), or kept one after fixing it (an unparseable timestamp replaced by arrival time, a timestamp too far ahead, a distinct_id that was shortened), the body also has "warnings":[{"index":0,"kind":"invalid_uuid","detail":"..."}], index being the event's position in the batch (a kept event still counts in accepted); a public-key request from an origin outside the project's capture_allowed_origins is acknowledged with the warning kind origin_not_allowed and stores nothing; the same warnings appear under ingestion warnings

no

400 problem+json

malformed body, empty batch, or on /v1/batch every event invalid (the detail names the first, such as event 0: ...). On other capture routes one invalid event rejects the request. Nothing was accepted and no warning is recorded

fix it first

401

missing or unknown key, or a public key on /v1/s2s/batch

no

413

body, batch (over 1000 events) or single event too large

split it

429

rate or plan quota; see Retry-After

yes, with backoff

5xx

try again

yes, same uuids

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 uuid it 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 ReplacingMergeTree table. Rows are collapsed when they have the same project, the same UTC day of timestamp, the same event name, the same distinct_id and the same uuid. A repeat with the same uuid but a different event name, distinct_id or 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 with FINAL, which collapses them at read time, so query results count the event once. A direct read of the table without FINAL can still see both until the merge.

  • Scope. The match is inside one project, whoever sent the event: two senders that use the same uuid with the same event name, distinct_id and 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 408

  • 429: the response carries Retry-After in whole seconds; wait at least that long

  • 500, 502, 503, 504. During a Lucida deploy the edge answers 502 or 503 with a plain-text body, no Retry-After and no x-request-id. The gateway itself answers 503 (problem+json, no Retry-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.

Updated