Skip to main content
@polar-sh/sdk is the official TypeScript client for the Polar API. It requires Node.js 24 or later.

Install

Terminal

Create a client

Create an organization access token in Settings → Access Tokens, or run polar auth token, and store it in POLAR_ACCESS_TOKEN. Then make your first request:
index.ts
The import path pins the client to API version 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 extends PolarError, 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:
See Handle deliveries for a full handler.

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:
Call 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. The polar-integration skill helps your coding agent integrate or migrate:

Learn more