Skip to content
emailkit
Esc
navigateopen⌘Jpreview
On this page

webhook.onCreated

emailkit registered a subscription with a provider — persist it.

Fires when emailkit registers a webhook with a provider — during setup, or as part of connecting a mailbox. Persist the webhook: mailbox subscriptions (Gmail, Outlook) expire and get renewed, and emailkit hands the state to your app instead of keeping its own database.

hooks: {
  webhook: {
    onCreated: async (event) => {
      await prisma.webhook.create({
        data: {
          id: event.webhook.id,
          emailDriver: event.emailDriver,
          scope: event.scope,
          expiresAt: event.webhook.expiresAt,
          data: event.webhook,
        },
      });
    },
  },
},

Payload

webhook is always set for this action.

PropType
id?string
Typestring
emailDriverstring
Typestring
actionWebhookLifecycleAction
TypeWebhookLifecycleAction
sourceWebhookLifecycleSource
TypeWebhookLifecycleSource
reasonWebhookLifecycleReason
TypeWebhookLifecycleReason
recommendedActions?WebhookRecommendedAction[]
TypeWebhookRecommendedAction[]
scopeWebhookScope
TypeWebhookScope
webhook?Webhook
TypeWebhook
previousWebhook?Webhook
TypeWebhook
webhookId?string
Typestring
providerId?string
Typestring
subscriptionId?string
Typestring
target?WebhookLifecycleTarget
TypeWebhookLifecycleTarget
status?WebhookStatus
TypeWebhookStatus
previousStatus?WebhookStatus
TypeWebhookStatus
expiresAt?Date
TypeDate
renewAfter?Date
TypeDate
receivedAt?Date
TypeDate
severity?"info" | "warning" | "critical"
Type"info" | "warning" | "critical"
context?unknown
Typeunknown
raw?unknown
Typeunknown

Last updated on July 24, 2026

Was this page helpful?