Overview
Null Pass integrates with Polar.sh for subscription management. Webhooks from Polar are received and processed to update user service entitlements automatically.Supported Webhooks
DROP Webhooks
/api/webhooks/dropMAILS Webhooks
/api/webhooks/mailsVAULT Webhooks
/api/webhooks/vaultDB Webhooks
/api/webhooks/dbWebhook Endpoints
Each service has its own webhook endpoint:POST /api/webhooks/dropPOST /api/webhooks/mailsPOST /api/webhooks/vaultPOST /api/webhooks/db
Webhook Processing
All webhooks are processed byhandlePolarWebhook() in lib/webhook-handlers.ts. The handler:
- Sends Discord notification (if configured)
- Processes webhook based on event type
- Updates user entitlements
- Creates audit log entries
- Handles errors gracefully
Supported Events
Checkout status update
New subscription created
- Updates user entitlement
- Sets premium status if active
- Sends payment success notification
- Creates audit log
Subscription updated
- Updates entitlement with new status
- Adjusts premium flag
- Creates audit log
Subscription activated
- Same as subscription.updated
Subscription canceled
- Marks subscription as canceled
- Access continues until period end
- Creates audit log
Subscription revoked
- Immediately removes premium access
- Resets to free tier
- Creates audit log
Customer created
- Links Polar customer ID to user
- Creates entitlement if needed
Customer updated
- Updates Polar customer ID
Customer deleted
- Removes Polar customer link
- Resets to free tier
Webhook Security
Webhooks are secured using Polar’s webhook secret verification:Webhook secret for DROP service
Webhook secret for MAILS service
Webhook secret for VAULT service
Webhook secret for DB service
Implementation
Code Reference
User Identification
Webhooks identify users through:metadata.userIdin subscription/customer object (preferred)- Customer email lookup if userId not present
Subscription Status Mapping
- active →
isPremium: true, tier set from metadata - canceled → Status marked as canceled, access continues
- revoked →
isPremium: false, tier reset to “free”
Audit Events
Webhooks create the following audit log entries:SUBSCRIPTION_CREATESUBSCRIPTION_UPDATESUBSCRIPTION_CANCELSUBSCRIPTION_REVOKE
Error Handling
- Errors are logged but don’t fail the webhook
- Discord notifications failures don’t block processing
- Database errors are caught and logged
- Webhook processing continues even if individual steps fail