<story><title>APIs, robustness, and idempotency</title><url>https://stripe.com/blog/idempotency</url></story><parent_chain></parent_chain><comment><author>brandur</author><text>I authored this article and just wanted to leave a quick note on here that I&amp;#x27;m more than happy to answer any questions, or debate&amp;#x2F;discuss the finer points of HTTP and API semantics ;)&lt;p&gt;An ex-colleague pointed out to me on Twitter today that there are other APIs out there that have developed a concept similar to Stripe&amp;#x27;s `Idempotency-Key` header, the &amp;quot;client tokens&amp;quot; used in EC2&amp;#x27;s API for example [1]. To my knowledge there hasn&amp;#x27;t really been a concerted effort to standardize such an idea more widely, but I might be wrong about that.&lt;p&gt;[1] &lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;docs.aws.amazon.com&amp;#x2F;AWSEC2&amp;#x2F;latest&amp;#x2F;APIReference&amp;#x2F;Run_Instance_Idempotency.html#client-tokens&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;docs.aws.amazon.com&amp;#x2F;AWSEC2&amp;#x2F;latest&amp;#x2F;APIReference&amp;#x2F;Run_In...&lt;/a&gt;</text></comment>
<story><title>APIs, robustness, and idempotency</title><url>https://stripe.com/blog/idempotency</url></story><parent_chain></parent_chain><comment><author>vfaronov</author><text>Curious that they don’t mention HTTP conditional requests [1] even in passing. This mechanism is typically used for slightly different things, but you can, for example, make a PATCH request “idempotent” (in their sense) by adding an If-Match header to it. I’d say that Idempotency-Key itself may be considered a precondition and used with status codes 412 [2] and 428 [3].&lt;p&gt;By the way, WebDAV extended this mechanism with a general If header [4] for all your precondition needs. I’m kinda glad it didn’t catch on though...&lt;p&gt;[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc7232&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc7232&lt;/a&gt;&lt;p&gt;[2] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc7232#section-4.2&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc7232#section-4.2&lt;/a&gt;&lt;p&gt;[3] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc6585#section-3&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc6585#section-3&lt;/a&gt;&lt;p&gt;[4] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc4918#section-10.4&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;tools.ietf.org&amp;#x2F;html&amp;#x2F;rfc4918#section-10.4&lt;/a&gt;</text></comment>