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
event
Checkout status update
event
New subscription created
- Updates user entitlement
- Sets premium status if active
- Sends payment success notification
- Creates audit log
event
Subscription updated
- Updates entitlement with new status
- Adjusts premium flag
- Creates audit log
event
Subscription activated
- Same as subscription.updated
event
Subscription canceled
- Marks subscription as canceled
- Access continues until period end
- Creates audit log
event
Subscription revoked
- Immediately removes premium access
- Resets to free tier
- Creates audit log
event
Customer created
- Links Polar customer ID to user
- Creates entitlement if needed
event
Customer updated
- Updates Polar customer ID
event
Customer deleted
- Removes Polar customer link
- Resets to free tier
Webhook Security
Webhooks are secured using Polar’s webhook secret verification:string
required
Webhook secret for DROP service
string
required
Webhook secret for MAILS service
string
required
Webhook secret for VAULT service
string
required
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