Skip to main content
POST
/
api
/
webhooks
/
mails

Endpoint

POST /api/webhooks/mails

Overview

Receives and processes Polar webhooks for MAILS service subscriptions. Updates user entitlements based on subscription events.

Security

Webhook secret: MAILS_POLAR_SECRET environment variable

Implementation

export const POST = Webhooks({
  webhookSecret: process.env.MAILS_POLAR_SECRET!,
  onPayload: async (payload) => {
    await handlePolarWebhook(payload, 'MAILS')
  },
})

Supported Events

See Webhooks Overview for complete list of supported events.

Service-Specific Behavior

When processing MAILS webhooks:
  • Updates UserServiceEntitlement with service: 'MAILS'
  • Links Polar customer and subscription IDs
  • Updates tier and premium status
  • Sends Discord notifications (if configured)

Configuration

Set MAILS_POLAR_SECRET in environment variables to match Polar webhook secret.