Skip to main content

This is either a question or a feature request. Is there any way to send an idempotency key with track events? it’d be something like:

 

client.track(BaseEvent(
…,
idempotency_key=’abc123’
))

 

For example, here’s how this is handled in the Stripe API: https://stripe.com/docs/api/idempotent_requests

 

I would like to do this for backend events that risk getting triggered twice. For example during a checkout there might be both an API request from the client directly to the backend and a webhook from Stripe, which both signify that the checkout was a success and instead of adding conditional extra logic on my side whether or not to send the event, it’d be easiest and the most robust to just pass an idempotency key.

Hey @Peter Coles,

This looks more like a feature request, as far as I’m concerned Amplitude doesn’t manage idempotent requests at the moment, as you said your engineering team must add conditional extra logic on your side to prevent this behavior from happening.


Nice feature request though! That’d save a lot of time when implementing events server side.


Hello @Peter Coles and @Naryie Vasquez  - if your goal is to avoid data duplication in case of pipeline failures/retries, then you should be able to use the ‘insert_id’ field when sending data via HTTP API or Batch API, see this doc here. Our last versions of SDK for frontend tracking, also allow you to overwrite the auto-generated insert_id, so you should be able to get to the result you need.

Amplitude model is ‘Write and Forget’ which means that you never update the ingested data but you can prevent the same data to be sent twice within a 7-day period by using the insert_id field. Please feel free to reach out for more details.


Reply