Agent skill

Polar Typescript SDK

by polarsource in polarsource/polar

Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients.

Apache-2.0Auto-check passedData & Analytics

Install Polar Typescript SDK

skills CLI
$ npx skills add polarsource/polar --skill polar-typescript-sdk -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install polarsource/polar polar-typescript-sdk --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/polarsource/polar.git skills-src && mkdir -p .claude/skills && cp -r skills-src/sdk/typescript/.agents/skills/polar-typescript-sdk .claude/skills/polar-typescript-sdk && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
polar-typescript-sdk
GitHub stars
10k
Token cost
~2k tokens
SKILL.md length
719 words
Files
5 (incl. references)
Skills in repo
18
Repo updated
First seen
Licence
Apache-2.0

At a glance

Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients.

  • Works in 5 steps: Identify the installed @polar-sh/sdk… → Inspect generated service signatures,… → Use createPolar for the full service… → …
  • Implementing Polar customers and external IDs
  • SKILL.md covers Inspect the application first, Migrate from the old SDK, Configure and reuse the client and Follow generated argument and…, plus 5 more sections
  • Needs POLAR_ACCESS_TOKEN

What it does

Polar Typescript SDK is an agent skill from polarsource/polar. Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients. Use when implementing Polar customers and external IDs, checkout or customer portal sessions, customer-state entitlement checks, webhook validation and processing, API error handling, tree-shakable SDK calls, usage-event ingestion and metered billing, or migrating an application from the old Polar TypeScript SDK.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `agents/openai.yaml`, `references/migration-from-v0.md` and `references/usage-events.md`).

It sits in Data & Analytics, covering DataFrames. It works with TypeScript. The repository describes itself as: Polar — A billing platform for the intelligence era. The licence is Apache-2.0.

When your agent uses it

  • Implementing Polar customers and external IDs
  • Customer portal sessions
  • Customer-state entitlement checks
  • Webhook validation and processing

Example prompts

  • “/polar-typescript-sdk”

Requirements

  • A credential in POLAR_ACCESS_TOKEN

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Identify the installed @polar-sh/sdk version and preserve the API version already selected by the application.
  2. Inspect generated service signatures, model interfaces, response types, and endpoint-specific errors before writing calls.
  3. Use createPolar for the full service client. Use createPolarCore with individual service functions when bundle size or tree-shaking matters.
  4. Identify whether the access token is scoped to an organization. When the selected token does not imply one, create the client with…
  5. Keep client, webhook, and environment configuration in trusted server-side code.

What it can do on your machine

Read from SKILL.md and the folder at commit e4fc909. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • POLAR_ACCESS_TOKEN

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Polar Typescript SDK loads about 2k tokens when it runs, and up to ~5.1k if it reads all its reference files. Until then it costs about 115 tokens; SKILL.md has 719 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~115
When it runs · the whole SKILL.md, loaded when a task matches
~2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~5.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from polarsource/polar at commit e4fc909, republished under its Apache-2.0 licence (© polarsource). 719 words, ~1,989 tokens.

Download SKILL.mdSave it as .claude/skills/polar-typescript-sdk/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
polar-typescript-sdk
description
Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients. Use when implementing Polar customers and external IDs, checkout or customer portal sessions, customer-state entitlement checks, webhook validation and processing, API error handling, tree-shakable SDK calls, usage-event ingestion and metered billing, or migrating an application from the old Polar TypeScript SDK.

Polar TypeScript SDK

Use the generated, versioned Polar SDK without inventing methods or parameters.

Inspect the application first

  1. Identify the installed @polar-sh/sdk version and preserve the API version already selected by the application.
  2. Inspect generated service signatures, model interfaces, response types, and endpoint-specific errors before writing calls.
  3. Use createPolar for the full service client. Use createPolarCore with individual service functions when bundle size or tree-shaking matters.
  4. Identify whether the access token is scoped to an organization. When the selected token does not imply one, create the client with createPolar({ ..., organizationId }) or pass organization_id, and confirm the required endpoint scopes.
  5. Keep client, webhook, and environment configuration in trusted server-side code.

Migrate from the old SDK

Read Migration from the <1.0.0 SDK before changing an application that imports an unversioned Polar class or uses camelCase request and response fields. Do not mix old and new client, field-casing, pagination, error, or webhook conventions.

Configure and reuse the client

Keep production and sandbox access tokens separate. Never expose an organization access token in browser, mobile, or other public client code. Pass environment: "sandbox" while testing; omit it or pass environment: "production" in production.

typescript
import { createPolar } from "@polar-sh/sdk/2026-10";

const accessToken = process.env.POLAR_ACCESS_TOKEN;
if (!accessToken) {
  throw new Error("POLAR_ACCESS_TOKEN is required");
}

const polar = createPolar({
  accessToken,
  environment: "sandbox",
});

const customerState = await polar.customers.getStateExternal("usr_123");

Create the client once for a long-running server and reuse it. The TypeScript client uses fetch and does not expose a connection-closing lifecycle.

For tree-shakable individual functions, create a core client and bind only the operations the application uses:

typescript
import { createPolarCore } from "@polar-sh/sdk/2026-10";
import { getStateExternalCustomers } from "@polar-sh/sdk/2026-10/services/customers";

const polarCore = createPolarCore({ accessToken });
const getCustomerState = getStateExternalCustomers(polarCore);
const customerState = await getCustomerState("usr_123");

Follow generated argument and output conventions

  • Use camelCase service names and methods such as benefitGrants, getStateExternal, and iterList.
  • Keep request, query, and response field names in API-style snake_case, such as external_customer_id.
  • Pass path parameters positionally.
  • Pass query parameters as an optional object after path parameters.
  • Pass request bodies as a single typed object.
  • Treat responses as typed plain JavaScript objects.
  • Expect UUID and date-time OpenAPI fields to remain strings.
  • Consume paginated iter* methods with for await; each additional page performs another API request.
typescript
for await (const customer of polar.customers.iterList({
  sorting: ["email"],
})) {
  console.log(customer.id);
}

Correlate customers with stable external IDs

Use the application's immutable user or organization identifier as the Polar customer external_id. It is unique within a Polar organization. It may be assigned later when initially unset, but it cannot be changed or removed once set.

typescript
const customer = await polar.customers.create({
  external_id: "usr_123",
  email: "user@example.com",
});
const customerState = await polar.customers.getStateExternal("usr_123");

Handle concurrent creation safely. A preflight lookup followed by creation is not atomic; if creation reports an existing email or external ID, fetch and reconcile the existing customer rather than creating a second mapping.

Show full SKILL.md (326 more words)Show less

Create checkout and customer portal sessions

Create checkout sessions on the server and send only the returned URL to the browser. Prefer external_customer_id so a completed checkout is reconciled with the application's customer.

typescript
const productId = process.env.POLAR_PRODUCT_ID;
if (!productId) {
  throw new Error("POLAR_PRODUCT_ID is required");
}

const checkout = await polar.checkouts.create({
  products: [productId],
  external_customer_id: "usr_123",
  success_url: "https://example.com/billing/success?checkout_id={CHECKOUT_ID}",
  return_url: "https://example.com/settings/billing",
});
redirect(checkout.url);

Do not treat the success redirect as proof of payment or entitlement. Confirm access through customer state or a verified webhook.

Create short-lived customer portal sessions only for an authenticated customer:

typescript
const session = await polar.customerSessions.create({
  external_customer_id: "usr_123",
  return_url: "https://example.com/settings/billing",
});
redirect(session.customer_portal_url);

Validate return URLs and never let an untrusted caller choose another customer's external ID.

Reconcile feature access from customer state

Prefer a feature_flag benefit attached to the relevant products over inferring access from subscription statuses. Reconcile both access grants and access revocations.

typescript
const benefitId = process.env.POLAR_BENEFIT_ID;
if (!benefitId) {
  throw new Error("POLAR_BENEFIT_ID is required");
}

const customerState = await polar.customers.getStateExternal("usr_123");
const enabled = customerState.granted_benefits.some(
  (grant) => grant.benefit_id === benefitId,
);

