Idempotency

Networks fail. Send an Idempotency-Key header with every create so that a retry never makes a second lead.

curl
curl -X POST "https://api.visaflow.work/v1/leads" \
  -H "Authorization: Bearer vf_test_xxxxxxxx_PASTE_THE_REST_OF_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2b8e-1f4a-4a51-9b7e-3f2d5c8a9e10" \
  -d '{ "full_name": "PW Sample Lead", "email": "sample.lead@example.test", "consent": true }'

How it works

  • Use a new random value per submission. A UUID is best. Up to 255 letters, digits and the characters _ . : -
  • We keep the first answer for 24 hours, per key. Sending the same key and the same body again returns that answer with the header Idempotent-Replayed: true.
  • The same key with a different body returns 409 idempotency_conflict. Key order in the JSON does not matter.
  • If the first request is still running, a repeat waits up to 5 seconds for it, then answers 409 idempotency_in_progress.
  • Server errors (5xx) are not kept, so you can retry them with the same key.

A replayed answer

HTTP
HTTP/1.1 201 Created
Idempotent-Replayed: true

{ "id": "LEAD_ID", "status": "new", "assigned_to": null, "duplicate": false }

Duplicates without a key

Even without the header, a lead with a phone number or email we already have is not created twice: it is added to the existing lead and the answer says duplicate: true.