# Webhook secret - Thread.Replied webhook

**URL:** <https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212>\
**Category:** Question and Answers\
**Tags:** webhooks\
**Created:** [June 6, 2024, 10:26am UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212 "2024-06-06T10:26:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![matej.djurin](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@matej.djurin](https://forums.nylas.com/u/matej.djurin)\
**Post date:** [June 6, 2024, 10:26am UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/1 "2024-06-06T10:26:49Z")

</div>

HI there!  
I have created Nylas v3 application in Development environment. Inside my backend Azure function which is listening for **thread.replied** webhook events, I am checking the validity of incoming request using webhook secret. But somehow, this webhook secret expires by itself after a week or so.  
I also listen for **message.opened** events and also the first thing I do is checking the validity of incoming request using the webhook secret. I have noticed that this webhook secret does not become invalid.  
So how is that possible, that webhooksecret of **thread.replied** somehow expires and webhooksecret of **message.opened** do not?

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [June 6, 2024, 2:56pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/2 "2024-06-06T14:56:29Z")

</div>

Hi @matej.djurin - thanks for reaching out!

Let me take a look and circle back.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [June 10, 2024, 8:50pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/3 "2024-06-10T20:50:08Z")

</div>

Hey @matej.djurin, just want to clarify a few items, so

1. `thread.replied` webhook events are failing as the webhook secret expires after a week. Are these secrets the default ones received from Nylas upon webhook creation? Do you happen to have any logs related to this that you can share?
2. I assume for `message.opened` it is setup similarly to `thread.replied`? Same logic for webhook secret validation?

I’ll double check on Nylas webhook secrets being expired, but I’m not aware of them expiring [edit: after a week] to my knowledge.

---

<div class="post-metadata">

**Author:** ![matej.djurin](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@matej.djurin](https://forums.nylas.com/u/matej.djurin)\
**Post date:** [June 11, 2024, 11:46am UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/4 "2024-06-11T11:46:57Z")

</div>

Hi,

My apologies for the confusion earlier. The issue isn’t with webhoosecrets. My mistake.

The actual problem is that we do not receive the `thread.replied` webhook event, even though the mail is sent correctly and quite quickly. The issue is not related to expiring secrets for the `thread.replied` webhook or the `message.opened` webhook. While `message.opened` events always come through, the `thread.replied` events sometimes do not come at all.  
I doubt that the problem is in inactivity of our Azure function, since it is deployed and always running. Do Nylas has some retry logic, so maybe we can handle it?  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![matej.djurin](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@matej.djurin](https://forums.nylas.com/u/matej.djurin)\
**Post date:** [June 11, 2024, 12:17pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/5 "2024-06-11T12:17:57Z")

</div>

@ram I just replied 3 times. At the start of the code in our Azure function, we are logging events before any logic is processed. After quite some time (around 4 minutes), we received only 2 events (2 events are logged). The event for the first reply message did not come at all.

Can we see if the event was sent from the Nylas app? If so, where and how can we check this?

---

<div class="post-metadata">

**Author:** ![matej.djurin](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@matej.djurin](https://forums.nylas.com/u/matej.djurin)\
**Post date:** [June 11, 2024, 1:09pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/6 "2024-06-11T13:09:59Z")

</div>

Ok, I found a way to get messages sent via Nylas using this API call: `https://api.eu.nylas.com/v3/grants/grantId/messages`.

I found both the reply messages for which I received the webhook event and the one for which I didn’t receive it. There is no property in the message object that indicates something went wrong.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [June 11, 2024, 2:56pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/7 "2024-06-11T14:56:19Z")

</div>

A few items to consider:

- When creating a [Nylas webhook](https://developer.nylas.com/docs/v3/notifications/webhooks/#create-a-webhook-using-the-webhooks-api), if you specify `notification_email_addresses `, we will send an email if the webhooks fail are not accepted (so we have retry logic)
  - This is the only logging we offer (email notifications of webhook failure to receive)

- So [for tracking emails webhooks to work](https://developer.nylas.com/docs/v3/email/message-tracking/#how-message-tracking-works), the messages must be sent via Nylas Email API
- Consider this [support post](https://support.nylas.com/hc/en-us/articles/19363454905501-No-thread-replied-webhook-triggered-when-message-tracking-enabled-V3) with possible solutions

Let me know if this helps clarifies what could be happening.

---

<div class="post-metadata">

**Author:** ![matej.djurin](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@matej.djurin](https://forums.nylas.com/u/matej.djurin)\
**Post date:** [June 11, 2024, 3:12pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/8 "2024-06-11T15:12:15Z")

</div>

I also considered that the problem may be in scopes. We use Custom Authentication. This are the scopes we are requesting from google:  
‘[https://www.googleapis.com/auth/userinfo.email](https://www.googleapis.com/auth/userinfo.email) [https://www.googleapis.com/auth/userinfo.profile](https://www.googleapis.com/auth/userinfo.profile) [https://www.googleapis.com/auth/calendar](https://www.googleapis.com/auth/calendar) openid [https://mail.google.com/](https://mail.google.com/)’

And for example, this are the scopes returned from endpoint [https://api.eu.nylas.com/v3/grants/{grantId}](https://api.eu.nylas.com/v3/grants/%7BgrantId%7D) for a {grantId} of user which sent initial email through Nylas v3 and did not get all 3 thread.reply events (because there were 3 reply messages):  
“grant\_status”: “valid”,  
“provider”: “google”,  
“scope”: [  
“[https://www.googleapis.com/auth/userinfo.email](https://www.googleapis.com/auth/userinfo.email)”,  
“[https://www.googleapis.com/auth/userinfo.profile](https://www.googleapis.com/auth/userinfo.profile)”,  
“[https://mail.google.com/](https://mail.google.com/)”,  
“[https://www.googleapis.com/auth/calendar](https://www.googleapis.com/auth/calendar)”,  
“openid”  
],

Are those scopes ok? Probably they are, becuase as said, we do get some thread.reply events for 1 initial message sent via Nylas v3 API, but some aren’t being received.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [June 11, 2024, 8:32pm UTC](https://forums.nylas.com/t/webhook-secret-thread-replied-webhook/212/9 "2024-06-11T20:32:28Z")

</div>

Hi @matej.djurin, the scopes for using the [email API are in our developer docs](https://developer.nylas.com/docs/v3/email/scopes/#email-api-scopes-for-yahoo-oauth), double check your provider configuration against this page.

Two follow ups:

1. To clarify, is the `thread.reply` not working at all, or just sometimes? For the specific user, I do not see the `email` scopes as part of their grant.

2. Also as a test, have you tried using our pre-configured `sandbox` environment to see if you receive the webhooks?
