Light AIDocs Beta Open Light AI

Concepts

Idempotency

Send an Idempotency-Key with writes so retries never create duplicates or charge twice.

Add Idempotency-Key (8–128 visible ASCII characters; a UUID is ideal) to write requests (POST and PATCH; each reference page says whether it applies). The same key with the same body replays the first response for 24 hours, with Idempotent-Replayed: true.

curl -X POST "https://api.light-ai.app/v1/leads" \
  -H "Authorization: Bearer $LIGHT_AI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "source": "api",
  "contact": {
    "first_name": "Dana",
    "email": "dana@example.com"
  }
}'
SituationAnswer
Same key, same body, first request finishedThe stored response, Idempotent-Replayed: true
Same key while the first is still runningWaits for the first to finish, then answers with its stored response (Idempotent-Replayed: true); if the first failed, the retry runs as a new request
Same key, different body422 idempotency_key_reused

Mockups#

POST /v1/projects/{id}/mockups requires the header, and its replay is permanent (not only 24 hours): a retry with the same key returns the same generation and never charges again. For live keys it is scoped to the organization and your partner account (or the organization alone for organization keys), not to one API key, so a retry after rolling a key is still safe.

Keys in automation tools#

Use a value that is stable across retries of one logical request, ideally the source record id (meta-{{leadgen_id}}). In n8n without one, use {{$execution.id}}-{{$runIndex}}-{{$itemIndex}} so each item gets its own key. Idempotency keys are scoped to your API key and the organization (and live or test mode), so one partner workflow is safe across contractors.

Tip

Leads have a second safety net: an external_ref your integration already sent replays the original lead (replayed: true) at any time, not only within 24 hours.