Skip to main content
Network failures happen. A request may succeed on the server but the response may never reach you. If you blindly retry, you’ll create a duplicate report and pay twice. AcreLens supports the standard Idempotency-Key header to prevent that.

How it works

  1. Generate a unique key for each logical operation — UUIDv4 is recommended.
  2. Send it on POST /v1/analyze or POST /v1/batch:
  1. AcreLens hashes <key>:<your-customer-id> with SHA-256 and uses that as the cache lookup. The original response gets stored alongside a hash of your request body.
  2. On retry, AcreLens compares your new request body (canonical JSON, keys sorted) to the stored hash:
    • Same key + same body → returns the original 202 response. No new report created. No charge.
    • Same key + different body → returns 409 idempotency_conflict. Use a fresh key for the new request.
    • No prior entry → proceeds as a new request and stores the response.

Lifetime

After 24 hours, the entry is purged. Reusing the same key after that point will create a new report — so don’t rely on idempotency keys for permanent deduplication.

When to use

  • Retries after network errors — connection timeouts, partial responses, 5xx
  • Background jobs — Inngest step retries, Celery, BullMQ, anything queue-driven
  • User-facing forms — generate the key on form render, attach it to the submit, prevent double-submit
  • Webhook handlers — if your webhook handler kicks off a /v1/analyze request, use a deterministic key derived from the webhook event ID

When not to use

  • Distinct logical operations — analyzing two different properties needs two different keys
  • After the 24-hour window — generate a fresh key for retries beyond that
  • Across different API keys — idempotency is scoped per customer, not per Authorization header

Conflict response

If you reuse a key with a different body — common bug: changing the address slightly and forgetting to regenerate the key — you’ll get:
Generate a new key for the new request and retry.

Safe retry pattern (Node)

The key insight: the same idempotency key is reused across all retry attempts. Generating a fresh key on each retry would defeat the protection.

Body canonicalization

Idempotency comparisons are body-aware, but field order doesn’t matter. Both of these match:
But these don’t:
(Note the trailing space in the second address.) Whitespace, case, and field values matter. Field order does not.