Setup
1
Get your credentials
From your Polar dashboard, go to Settings → API and create an access token. Under Webhooks, create an endpoint pointing to/api/kavach/auth/polar/webhook and copy the signing secret.2
Configure the plugin
Usage
Create a checkout session
Check subscription status
HTTP endpoints
The plugin registers three routes under your KavachOS base path.POST /auth/polar/checkout
Creates a checkout session. Requires an authenticated session.GET /auth/polar/subscription
Returns the current subscription for the authenticated user.{ "subscription": null } when the user has no active subscription.
POST /auth/polar/webhook
Receives webhook events from Polar. Signature is verified with HMAC-SHA256, no session auth needed. Handled events:Sandbox mode
Setsandbox: true to point at sandbox.api.polar.sh during development. Polar’s sandbox environment mirrors the production API and lets you test webhooks without real payments.
Reference
PolarConfig
PolarSubscription
KavachOS stores Polar subscription data in the
kavach_users table. You can query it directly with Drizzle or any SQL client.