How do you design an API that is safe to retry?

REST API design and errors · Experienced

Model answer

Make writes idempotent where possible (PUT instead of POST, or an idempotency key header stored with the result), return the same response for a repeated key, use unique constraints in the database to block duplicates, and use timeouts with exponential backoff on the client. Return clear error codes so clients know whether retrying is safe.

Learn this topic

Build a REST API: Create, Read, Update and Delete Tasks in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions