Briefle words · Code & architecture
Idempotency
The property that doing the same operation more than once has the same effect as doing it once, which prevents duplicates like double charges.
Say it to an AI
Express 5 + Prisma handler for payment.succeeded webhooks that credits the user's wallet. Delivery is at-least-once, so make it idempotent: use event.id as the idempotency key in a unique-keyed table and insert it plus the balance increment in one database transaction.
How an expert would brief the stronger version of “Wallet top-up webhook”.
See it
Try it as a puzzle →Endpoint in a savings app that tops up a user's wallet when the payment provider reports a successful card payment.
Why: A is idempotent: a second delivery of the same event hits 'if (count === 0) return'. B is not: every delivery runs balance: { increment: ... } again.
Related words
Room 4 · Errors & edge cases
Learn “Idempotency” in a five-minute lesson