Evaluate flags over HTTP
The flags decide route POST /v1/flags on the capture host, plus flag kinds, condition filters, rollout and sticky behaviour.
You do not need an SDK to read flags. The capture host (the apiHost your SDK uses) answers POST /v1/flags with the value of every flag for one user. The same route is in GET /v1/openapi.json under the capture tag. It is on the capture host, not the app host.
Request
curl -X POST "https://<your capture host>/v1/flags" -H "Content-Type: application/json" -d '{
"api_key": "lc_pk_...",
"distinct_id": "user_123",
"person_properties": {"plan": "pro"},
"flag_keys": ["new-checkout"]
}'Field | Required | Meaning |
|---|---|---|
| yes (or | public or secret project key |
| yes, unless | who to evaluate for |
| no | hash unit used instead of |
| no | properties for |
| no | group keys by type, and their properties, for |
| no | only evaluate these flags; omitted means all |
Response
{"flags": {"new-checkout": {"enabled": true, "value": true, "reason": "condition_match", "condition_index": 0}}, "request_id": "..."}If you sent flag_keys, any key this project does not have is listed in "unknown_flags":["..."], so a typo does not look like a flag that is off. The field is left out when there are none.
If your SDK ignores that field, the keys still show up: Data > Project health lists the 100 most recently requested unknown keys with the last time each was seen (read it with GET /v1/projects/{pid}/pipeline-health/unknown-flags, which returns {"data":[{"key","first_seen_at","last_seen_at"}]}). Keys longer than 200 characters are not recorded, and an unknown key is recorded within about 30 seconds of the request.
Per flag: enabled, value (true/false, or the variant key), variant and payload when there is one, reason and condition_index (the condition that decided it, -1 when none did).
| Meaning |
|---|---|
| a condition's filters and rollout matched |
| no condition matched; value is off |
| a stored assignment decided (see below) |
|
|
| the flag is disabled |
| a prerequisite flag decided it |
| needs a secret-key / server evaluation |
| no |
| held out, outside the layer, or not served to this app context |
| a QA preview override |
If the plan quota is exhausted the response is 200 with "quota_limited": true and no flags; keep your cached values.
Record exposure
POST /v1/flags only decides; it records nothing. An experiment's results count a person from their first exposure event, so an HTTP caller must send one. The SDKs do this for you (expose() in sdks/node/src/flags.ts): once per user, flag and value they send two events with the same properties.
Event | Properties |
|---|---|
|
|
| the same properties |
Experiment results read event IN ('$exposure', '$feature_flag_called') where $feature_flag equals the experiment's flag key, and take the variant from $feature_flag_response, so $exposure alone is enough for experiments. $feature_flag_called is what the flag usage and stale-flag views count, so send it too when you want those. Send the variant key as a string: an empty variant is ignored. An experiment can also name a custom exposure event instead.
Send them with the capture route when you act on the value, with the same distinct_id you decided for:
curl -X POST "https://<your capture host>/v1/batch" -H "Content-Type: application/json" -d '{
"api_key": "lc_pk_...",
"batch": [
{"event": "$feature_flag_called", "distinct_id": "user_123",
"properties": {"$feature_flag": "new-checkout", "$feature_flag_response": "test",
"locally_evaluated": false, "$feature_flag_request_id": "<request_id from the decide response>"}},
{"event": "$exposure", "distinct_id": "user_123",
"properties": {"$feature_flag": "new-checkout", "$feature_flag_response": "test",
"locally_evaluated": false, "$feature_flag_request_id": "<request_id from the decide response>"}}
]
}'Give each event a uuid if you retry, so a duplicate is dropped. Do not send an exposure when your own fallback was served because the call failed: that is not an exposure (the SDKs skip it too).
One call instead. Add "record_exposure": true (default false) to the /v1/flags body and Lucida records both $feature_flag_called and $exposure for each flag it returns that decided (a flag that needs the server, or has no bucketing key, is skipped), so no second request is needed. It works on /v1/flags only, not /decide or /v1/flags/batch.
Dedupe window. Each event gets a deterministic id derived from the project, distinct_id, flag, value and the UTC day. Calling again for the same user, flag and value on the same UTC day (a retry, a page reload) adds no extra row once the warehouse merges duplicates (usually within minutes; reads with FINAL are exact at once). The exact key is the UUIDv5 of project|distinct_id|flag|value|UTC day (YYYY-MM-DD)|event name, one per event of the pair. A new value (the user moved from control to test) or a new UTC day records a new exposure.
Why per day. The key bounds the exposure log to one row per user, flag and value per day, so a busy page or a retry loop does not write one row per call, while a returning user and a changed variant still show up on the day they happen. It does not change experiment results: analysis attributes each person (unit) to the variant of their first exposure (argMin by timestamp, over rows collapsed with FINAL) and counts them once, so the later daily rows only feed the "switched variants" check. "send_exposure": true is the older switch: same pair, but a random id on every call, so it is not deduped.
Errors
Errors are RFC 9457 application/problem+json with type https://lucidace.com/help/problems#<class>.
Status | Meaning | Retry? |
|---|---|---|
| malformed body, or no | fix it first |
| missing or unknown key | no |
| the request origin is on the project's flag blocklist | no |
| rate limit; see | yes, with backoff |
| flag definitions unavailable | yes |
Defining flags
Flags are created with POST /v1/projects/{project_id}/flags.
| Notes |
|---|---|
| the default; no |
| needs two or more |
| serves a JSON payload (can be encrypted) |
| variants for staged migrations |
| variants carrying model configuration |
Only multivariate, migration and ai_config take variants; anything else is 400.
A flag has ordered filters.conditions[]. A condition matches when all its filters[] pass and the unit falls inside its rollout_pct (0-100). The first matching condition decides. A filter is {type, key, op, value}:
| Reads |
|---|---|
|
|
| group properties (also needs |
| cohort membership |
| device / geo properties |
| the SDK's app version |
| another flag's value (prerequisite) |
| a multi-kind context (also needs |
| an event count in the session or page ( |
| |
|---|---|
| equality and set membership |
| strings |
| numbers |
| presence |
| dates |
| versions |
| list properties |
| request IP |
Change a flag's first-condition rollout with PATCH /v1/projects/{project_id}/flags/{id}/rollout {"rollout_pct": 100} (the old name rollout_percentage is still accepted).
Rollout and sticky behaviour
Each unit hashes to a fixed point in 0-100 using the flag key, its salt and the unit id. It is inside the rollout when that point is below rollout_pct. The hash does not depend on the percentage, so raising a rollout only adds users; it never removes anyone who was already in, and lowering it only removes the ones with the highest points.
stickiness(top level) chooses the unit that is hashed:distinct_id(default),person_id,device_id,group:<type>orcontext:<user|device|org>.filters.sticky: trueadditionally stores the assignment so it survives allocation changes. Only "on" results are stored: thetrueof a boolean flag, or the variant a user was served. A user who was outside the rollout is not pinned and is hashed again next time, so raising the rollout can turn them on. A pinned user keeps their value (reasonsticky_bucket) even if the rollout is later lowered or the variant weights change. The first stored assignment wins.