docs icon indicating copy to clipboard operation
docs copied to clipboard

Is it safe to rely on the matching of X-Message-Id and sg_message_id prefix

Open shiglet opened this issue 5 years ago • 0 comments

Hello,

When sending an email through SendGrid api, we get in the response headers an X-Message-Id, let's say for example : "R14554qsAGSkiKYYviJN34DGA". I store this ID somewhere, let's say for example in a database. Then when an event is fired to my Webhook i don't have any X-Message-Id to make the link between the mail i have sent and the event source email. But i have noticed that i have "sg_message_id" and a "smtp-id" that always (?) start with my X-Message-Id.

So the question i have for you is : Is it safe to rely on that matching ? So in my endpoint, when an event is fired, i would check if the sg_message_id (or smtp-id) field starts with the X-Message-Id i have saved just before ?

If not, what's the best practice to go with so i can associate an Email i have sent to a given Event.

Thanks.

shiglet avatar Jun 15 '21 15:06 shiglet