@polar-sh/sdk is the official TypeScript client for the Polar API. It requires Node.js 24 or later.
Install
- npm
- yarn
- pnpm
Terminal
Create a client
Create an organization access token in Settings → Access Tokens, or runpolar auth token, and store it in POLAR_ACCESS_TOKEN. Then make your first request:
index.ts
2026-10: its types and the Polar-Version header it sends. See SDKs.
Use the token on your server only. Never bundle it into browser code.
Options
List resources
List methods return one page.iterList yields every item across pages:
Handle errors
Every SDK error extendsPolarError, exported from @polar-sh/sdk. Errors the API documents, such as ResourceNotFound, have their own classes under errors:
Verify webhooks
webhooks.validateEvent checks the signature and returns a typed event:
Send usage events
polar.track adds an event to the SDK’s queue and returns. The SDK sends queued events in batches in the background:
await polar.flush() before a serverless function returns, and await polar.close() when a server shuts down, so no queued events are lost. See Send events for configuring the queue, duplicates and limits.
Framework adapters
Adapters add checkout, Customer Portal and webhook routes in a few lines: Adapters for other frameworks are deprecated. Use the SDK directly instead. Thepolar-integration skill helps your coding agent integrate or migrate:

