Prevent sending the same message multiple times.
notifications#create
call is madeidempotency_key
field exists on notifications for precisely this reason.
idempotency_key
is simply an optional parameter to the notifications#create
request that can be used to correlate the notification to your system, and more importantly, ensure that duplicate notifications are not sent.
Keys must be unique v3 or v4 UUID format.
In the example case above, the flow might look something like this:
notifications#create
call is made with idempotency_key
notifications#create
call is made again with the same idempotency_key
as the previous one.idempotency_key
is the same in each request, only 1 notification will be delivered to your users regardless of the number of times the request is sent to our api.
Because the api will not send a notification if the idempotency_key
already exists in our database, it’s important to use a good source of randomness when generating the uuid passed.
It’s important to note this key is only idempotent for 30 days. After 30 days, the notification could be removed from our system and a notification with the same idempotency_key
will be sent again.
idempotency_key
property used to be called external_id
but caused
confusion with our Users alias, so we have added this new
property name to reduce confusion. Both will work in this case.