Idempotency Guide
Why Idempotency Matters
Syllecta prevents duplicate writes by enforcing one record per (tenant, scope, key) pair. The same principle applies to webhooks: replays are filtered before they reach your backend.
Core Concepts
- Scope – logical grouping of requests (e.g.,
orders,payouts). - Key – unique identifier within the scope (
order-1001,invoice-55). - Lock –
POST /v1/recordreturnslocked: truewhen you may proceed with work. - TTL – records live for 24 hours by default (configurable).
Recommended Flow
- Call
POST /v1/recordwithscope+key. - If
cached: true, reuse the stored record and skip the write. - If
locked: true, perform the write andPUT /v1/recordwith the final body/status. - If
locked: false, waitretryAfterMsand try again.
Example Workflow
bash
curl -X POST https://cloud.syllecta.example/v1/record \ -H "Authorization: Bearer <API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "scope": "orders", "key": "order-2001" }'
bash
curl -X PUT https://cloud.syllecta.example/v1/record \ -H "Authorization: Bearer <API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "scope": "orders", "key": "order-2001", "body": { "status": "paid" } }'
Handling Responses
- Record already exists:
json
{ "cached": true }
Reuse stored record.
- Lock acquired:
json
{ "locked": true }
Execute write and save.
- Another request is in progress:
json
{ "locked": false, "retryAfterMs": 1500 }
Retry after the suggested delay.
- Usage limit exceeded:
json
{ "status": 429 }
Review plan usage.
Webhook Idempotency
- Syllecta dedupes webhook events using provider IDs (Stripe
event.id, ShopifyX-Request-Id, etc.). - Duplicates return:
json
{ "ok": true, "cached": true }
and your callback is not hit again.
- You can see replay counts per provider in Events by filtering on status
cached.
Checklist
- Each logical write uses a stable
scope+key. - Handlers only proceed after
locked: true. - Retries respect
retryAfterMs. - Usage is monitored in Backoffice.