X-Convoy-Idempotency-Key header whenever the event has an idempotency
key, and your receiver can use it to de-duplicate events sent by Convoy. In the next two sections, we will talk about how to configure
idempotency keys for both incoming and outgoing projects and how to de-duplicate events sent or received.
Idempotency in Incoming Projects
With Convoy, you can inspect parts of a request to extract the idempotency key. You can define idempotency keys in both the request body or header. When creating a source you can specify the location of the idempotency key which convoy will use to generate a SHA256 checksum value. To get started create a source and specify the idempotency key locations, this is an ordered set of locations— valid parts of the request where the keys might be found. The locations include the request header, body and query params. For request body key:Idempotency in Outgoing Projects
In outgoing projects you would need to specify an idempotency key in the request payload when creating the event. This works the same way when creating dynamic and fanout events. The idempotency key should be a unique value generated by the client. It is recommended to use the SHA256 of a UUID v4 string or any other sufficiently random string to ensure avoidance of collisions. We recommend a SHA256 string because the idempotency keys we generate for incoming projects are SHA256 strings.Overriding the outbound idempotency header
Theidempotency_key field above is the ingestion key Convoy uses to de-duplicate events coming into the project. Convoy also reuses that same key as the default value of the X-Convoy-Idempotency-Key header it sends out to your endpoint, and you can override that outbound value independently.
When Convoy delivers a webhook it sets the X-Convoy-Idempotency-Key header on the outbound request so your receiver can de-duplicate on it. By default this is the event’s own idempotency key; if the event has none, the header is omitted entirely. To override it, Convoy merges the event’s custom_headers first and only fills in the default when you didn’t supply an X-Convoy-Idempotency-Key, so your value wins. Set it in the event’s custom_headers when you want your receiver to dedupe on a key you control: