Skip to main content

I have ended up with 2 subscriptions sending me webhook events. I don't know how to delete the old one.

The scenario:
User A ran the OAuth flow. My app is using that user for authentication. The app created a webhook subscription to /telephony/session events for some extensions.

Something happened to my refresh token. So User B logs into my app and runs the OAuth flow. So now my app is using an access token for User B. The app checks the subscriptions to make sure they are up to date. The app sees no subscriptions for User B so it creates a new subscription. At the same time the subscription from User A is still sending webhook events. Now my app is receiving duplicate events.

How do I delete the subscription for User A?

Notification subscription is per user. In app scenario, you should authenticate the app with just one user (if possible, use password flow authentication). If not that, you can keep the subscription id in your database (possible with the owner) and user B will need to check if the subscription exists then don't create a new one. However, user B's access token cannot be used to renew user A's subscription. So make sure the subscription lives long enough without the need to renew it.

I have not try this but you can help test it and share your finding. Give user A and user B a super admin role and try to delete other's user subscription to see if works.


Reply