Developer guide: 5. Errors, pagination, rate limits, idempotency, async patterns, versioning
Problem+json errors, cursor pagination, rate limits, idempotency, async patterns and API versioning.
5. Errors, pagination, rate limits, idempotency, async patterns, versioning
Errors are RFC 9457 application/problem+json on both hosts:
{"type":"https://lucidace.com/help/problems#validation","title":"Validation failed","status":422,
"detail":"key: missing field `key`","errors":[{"field":"key","message":"missing field `key`"}],
"instance":"/v1/projects/.../flags","request_id":"01a1c20f-56c8-760b-8ec8-f0861c97dc6a"}Always read status and detail; errors[] appears on field-level failures. request_id (also the x-request-id header) is what to quote in a support request.
Status |
| Meaning (verified behaviour) |
|---|---|---|
|
| the request cannot be read or breaks a rule that no single field owns: unparsable JSON ( |
|
| well-formed JSON that does not fit the body: a missing or mistyped field, a bad timestamp, or an unknown field (for example |
|
| the JSON parsed but a field is missing or has the wrong type: |
|
| missing or unknown key ( |
|
| you can see the resource but lack the scope or role; the detail often names it |
|
| missing or inaccessible (wrong org, wrong project, session-only route with a key); also |
|
| wrong method for the route |
|
| a name or key already exists, or the state does not allow it: |
|
| batch over 1000 events, body or event too large |
|
| wrong |
| project lives in another region | |
|
| rate limit or plan quota; |
|
| retry with backoff; deploys can answer |
Other specific type suffixes you may see: approval-required (a change needs sign-off first), sso-required, seat-limit, org-limit, region-locked, ip-not-allowed, compliance / compliance-profile, share-password-required, report-cap-reached, ai-provider-required, audit-sink-required, replay-deleted, replay-erased, sensitive-key-destroyed, relationship_rejected, relationship_no_overlap, signup-restricted, captcha-failed. Branch on status and type, not on detail text. Treat the field-level split between 400 and 422 as informational: handle both as "fix the request".
Errors you can reproduce cheaply to test your client:
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/flags" -d '{bad' # 400 broken JSON
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/flags" -d '{}' # 422, errors[] names "key"
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/events?limit=abc" # 400, errors[] names "limit"
lc "$LUCIDA_API/v1/projects/00000000-0000-0000-0000-000000000000/events" # 404
curl -sS "$LUCIDA_API/v1/projects/$PROJECT_ID/events" # 401 no keyPagination is cursor based on every list: ?limit=&cursor= returns {"data":[...],"next_cursor":"..."}. Pass next_cursor back as cursor; null means the last page. Cursors are opaque; never build them. Share lists (insights, dashboards, notebooks, replays, replay playlists, heatmaps, web), GET {p}/replay-playlists, GET {p}/namespaces and GET {p}/holdouts follow the same shape. events also returns newer_cursor and older_cursor. Check the shape once for any list not named here.
CUR=""; while :; do
P=$(lc "$LUCIDA_API/v1/projects/$PROJECT_ID/event-definitions?limit=100${CUR:+&cursor=$CUR}")
echo "$P" | jq -r '.data[].name'
CUR=$(echo "$P" | jq -r '.next_cursor // empty'); [ -z "$CUR" ] && break
doneRate limits (details in Rate limits). Every limited route answers an empty bucket with 429 and Retry-After (whole seconds); wait at least that long, then back off with jitter. Responses carry RateLimit-Limit (burst), RateLimit-Remaining and RateLimit-Reset: slow down as Remaining nears 0 instead of waiting for a 429. On the capture host with a public key the headers describe the tighter of the per-IP and the per-project bucket, because that is the one that throttles you first.
Family | Default |
|---|---|
capture host events | 1000/s per project, burst 2000 (a batch of N costs N); public keys also 100/s per client IP |
flag evaluation | 100/s per project, burst 200 |
management API | 50 requests/s, burst 100, per key (or session, or IP) |
query ( | API keys 120 per minute per project; a key query reads at most 10 GiB |
MCP | 5/s, burst 20 |
sign-in, sign-up, reset, MFA, invites | per IP, email or user, fixed windows |
Plan quotas (events per month) are separate and also answer 429, with a quota message. Self-hosted limits are set by the operator (LC_RATE, LC_API_RATE, LC_MCP_RATE).
Idempotency.
Events: delivery is at-least-once and never exactly-once. Give every event a UUID
uuidand retry with the same one; a repeat is dropped. Retry only on network errors,408,429,500,502,503,504; never on other4xx.Backoff for capture: 1, 2, 4, 8, 16 s then 30 s steps, each randomised to 50 to 100 percent; honour
Retry-After(cap 60 s). For a deploy, keep trying for about 10 minutes or keep events in your own outbox.Management API: there is no generic
Idempotency-Keyheader. For creates, look the resource up first (flag keys, metric names and similar are unique and answer409). Key names are not unique, so list keys before minting to avoid duplicates.PUTandPATCHare safe to repeat;POSTactions (start,rotate,run) are not.
Async (202) patterns. These calls return 202 and finish later; do not assume the change is visible in the same second.
Call | What you get | How to finish |
|---|---|---|
|
| poll |
|
| applied through the pipeline; re-read after a few seconds |
|
| poll |
|
| poll |
|
| read the resource's |
Event capture |
| queryable after seconds; replays and rollups after minutes |
Config writes ( |
| gateway and worker caches refresh within 30 to 60 s |
Versioning. Lucida-Version: YYYY-MM-DD pins the management API (section 1). Within /v1, changes are additive: ignore fields and enum values you do not know. A breaking change ships only behind a new version date; deprecated routes send Deprecation and Sunset headers and stay for at least six months. Nothing is deprecated today.
Timestamps are RFC 3339 with Z in responses. Some ClickHouse-backed rows (groups, identity graph) show YYYY-MM-DD HH:MM:SS.mmm text; parse both.