Webhooks
Webhooks allow your application to receive notifications in real-time when certain events occur. Webhooks use a push notification protocol to notify you of changes, rather than you periodically requesting (polling for) the latest changes from Nylas. Webhooks are the best way to get notifications about changes in your connected accounts, because they are lightweight, can easily integrate with your app, and scale seamlessly as you grow.
The following pages are in this section:
This documentation is the source of truth for different values that Nylas uses, such as the request timeout threshold and retry policy.
Good to know: The word "webhook" can refer to any of its three parts: a location where you receive notifications (the "callback URL", or "webhook endpoint"), a subscription to events you want notifications for ("webhook triggers"), and the information payload sent when a trigger condition is met (the "webhook notification"). This documentation tries to be specific to avoid confusion.
Webhooks in Nylas
Nylas implements webhooks by sending an HTTP POST request to a URL that you specify when you configure your webhook. When a webhook triggers, Nylas sends information about the object to your application, and your application can use that information to query the Nylas API for details about the object that changed. For example, when a connected account receives a new email, Nylas can make a POST request to your callback_url
endpoint to let you know about the new message.
You can specify what events you want to be notified about from the developer dashboard or with the Webhooks API. The Nylas Webhooks API documentation lists the webhook management endpoints, the available webhook triggers, and how webhooks payloads are structured.
Good to know: The term "webhook" can refer to both the configuration of the webhook (the data change that triggers the message, and where the message is sent), and the notification that is sent.
Webhook examples and sample apps
Nylas maintains code examples in the SDK repositories that demonstrate how to handle webhooks. You can build from these examples, or use them as a reference to get started on your own implementation.
Nylas also maintains fully-functional demonstration applications which use and log webhooks. You can download the code for these samples and run them locally to see how they work.
Video walkthroughs
Prefer video? You can watch our LiveStream Coding with Nylas.
Testing Webhooks using the Nylas CLI and Ruby
Creating Nylas webhooks with Node.js and Vercel
Testing Nylas webhooks using Pipedream
More resources
- Set up local webhook testing in Node.js.
- Read the blog post How to Create Nylas Webhooks With NodeJS.
- Set up local webhook testing in Ruby
- Read the blog post Testing Webhooks Using the Nylas CLI and Ruby.
- Set up local webhook testing in Python
- Read the blog post Testing Webhooks using the Nylas CLI and Python.
- Set up local webhook testing in Java
- Read the blog post Testing Webhooks Using the Nylas CLI and PHP.