API Endpoints

The application exposes several API endpoints for handling payments and webhooks.

Payments

GET /api/checkout

Creates a checkout session with Polar.sh.

  • Query Parameters: None
  • Response: Redirects to Polar checkout page.

GET /api/portal

Redirects the user to the Polar Customer Portal.

  • Query Parameters: None
  • Response: Redirects to Polar portal.

Webhooks

POST /api/webhook/polar

Handles incoming webhooks from Polar.sh.

  • Body: JSON payload from Polar.
  • Headers: Must include Polar-Webhook-Signature for verification.

POST /api/webhooks/polar

Alternate Polar webhook route wired to the same handler.

  • Body: JSON payload from Polar.
  • Headers: Must include Polar-Webhook-Signature for verification.

Authentication

Authentication endpoints are handled by Better Auth and are generally not called directly by the client application code, but rather through the Better Auth client SDK.

Auth requests are handled through:

  • /api/auth/$

In the current app flow, authentication is Google SSO only from /login.