Why is PUT idempotent by contract while POST is not?
PICTURE THIS: HOW TO EXPLAIN IT
Simple meaning
PUT of the same body to the same URL should leave the resource in the same state no matter how many times you retry.
WHY — Idempotency instead of guessing?
Why interviewers care about Idempotency:
on Idempotency.
the situation, the default choice, and one exception - that reads as experience.
Name the idea, why it exists, then one short example.
End with when you use it and one common pitfall.
STEPS — What happens step by step?
Before you speak the answer, walk the interviewer through these steps:
- 1PUT of the same
body to the same URL should leave the resource in the same state no matter how many times you retry.
- 2POST create is allowed
to insert a new row on every call, so a timeout plus retry can double-charge.
- 3Product APIs therefore put
an Idempotency-Key on POST /payments.
- 4Give an example
One tiny concrete case you can say aloud.
- 5Common mistake
What juniors usually get wrong.
- 6Close
When you pick this over the alternative.
EXAMPLE — See it in action
Here's a short line you can speak, broken into clear beats:
Note: Adapt this scaffold to your own project — keep it under 60–90 seconds.
Key takeaway
PUT of the same body to the same URL should leave the resource in the same state no matter how many times you retry. POST create is allowed to insert a new row on every call, so a timeout plus retry can double-charge.