await setFeatureAccess({
  customerExternalId: "usr_123",
  enabled,
});

Make setFeatureAccess an idempotent application write. A missing benefit must disable access, not merely skip a grant operation.

For webhook-driven synchronization, use benefit-grant events for an incremental local grant ledger or customer.state_changed for complete snapshot reconciliation. Read Webhook processing before implementing or modifying a receiver.

Ingest metered usage events

Read Usage-event ingestion before implementing metered billing. In particular:

  • Match the event name and metadata to the configured meter.
  • Associate the event with exactly one customer_id or external_customer_id.
  • Assign every logical event a stable, unique external_id.
  • Reuse the same external_id when retrying so Polar can deduplicate the event.
  • Inspect both inserted and duplicates in the ingestion result.
  • Enforce usage limits in the application; ingestion does not reject an action because a customer has exhausted a balance.

Handle API failures intentionally

Handle generated endpoint-specific errors before broad SDK errors. Import base errors from @polar-sh/sdk and version-specific endpoint errors from the selected API version's errors namespace.

  • PolarNetworkError: retry only when the operation is safe or carries a stable deduplication identifier.
  • PolarRateLimitError: apply bounded backoff and honor retryAfter when present.
  • PolarServerError: retry selected 5xx failures with bounded exponential backoff and jitter.
  • PolarClientError: do not blindly retry authentication, authorization, validation, or not-found failures.

Never create a new usage-event external_id during a retry. For other mutations, use an endpoint-supported idempotency mechanism or application-level reconciliation before retrying.

© polarsource, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in sdk/typescript/.agents/skills/polar-typescript-sdk of polarsource/polar.

  • SKILL.md
  • agents/openai.yaml
  • references/migration-from-v0.md
  • references/usage-events.md
  • references/webhooks.md

Open the folder on GitHubat commit e4fc909

Compare with similar skills

