## What this teaches

How to idemptency when sending events (avoid duplicate events).

## The problem

Issue posthog/posthog#17211 (closed, 25 comments): ## Is your feature request related to a problem? Duplicate events possible when sending to posthog. My exact usecase is - i'm listening to appstore subscription purchase/renew events on my server and I want send those events to posthog to keep track of sales and MRR. However it is possible to end up with sending the same event to posthog twice: * My server recieves notification about subscription renewal * My server send corresponding event to posthog * My server crashes * Appstore will attempt to send the same notification with the same "NotificationUUID" again to my server as server didn't...

## What worked (verified answer)

[MarconLP (maintainer)]: For idempotent event capture, include a uuid in the capture payload next to distinct_id. PostHog dedupes on it, so resends of the same notification (e.g. App Store subscription renewals after your server crashes mid-send) do not create duplicate events. Example: curl -d '{ "api_key": "[ph_project_api_key]", "distinct_id": "distinct_id_of_the_user", "event": "user_signed_up", "uuid": "01916987-08f2-0000-7f29-91ed6eeeeeee" }' https://us.i.posthog.com/capture/

## Source

gh:posthog/posthog#17211 - https://github.com/posthog/posthog/issues/17211
