InterviewBuddy
All interview questions

How should an API handle a retry after a timeout?

Advanced

Answer

Assume the original operation may have succeeded even if the client never saw a response. Design safe retries with idempotent operations, unique constraints, or an idempotency key.

Explanation

A timeout is an uncertain outcome, not proof of failure. Returning the saved result for a repeated key prevents accidental duplicate side effects.

Example

POST /orders with Idempotency-Key: request-123