Skip to main content
The Outlook plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • contacts
    • newContact (contacts.newContact)
  • events
    • eventChange (events.eventChange)
    • newEvent (events.newEvent)
  • messages
    • newMessage (messages.newMessage)
    • sentMessage (messages.sentMessage)
  • subscriptionValidation (subscriptionValidation)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Contacts

New Contact

contacts.newContact Triggered when a new contact is added in Outlook contacts Payload
NameTypeRequiredDescription
valueobject[]Yes
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType?: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}[]
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType: created,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}
webhookHooks example
outlook({
    webhookHooks: {
        contacts: {
            newContact: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Events

Event Change

events.eventChange Triggered when a calendar event is created, updated, or deleted Payload
NameTypeRequiredDescription
valueobject[]Yes
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType?: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}[]
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}
webhookHooks example
outlook({
    webhookHooks: {
        events: {
            eventChange: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

New Event

events.newEvent Triggered when a new calendar event is created Payload
NameTypeRequiredDescription
valueobject[]Yes
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType?: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}[]
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType: created,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}
webhookHooks example
outlook({
    webhookHooks: {
        events: {
            newEvent: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Messages

New Message

messages.newMessage Triggered when a new message is received in the Outlook mailbox Payload
NameTypeRequiredDescription
valueobject[]Yes
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType?: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}[]
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType: created,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}
webhookHooks example
outlook({
    webhookHooks: {
        messages: {
            newMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Sent Message

messages.sentMessage Triggered when a message is sent from the Outlook mailbox Payload
NameTypeRequiredDescription
valueobject[]Yes
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType?: created | updated | deleted,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}[]
{
  subscriptionId?: string,
  subscriptionExpirationDateTime?: string,
  changeType: created,
  resource?: string,
  resourceData?: {
    @odata.type?: string,
    @odata.id?: string,
    @odata.etag?: string,
    id?: string
  },
  clientState?: string,
  tenantId?: string,
  eventType?: string
}
webhookHooks example
outlook({
    webhookHooks: {
        messages: {
            sentMessage: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Subscription Validation

Subscription Validation

subscriptionValidation Microsoft Graph subscription validation handshake Payload
NameTypeRequiredDescription
validationTokenstringYes
{
  validationToken: string
}
webhookHooks example
outlook({
    webhookHooks: {
        subscriptionValidation: {
            before(ctx, args) {
                return { ctx, args };
            },
            after(ctx, response) {
            },
        },
    },
})