Last week, I spammed my users with emails by mistake. I had written an idempotent method to do a transaction and send a confirmation email. I didn't realize the email call is not idempotent. So, when the transaction failed, it retried again and again and spammed the entire user base with emails. I was so embarrassed and wrote an API layer on top of my email delivery service (SendGrid) to ensure that my users won't get more than 1 email per day, irrespective of my architecture or mistakes. I am publishing it as a public API, in case anyone else needs it:
https://rapidapi.com/mailrecipe/api/mailrecipe
Have you run into this problem? How did you solve it?