Real-time destinations: filter, dry run, delivery log and replay
Send only the events you choose to a webhook as they are ingested: filters, mapping, a dry run that renders the request, retries, the per-attempt delivery log, the dead-letter queue and replay, and what consent and internal traffic do.
A real-time destination is a connector (here the generic webhook) that receives events from your project as they are ingested, after your filter and mapping. Every call below is under $API/v1/projects/$PROJECT with a key that has connector:read and connector:write. Delivery is at least once: the event uuid is sent as the record id, so dedupe on it.
lc() { curl -sS -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" "$@"; }
C="$API/v1/projects/$PROJECT/connectors"1. Create the destination
lc -X POST "$C?skip_check=true" -d '{
"kind":"webhook","name":"Purchases to ops",
"config":{"url":"https://example.com/hooks/lucida"},
"credentials":{"webhook_secret":"<your signing secret>"}}'To start the destination already filtered, add "route": {...} to the create body: it takes exactly the fields of the routing call in section 2 (filter, transform, realtime, consent, internal, cohorts, ...) and is validated the same way, so an invalid route creates nothing (422). A destination receives live events only once realtime is true. sync_interval_secs does not apply to destinations (it is the pull schedule of sources; 0 or absent means the 900 s default).
The response is the connector (id, kind, name, status, config, has_credentials). Without skip_check=true Lucida first sends one signed webhook.test request and refuses the create if it fails. The URL must be http or https and must resolve to a public address. Config also takes method (POST default, PUT, PATCH, DELETE, GET), query and headers (name to expression) and body_template (a JSON template). With a webhook_secret every body is signed: X-Lucida-Signature: sha256=<hex HMAC-SHA256 of the body>.
Default body, one request per batch of matching events:
{"project_id":"...","records":[{"kind":"event","id":"<event uuid>","event":"purchase","distinct_id":"u1",
"timestamp":"2026-11-11T10:00:00Z","title":"","url":"","properties":{"plan":"pro"}}]}With body_template set, the destination sends one request per record with that body instead.
2. Set the filter, the mapping and turn on real time
PUT .../{id}/routing stores the route. filter and transform are YAML strings; realtime: true is what makes the connector receive live events.
CID=<connector id>
lc -X PUT "$C/$CID/routing" -d '{
"realtime": true,
"filter": "events: [purchase]\nwhere:\n - {path: props.plan, op: eq, value: pro}",
"transform": "transform:\n - kind: event\n fields:\n event: {from: event}\n distinct_id: {from: distinct_id}\n ts: {from: ts}\n props.plan: {from: props.plan}\n props.amount: {from: props.amount}"}'Filter grammar
The filter is a YAML mapping with only these keys:
Key | Value |
|---|---|
| list of event names; absent or empty is any event |
| list of |
| a list of conditions that must all hold, or one expression string |
A condition is {path, op, value}. Paths: event, distinct_id, kind, props.<name>. Ops: eq, neq, set, is_not_set, in (value is a list), gt, gte, lt, lte, contains, not_contains, regex. Groups: {op: and, args: [...]}, {op: or, args: [...]} and {op: not, args: [<one condition>]}.
The expression form reads where: "plan = pro and not (country = DE or country = AT)": ops =, !=, >, >=, <, <=, ~ (contains), !~ (not contains), =~ (regex), is set, is not set, combined with and, or, not and parentheses; a bare name means props.<name>.
events: [item_viewed, item_saved]
where:
- {path: props.plan, op: in, value: [pro, team]}
- {op: not, args: [{path: props.country, op: eq, value: DE}]}Any other key (event:, a typo, bogus_key:), an unknown op, a condition key other than path, op, value, args, or invalid YAML is a 422 that names the accepted keys: nothing is stored, so a mistyped filter never widens what is sent. A filter saved before this check that no longer parses stops the destination's delivery (it is reported as a routing error) instead of sending everything.
The transform is an allowlist: only the fields you map reach the destination, and the event id stays the original. Test a custom-code transform with POST $C/transform/test ({code, event, inputs} returns {output, logs, ok, elapsed_ms, error}).
Cohort limit: "cohorts":["<cohort uuid>"] (at most 20) sends only events of people in any listed cohort; if the membership lookup is down nothing is sent and the batch retries. There is no separate group filter: use a where on the group property your events carry.
Changes reach the live dispatcher within about 30 seconds (it caches the destination list for that long).
3. Dry run: render the request without sending
lc "$C/$CID/preview/events" # recent events you can pick
lc -X POST "$C/$CID/preview" -d '{"record":{"event":"purchase","distinct_id":"u1","properties":{"plan":"pro","amount":42}}}'{"matched":true,"dropped":[],"requests":[{"method":"POST","url":"https://example.com/hooks/lucida",
"headers":{"X-Lucida-Signature":"REDACTED"},"body":"{\"project_id\":...}"}]}matched says whether the filter, the default rules in section 5 and the sensitive-property policy let the record through; dropped says why a record is not sent: filter, internal, consent, consent: waiting for ... (held, missing: hold) or the transform error; requests is what would be sent, built by the real destination code against a recorder, with credentials redacted. Nothing leaves Lucida. The cohort filter is not applied in the preview, and the person's stored consent is not looked up: pass it as "person": {"consent": {"marketing": "granted"}} next to record, or put it on the record as properties.$consent: {"marketing": true} or properties.$consent_marketing: "granted". Without either, the record has no recorded decision.
lc -X POST "$C/$CID/preview" -d '{"record":{"event":"item_viewed","distinct_id":"u1"},"person":{"consent":{"marketing":"granted"}}}'
# {"matched":true,"dropped":[],...}
lc -X POST "$C/$CID/preview" -d '{"record":{"event":"item_viewed","distinct_id":"u1"}}'
# {"matched":false,"dropped":["consent"],...} with consent {categories:[marketing], missing:drop}
``` `POST .../estimate` counts the events of the last `days` (default 7, at most 30) the filter would have matched.
## 4. Enable
A created connector is `active`. Pause and resume with `POST $C/$CID/disable` and `POST $C/$CID/enable` (`status` becomes `paused` or `active`). A paused destination receives nothing.
## 5. What is delivered, and what never is
- **Opted-out people.** A person with any explicit consent denial never reaches a destination (the event's `$consent`, or the person's stored `$consent`). No recorded decision counts as no denial. A route can require specific categories with `"consent":{"categories":["marketing"],"missing":"drop"}`; `missing` is `drop`, `hold` (parked in the DLQ until a replay re-checks) or `allow`. A denial always drops.
- **Where consent is read.** Decisions are a map of category to granted or denied: the person's stored consent first (set by `$consent_updated` events and the SDK's `consent` call), else the event's `properties.$consent` (the browser SDK stamps it on every event), else flat event properties `$consent_<category>` (for example `$consent_marketing: "granted"`). Values `true`, `"granted"`, `"yes"`, `"1"` grant; `false`, `"denied"`, `"no"`, `"0"` deny. Category names are free text matched exactly: the SDK's own are `analytics`, `replay` and `marketing`; a consent manager's ids (for example Cookie Munch's) work as long as the route names the same id.
- **`$internal` events** (flagged by your internal-traffic rules or the SDK) never leave unless the destination is marked internal: `"internal": true` on the routing call.
- Properties classified as personal or sensitive are dropped by default (`sensitive` policy on the routing call).
- Filtered and withheld events are counted as `filtered`; they are not logged one by one.
## 6. Retries and the per-attempt delivery log
A failing request is retried with jittered backoff: a `5xx`, `429` (honouring `Retry-After`), `408` or a network error retries; any other `4xx` is permanent and the records go to the DLQ at once. A delivery makes up to 4 attempts, and each attempt's HTTP client may itself make up to 5 requests. **Every failed request writes one `warn` line** (`attempt 1: HTTP 503`, `attempt 2: HTTP 503`; a network error reads `attempt 3 failed: ...`), then the outcome writes one line: `delivered N record(s)` (`info`) or `delivery failed, N record(s) parked: ...` (`error`). Counters count outcomes (records succeeded, failed, filtered), not attempts.
```sh
lc "$C/$CID/delivery-log?limit=20" # {data:[{id,at,level,message,response?}], next_cursor}, newest first
lc "$C/$CID/delivery-log?level=error" # info, warn or error
lc "$C/$CID/stats?window=24h" # totals {succeeded,failed,filtered}, hourly series, quarantineResponse bodies appear in the log only with "log_responses": true on the routing call (the first 1 KiB, on the outcome line). The log keeps 14 days. A destination whose failures reach 80% of at least 20 deliveries within an hour is quarantined for 30 minutes: its records are parked, not sent. POST $C/$CID/unquarantine lifts it.
7. Dead-letter queue and replay
lc "$C/$CID/dlq?limit=20" # {data:[{id,stream,payload,error,created_at}], next_cursor}
lc -X POST "$C/$CID/dlq/replay" -d '{"limit":100}' # {"replayed": 3}limit is 1 to 500. A replayed record is deleted from the queue on success and stays parked if it still fails. Lucida also redrives parked records by itself for 24 hours with doubling backoff from 1 minute to 1 hour; after that, replay by hand. Replay re-checks consent for records held for it and drops those the person has since denied.
8. How fast is delivery
Events flow from the ingest worker to the destination dispatcher through a queue, and a matching event is sent in the same pass, with no polling interval. Expect seconds under normal load; there is no latency guarantee, and retries and backoff add to it when the destination is failing. A newly enabled or changed route may take up to 30 seconds to be picked up. "trigger":{"mode":"batched","interval_secs":300} on the routing call holds matching events and sends them on that interval instead (60 to 86400 seconds).
See also Outbound webhooks (signed callbacks for Lucida's own events) and the developer guide, section 15.