Polar Typescript SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Polar Typescript SDK compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Polar Typescript SDK this skillpolarsource/polar10k—~2kAutomated safety check: PassApache-2.0
Chdb Datastorevemetric/vemetric3942 repos~1.4kAutomated safety check: PassApache-2.0
CSV Data Summarizercoffeefuelbump/csv-data-summarizer-claude-skill4682 repos~1.4kAutomated safety check: PassNone
Paper FiguresEvoScientist/EvoSkills4751 repos~4.4kAutomated safety check: PassApache-2.0
Python Executorcortega26/chile-hub1132 repos~1.5kAutomated safety check: PassMIT
DataframelyQuantco/dataframely619—~2.4kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Chdb Datastore

    vemetric/vemetric

    A skill your agent uses when the user has tabular data (pandas DataFrame, parquet, csv, Arrow, json) and wants to filter, group, aggregate, join, or speed up slow pandas.

    394 GitHub starsUsed in 2 repos~1.4k tokens
    Data & AnalyticsAuto-check passed
  • CSV Data Summarizer

    coffeefuelbump/csv-data-summarizer-claude-skill

    Analyzes CSV files, generates summary stats, and plots quick visualizations using Python and pandas.

    468 GitHub starsUsed in 2 repos~1.4k tokens
    Data & AnalyticsAuto-check passed
  • Paper Figures

    EvoScientist/EvoSkills

    A skill your agent uses to produce standalone, publication-ready PNG graphics and reproducible matplotlib scripts from tabular data (CSVs or DataFrames).

    475 GitHub starsUsed in 1 repo~4.4k tokens
    Data & AnalyticsAuto-check passed
  • Python Executor

    cortega26/chile-hub

    Execute Python code in a safe sandboxed environment via [inference.sh](https://inference.sh).

    113 GitHub starsUsed in 2 repos~1.5k tokens
    Data & AnalyticsAuto-check passed
  • Dataframely

    Quantco/dataframely

    Best practices for polars data processing with dataframely. An agent skill from Quantco/dataframely.

    619 GitHub stars~2.4k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Retentioneering Product Analytics

    retentioneering/retentioneering-tools

    Analyze event logs, clickstreams, user paths, product funnels, retention, behavioral segments, transition graphs, step matrices, sequence patterns, and customer journeys using Retentioneering.

    920 GitHub stars~1.6k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed

More from polarsource/polar

All 18 skills in this repo
  • Polar Python SDK

    polarsource/polar

    Integrate Polar billing in server-side Python applications using the versioned Polar and PolarAsync clients.

    10k GitHub stars~1.8k tokensUpdated yesterday
    Auto-check passed
  • Adr Check

    polarsource/polar

    Check a code change against the repo's Accepted Architecture Decision Records (ADRs) in handbook/engineering/decisions/ and report violations with citations.

    10k GitHub stars~771 tokensUpdated yesterday
    Auto-check passed
  • API Surface Review

    polarsource/polar

    Review changes to Polar's API contract — Pydantic schemas, FastAPI endpoints, OpenAPI output and the generated SDKs.

    10k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • Billing Review

    polarsource/polar

    Review a diff that touches Polar's billing domain — subscriptions, cycles and crons, orders, billing entries, meters and usage, discounts, checkout, payments and dunning, refunds, disputes, payouts…

    10k GitHub stars~2.3k tokensUpdated yesterday
    Auto-check passed
  • Interview Task

    polarsource/polar

    Prepare an interview task for a candidate, as part of our hiring process.

    10k GitHub stars~933 tokensUpdated yesterday
    Auto-check passed
  • Open PR

    polarsource/polar

    Open or update a draft GitHub pull request after Polar-specific review and cubic CLI review.

    10k GitHub stars~586 tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Polar Typescript SDK

What does Polar Typescript SDK do?

Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients. Polar Typescript SDK is an agent skill from polarsource/polar. Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients.

When should I use Polar Typescript SDK?

Polar Typescript SDK fits situations like: implementing Polar customers and external IDs; customer portal sessions; customer-state entitlement checks; webhook validation and processing.

How do I install Polar Typescript SDK in Claude Code?

Run `npx skills add polarsource/polar --skill polar-typescript-sdk -a claude-code`. Or copy the skill folder (sdk/typescript/.agents/skills/polar-typescript-sdk in polarsource/polar) into .claude/skills/polar-typescript-sdk in your project. Claude Code loads it when a task matches its description.

How do I install Polar Typescript SDK in Codex?

Run `npx skills add polarsource/polar --skill polar-typescript-sdk -a codex`. Or copy the skill folder (sdk/typescript/.agents/skills/polar-typescript-sdk in polarsource/polar) into .agents/skills/polar-typescript-sdk in your project. Codex loads it when a task matches its description.

Can I use Polar Typescript SDK in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add polarsource/polar --skill polar-typescript-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/polar-typescript-sdk, .gemini/skills/polar-typescript-sdk, .github/skills/polar-typescript-sdk and .opencode/skills/polar-typescript-sdk in your project.

What does Polar Typescript SDK need to run?

Going by SKILL.md and its folder, Polar Typescript SDK needs credentials named POLAR_ACCESS_TOKEN. Our summary lists: A credential in POLAR_ACCESS_TOKEN.

Does Polar Typescript SDK access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Polar Typescript SDK safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Polar Typescript SDK use?

Polar Typescript SDK is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Polar Typescript SDK use?

About 2k tokens (SKILL.md is roughly 8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.1k tokens, read only when the agent opens those files.

What are the alternatives to Polar Typescript SDK?

Skills that share tags, products or a category with Polar Typescript SDK: Chdb Datastore (vemetric/vemetric, 394 stars), CSV Data Summarizer (coffeefuelbump/csv-data-summarizer-claude-skill, 468 stars), Paper Figures (EvoScientist/EvoSkills, 475 stars) and Python Executor (cortega26/chile-hub, 113 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Polar Typescript SDK?

polarsource (a GitHub organization) maintains it in polarsource/polar, which has 10,340 GitHub stars. The repository holds 18 skills in this directory. The repository was last updated on October 7, 2026.

Source: polarsource/polar on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.