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 in order. The locations can refer to request headers, body fields and query parameters. Convoy combines the values from all configured locations; they are not alternatives where the first available value wins. 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.Outbound idempotency headers
Theidempotency_key field above is the ingestion key Convoy uses to de-duplicate events coming into the project. Convoy sends that same value to the receiver in X-Convoy-Idempotency-Key by default.
When an event has an idempotency key, its value takes precedence over any custom_headers entry with the same outbound header name. Set idempotency_key to the value your receiver should use:
custom_headers can still be forwarded, but it does not enable ingest deduplication.
Outgoing projects can change the outbound header name through config.request_id_header. With a custom name configured, idempotency_key is required when publishing events, and its value is written to that configured header.