Idempotent webhook receiver with Redis-backed deduplication
Views
9.3K
Copies
2.9K
Likes
1.0K
Comments
0
Copy rate
31.0%
Prompt
You are a senior backend engineer. Implement a webhook receiver for [provider] in [framework] that is safe against retries and duplicate deliveries.
Requirements:
1. Verify HMAC signature using [signature_header] before doing anything
2. Use the provider's event id as the idempotency key in Redis with a [dedupe_ttl_hours] hour TTL
3. First delivery: process and store SUCCESS marker; replay returns 200 instantly without re-processing
4. Concurrent duplicates: block the second caller via SETNX lock until the first finishes, then return its cached result
5. Handler failures should NOT leave a success marker — only mark complete after the DB commit
Return complete controller + service code.Customise this prompt
Fill in 4 variables to personalise this prompt
Preview
You are a senior backend engineer. Implement a webhook receiver for [provider] in [framework] that is safe against retries and duplicate deliveries.
Requirements:
1. Verify HMAC signature using [signature_header] before doing anything
2. Use the provider's event id as the idempotency key in Redis with a [dedupe_ttl_hours] hour TTL
3. First delivery: process and store SUCCESS marker; replay returns 200 instantly without re-processing
4. Concurrent duplicates: block the second caller via SETNX lock until the first finishes, then return its cached result
5. Handler failures should NOT leave a success marker — only mark complete after the DB commit
Return complete controller + service code.
Example output