TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Idempotency Key: Where to Generate the Attribute

2 pointsby boonez123about 6 years ago
I am making the following http request to create a financial transaction on another system.<p>The request follows this path:<p>Http request -&gt; Service -&gt; Third Party(like stripe but not stripe).<p>Should the idempotency_key be put into the http request so clients will have to generate it (most likely a uuid) or alternatively should the idempotency key be generated in the service itself?<p>I&#x27;m putting it out here on hacker news for people who have experience building and maintaining API&#x27;s for financial institutions.

2 comments

ezekgabout 6 years ago
I like how Stripe does idempotent requests [0]. Essentially, you end up saying, &quot;do this thing, which I&#x27;m calling &#x27;charge-for-cust-foo&#x27;, but only do it once, even if I tell you to do it again.&quot; Putting the &quot;burden&quot; of generating a unique idempotency key on the client seems to be the best solution, otherwise, they have to somehow store the idempotency key that your service generates to re-send it for the next request, which adds complexity on their end, especially when the request could be sent from multiple servers that need to share which key belongs to which request (i.e. multiple servers rule out storing the keys in memory, which would already pose a risk due to crashes&#x2F;restarts clearing memory).<p>[0]: <a href="https:&#x2F;&#x2F;stripe.com&#x2F;docs&#x2F;api&#x2F;idempotent_requests" rel="nofollow">https:&#x2F;&#x2F;stripe.com&#x2F;docs&#x2F;api&#x2F;idempotent_requests</a>
verdvermabout 6 years ago
put the least burden on users as possible