Software Engineer Interview Question

What does it mean for an endpoint to be idempotent, and how would you make a create endpoint idempotent?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

An idempotent endpoint produces the same result whether it is called once or five times with the same input. GET, PUT and DELETE are naturally idempotent; POST is not. You make a create endpoint idempotent by having the client send a unique idempotency key, storing that key alongside the created resource in the same transaction, and returning the original result on any repeat.

Why interviewers ask this

Retries are everywhere: clients retry, load balancers retry, queues redeliver. The interviewer wants to know whether you design for at least once delivery instead of assuming each request arrives exactly once. They are listening for the idempotency key pattern, for the detail that the key and the write must commit together, and for awareness of the race when two identical requests land at the same moment.

How to structure your answer

  • Define idempotency in terms of repeated calls, not read only calls.
  • Explain why POST needs help and PUT does not.
  • Describe the idempotency key flow end to end.
  • Cover the concurrent duplicate case with a unique constraint.

Example answer

Spoken example, first person

Idempotent means calling it twice leaves the system in the same state as calling it once. PUT is idempotent because you are stating the final state; POST usually is not, because each call means make another one. For a create endpoint I have the client generate a key, typically a UUID, and send it as a header. Server side I store that key in a table with a unique constraint, and I write it in the same transaction as the resource itself, because if those two commits can diverge the whole scheme is decorative. If the same key comes back, I look it up and return the original response with the original status. The part people miss is the concurrent case, where two retries land in the same millisecond. The unique index handles that: the second insert fails, I catch the violation and read back the winner rather than erroring. I built this for a payments endpoint after we double charged somebody during a network blip.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How long would you keep idempotency keys around?
  • What status code do you return on a replayed request?
  • What if the retry sends the same key but a different body?

Related software engineer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot