License keys

Sell desktop apps, plugins, and CLIs that activate offline. SettleKit issues license keys bound to a customer and product, enforces machine and domain activation limits, and can hand out signed tokens that verify without a network round-trip.

Issue a key

LicenseService wraps a store plus a token secret. issue takes a CreateLicenseKeyInput — the organization, customer, product, the entitlement it fulfills, and the activation limits — and returns a LicenseKey.

issue a license keyts
import {
  LicenseService,
  InMemoryLicenseStore,
} from "@settlekit/license-keys";

const licenses = new LicenseService(new InMemoryLicenseStore(), {
  tokenSecret: process.env.LICENSE_TOKEN_SECRET!,
});

const license = await licenses.issue({
  organizationId: "org_acme",
  customerId: "cus_123",
  productId: "prod_desktop_app",
  entitlementId: "ent_456",
  machineLimit: 3,
  domainLimit: 1,
  // expiresAt is optional for perpetual licenses
});

console.log(license.key); // the key string to deliver to the buyer

Verify a key

Your app calls verify with the key string, the product, and a stable machine id. The service evaluates status (active, revoked, expired, machine-limit) and, when a new machine activates, persists the updated activation list.

verify on app launchts
const result = await licenses.verify({
  licenseKey: userEnteredKey,
  productId: "prod_desktop_app",
  machineId: "machine-fingerprint-abc",
});

if (!result.active) {
  throw new Error(result.reason ?? "license_invalid");
}

VerifyResult.reason is one of the typed VerifyReason values (for example not_found, revoked, expired, machine_limit), so your UI can show a precise message.

Offline tokens

For fully offline apps, issue a signed token the client verifies locally against the public payload — no call back to SettleKit needed until the token expires.

issue a signed offline tokents
// Sign a short-lived token bound to the license id.
const token = await licenses.issueToken(license.id);

// Ship the token with the app; the client verifies it offline with the same
// secret (or a verifying key) using verifyLicenseToken from the package.

Activation management

Move a license between machines or revoke it entirely. Each call returns a new, persisted LicenseKey — the underlying domain functions are immutable.

manage activationsts
await licenses.activateMachine(license.id, "machine-fingerprint-xyz");
await licenses.deactivateMachine(license.id, "machine-fingerprint-abc");
await licenses.revoke(license.id);

Next

Prefer per-call billing for an API instead of a license? See Paid APIs (x402). Want to bundle a license with other products? Bundles.