Only show these results:

Set up webhooks

This page describes how to set up webhooks for your Nylas v3 applications.

Before you begin

Before you can start using webhooks, your environment must have the following prerequisites:

Create a webhook

The following sections describe how to create webhooks for your Nylas application using the Nylas Dashboard, the Webhooks API, or the Nylas SDKs.

You can create multiple webhooks for each of your Nylas applications, but each webhook must have its own unique endpoint.

Create a webhook in the Nylas Dashboard

To create a webhook in the Nylas Dashboard, navigate to the Webhooks section of your application and select the webhook that you want to add. You must provide the following information:

  • The full callback_url for the webhook. The URL must direct to an HTTPS endpoint that is accessible from the public internet.
  • The webhook's notification triggers. For response examples, see the webhook schemas documentation.

Create a webhook using the Webhooks API

To create a webhook using the Webhooks API, make a POST /v3/webhooks request with the following information:

  • The webhook's callback_url. The URL must direct to an HTTPS endpoint that is accessible from the public internet.
  • A list of the trigger_types that you want to listen for. Nylas sends webhook notifications for the triggers that you include.

The following snippet is an example of a POST request to create a webhook.

curl --location '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <NYLAS_API_KEY>' \
--data-raw '{
"trigger_types": [
"description": "local",
"webhook_url": "<your webhook url>",
"notification_email_addresses": ["[email protected]", "[email protected]"]

Create a webhook using the Nylas SDKs

The following code samples show how to create a webhook using the Nylas SDKs.

import 'dotenv/config'
import Nylas from "nylas"

const NylasConfig = {
apiKey: process.env.NYLAS_API_KEY,
apiUri: process.env.NYLAS_API_URI,

const nylas = new Nylas(NylasConfig)

const createWebhook = async () => {
try {
const webhook = await nylas.webhooks.create({
requestBody: {
triggerTypes: [WebhookTriggers.EventCreated],
callbackUrl: process.env.CALLBACK_URL,
description: "My first webhook",
notificationEmailAddress: process.env.EMAIL,

console.log("Webhook created:", webhook)
} catch (error) {
console.error("Error creating webhook:", error)

from dotenv import load_dotenv

import os
import sys
from nylas import Client
from nylas.models.webhooks import WebhookTriggers

nylas = Client(

grant_id = os.environ.get("NYLAS_GRANT_ID")
callback_url = os.environ.get("CALLBACK_URL")
email = os.environ.get("EMAIL")

webhook = nylas.webhooks.create(
"trigger_types": [WebhookTriggers.EVENT_CREATED],
"callback_url": callback_url,
"description": "My first webhook",
"notification_email_address": email,

require 'nylas'

nylas = "API_TOKEN")

request_body = {
trigger_types: [Nylas::WebhookTrigger::EVENT_CREATED],
webhook_url: "CALLBACK_URL",
description: 'My first webhook',
notification_email_address: ["EMAIL_ADDRESS"]

webhooks, = nylas.webhooks.create(request_body: request_body)
puts "Webhook created: #{webhooks}"
rescue StandardError => ex
puts "Error creating webhook: #{ex}"
import com.nylas.NylasClient;
import com.nylas.models.*;
import com.nylas.resources.Webhooks;
import com.nylas.models.WebhookTriggers;
import java.util.*;

public class webhooks {
public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

List<WebhookTriggers> triggers = new ArrayList<>();

CreateWebhookRequest webhookRequest = new CreateWebhookRequest(triggers, "<WEBHOOK_URL>",
"My first webhook", "<EMAIL_ADDRESS>");

try {
Response<WebhookWithSecret> webhook = new Webhooks(nylas).create(webhookRequest);

} catch (Exception e) {
System.out.println("Error: " + e);
import com.nylas.NylasClient
import com.nylas.models.*
import com.nylas.resources.Webhooks

fun main(args: Array<String>){
val nylas: NylasClient = NylasClient(apiKey = "<NYLAS_API_KEY>")
val triggersList: List<WebhookTriggers> = listOf(WebhookTriggers.EVENT_CREATED)

val webhookRequest: CreateWebhookRequest = CreateWebhookRequest(triggersList,
"My first webhook",

try {
val webhook: Response<WebhookWithSecret> = Webhooks(nylas).create(webhookRequest)

} catch(exception : Exception) {
println("Error :$exception")

Respond to webhooks

The first time you create a webhook or set an existing webhook's state to active, Nylas checks that it's valid by sending a GET request to its endpoint. The request includes a challenge query parameter for the verification process. Your Nylas application must return the exact value of the challenge parameter in the body of its response.

After the webhook is verified, Nylas sends updates to your application using webhook notifications. Your application must respond to those updates with a 200 status code. If Nylas doesn't receive a response, it will attempt to deliver the notification five times before changing the webhook's status to failing.

Every webhook that Nylas sends includes a signature header. You can use this to verify that the data is coming from Nylas.

The Challenge query parameter

When your Nylas application receives a request that includes the challenge query parameter, it's subject to the following requirements:

  • Your application has up to 10 seconds to respond to the verification request.
    • Nylas will not attempt to verify the webhook again if it fails the first check.
    • If your application does not respond to the verification request, Nylas returns a 400 BAD REQUEST error.
  • Your application must return the exact value of the challenge parameter in the body of its response. Do not include any other data — not even quotation marks.
  • Your application must not use chunked encoding for its response to Nylas' verification request.
  • Your application must allow the USER-AGENT header with the python-requests value. Without this field, your application might discard inbound API requests.

The code snippet below is an example of a verification request sent by Nylas. The sample adds line breaks to separate the header fields.

{'HOST': '', 
'USER-AGENT': 'python-requests/2.27.1',
'ACCEPT': '*/*',
'ACCEPT-ENCODING': 'gzip, deflate',
'TRACEPARENT': '00-290e04f302c62c3151b6dab68f4562ad-9f70e1dd368f653c-00',
'TRACESTATE': '2700637@nr=0-0-2740637-675374629-9f70e1dd368f653c-290e04f302c62c11-0-0.081429-1648045740010',

The Nylas webhook signature

Every webhook notification that Nylas sends (except for v2 Scheduler notifications) includes an X-Nylas-Signature header.

For v3 notifications Nylas generates a signing key for each webhook endpoint when it's created, and returns it as a webhook_secret in the success response. The webhook secret is used to sign future requests to update the webhook. For more information, see Improvements to webhook signatures.

Retry attempts

Nylas tries sending failed webhook messages up to five times, backing off exponentially. Nylas guarantees at least four retries within the first 20 minutes of a webhook failing. All five retries occur within one hour of a webhook failing.

If Nylas can't make a successful POST request to a webhook endpoint after five retries, the system skips the affected notification and continues to send others.

Failed webhooks

Nylas marks a webhook as failing when it receives 95% non-200 responses or non-responses from the webhook's endpoint over a period of 15 minutes.

Nylas marks a webhook as failed in the following circumstances:

  • It receives 95% non-200 responses (or non-responses) from a webhook endpoint over a period of three days.
  • It doesn't receive a response from a webhook endpoint over a period of three days.

When a webhook's state is changed to either failing or failed, Nylas sends an email notification to you about the change.

You can reactivate a webhook through the Nylas Dashboard, or by using the Webhooks API. Nylas v3 doesn't automatically restart or reactivate webhooks that were marked as failed. For more information, see Improvements to webhook failure notifications.

Reactivated webhooks don't send notifications for events that occurred while they were marked as failed.

Activate and deactivate webhooks

By default, Nylas webhooks are set to active. When you deactivate a webhook, Nylas stops sending all events associated with that webhook to your endpoint. When you reactivate a webhook, it starts sending data from the time that it was reactivated. Nylas does not send notifications for events that occurred while a webhook was inactive.

Deactivate webhooks in the Nylas Dashboard

To deactivate a webhook in the Nylas Dashboard, select Webhooks from the left navigation menu. Find the webhook whose state you want to change and set it to inactive.

Deactivate webhooks using the Webhooks API

To deactivate a webhook using the Webhooks API, make a PUT /v3/webhooks/{id} request to update the status to inactive.

Test webhooks

🔍 The Nylas APIs block requests to Ngrok testing URLs. Nylas recommends using the Nylas CLI instead, to ensure you receive all data during testing and development.

If you need to add an IP address that sends webhooks to your allowlist, you can use the IP Addresses endpoint to get a list of dynamic IP addresses.

Keep in mind

  • Webhooks are not compatible with Ngrok because of throughput limiting concerns.
  • Email threads might be incomplete if the sync date is not far enough in the past. Be sure to sync to the start of an account's threads.
  • Historical webhook settings apply only to new applications.
  • You should configure your webhook settings before you add connected accounts or grants to your Nylas application.
  • Changes to webhook settings apply only to accounts or grants that connect after you save the changes.