What Is Idempotence? Simply put, the outcome of processing the same message /api request repeatedly must be the same as processing the message/api request once. Idemptoency in rest APIs can be ensured by associating a logical api request (app to server / server to server request) with an unique idempotency key and hence getting the ability to track the api and all its retries and ensuring that api request is not processed twice). 

Relevance of idempotency in REST APIs

Idempotency ensures that an API request completes no more than one time. Idempotency important in rest api calls as duplicates of the same logical request can be created by retries.

note that event streaming platforms with at least once delivery guarantee can deliver the same message twice to subscriber.


Client associates a logical request with a unique idempotency key so that the request can be uniquely identified/tracked and duplicate requests can be removed , thus making the api calls idempotent. In other words An idempotency key is a unique value generated to recognize subsequent retries of the same logical request.Idempotency-Key request header should be included in api requests which should be handled by an Idempotent Receiver. Idempotent reciever extracts the Idempotency-Key and uses it to ignore duplicate requests made by the client on retries. 

Idempotency key can be a 

Idempotent receiver can typically use database or redis for deduplication . 

Often for scalability idempotency-key are purged after 10 to 30 mins .

Idempotency key can be generated by