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
Type
stringemailDriverstring
Type
stringactionWebhookLifecycleAction
Type
WebhookLifecycleActionsourceWebhookLifecycleSource
Type
WebhookLifecycleSourcereasonWebhookLifecycleReason
Type
WebhookLifecycleReasonrecommendedActions?WebhookRecommendedAction[]
Type
WebhookRecommendedAction[]scopeWebhookScope
Type
WebhookScopewebhook?Webhook
Type
WebhookpreviousWebhook?Webhook
Type
WebhookwebhookId?string
Type
stringproviderId?string
Type
stringsubscriptionId?string
Type
stringtarget?WebhookLifecycleTarget
Type
WebhookLifecycleTargetstatus?WebhookStatus
Type
WebhookStatuspreviousStatus?WebhookStatus
Type
WebhookStatusexpiresAt?Date
Type
DaterenewAfter?Date
Type
DatereceivedAt?Date
Type
Dateseverity?"info" | "warning" | "critical"
Type
"info" | "warning" | "critical"context?unknown
Type
unknownraw?unknown
Type
unknown