How to send email notifications on oauth token expirySummaryThere are many requests from Users for email notification creation for Oauth tokens. This is a step-by-step guide to creating such event-based notifications for tokens expiring in few days.ReleaseAnyInstructions You will have to create the following: Scheduled job to just check for oauth expiration (frequency can be as per your requirement)A BR to trigger a new event named "oauth_token.expiring" When the gap is 3 daysCreate Event-based notifications. EVENT Names: Please Navigate to the event registry and create the following new events. oauth_token.expiring (This will be used to notify the user if the OAuth token is about to expire in the x number of days which is managed by system property Oauth_expiry_warning) New system property:Name: Oauth_expiry_warningType: Int The default value is 3 1. Scheduled job which runs every day/frequency of your liking: // force update all active tokens, to trigger oauth expiration eventsvar cgr = new GlideRecord("oauth_credential");cgr.addQuery('type','refresh_token');cgr.addActiveQuery();cgr.query();if(cgr.next()) { cgr.setForceUpdate(true); cgr.update();} 2. Create a Business rule which will fire the events based on the expiry date: This should run during every insert/update: (function executeRule(current, previous /*null when async*/ ) { var gr = new GlideRecord("oauth_credential"); //Assuming that this is only for type refresh_token gr.addQuery('type', 'refresh_token'); gr.query(); while (gr.next()) { var gdt = new GlideDateTime(gr.expires); var currentdate = new GlideDateTime(); // Current DateTime var expiresInDays = GlideDateTime.subtract(currentdate, gdt).getRoundedDayPart(); var notifuser = gr.getValue('user'); var peer = gr.getDisplayValue('peer'); //You can change this value by "Oauth_expiry_warning" if (expiresInDays <= gs.getProperty('Oauth_expiry_warning')) { gs.eventQueue("oauth_token.expiring", gr, notifuser, peer); } }})(current, previous); 3. Create event-based notifications with the respective events: oauth_token.expiringRelated Links Considerations: 1. This will work only for refresh tokens, the reason being the access tokens' life span generally is less compared to refresh tokens and more over you can always generate access tokens if you have refresh tokens available in the instance. To automate the refresh token process, you may refer to the following KBs: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0854269 https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131 2. The notification will be sent to the user who is associated with these tokens in the oauth_credential table. 3. You can further refine the above scripts to match your requirement this is just offered as a suggestion.