Skip to main content

How do you test idempotency in API endpoints?

  • idempotency
  • duplicate requests
  • data integrity

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Idempotent operations should produce the same result when called multiple times. Tests: (1) POST with same idempotency key twice, verify 200 (not 201) on second call and same response body. (2) Verify database state has only one record. (3) Test expired idempotency keys. (4) Test with different payloads but same key, should return error or original result. (5) PUT and DELETE should be naturally idempotent. (6) Concurrent requests with same key should not create duplicates. Common mistake: testing only the response, not the side effects.

What interviewers listen for

  • Schema-first thinking
    You validate response shape before you assert on values, every time.
  • Status-code literacy
    You can defend why 401 vs 403 vs 422 matters for the consumer.
  • Contract awareness
    You know when consumer-driven contract tests beat end-to-end checks.
  • Auth fluency
    You can describe rotating tokens across parallel workers without secrets in logs.

Terms to know

See all 35 api testing questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026