Leverine · Licensing · Documentation
Licensing, documented
Everything an integrating app needs: the concepts behind Leverine Licensing, the full HTTP API, the Paddle webhook contract, and a step-by-step integration guide with working code. This documentation describes the production service as deployed — service version 0.4.2.
https://licence.leverine.com
Keys: LVN-…
Tokens: ML-DSA-65 signed
API reference
Every endpoint — lifecycle, operator, keys, health — with parameters, response shapes, error codes, and rate limits.
Webhooks
How Paddle Billing events are verified, recorded, and turned into licences: signature scheme, idempotency, outcomes.
Integration guide
Purchase → activation → offline verification → refresh, with curl and TypeScript examples using the reference library.
Walkthrough
A real PVEZ-v2 licence end to end — purchase, issuance, activation, the deployment cap, grace, and revocation — with the actual IDs, payloads, and states from a documented run.
Concepts
What the service is
Leverine Licensing is a hosted licensing service for independent developers. It issues licence keys, binds them to a bounded number of devices (“deployments”), and hands apps a signed licence token they can verify offline — no phone-home on every launch, no licensing server of your own to run.
One deployment per customer. Every vendor gets their own deployment of the service: their own Worker, database, secrets, and issuer. There is no shared tenancy layer — your customers’ licences live in your deployment, under your products, and nobody else’s outage or data touches them. The production Leverine deployment answers at https://licence.leverine.com; your deployment answers at its own issuer host, with the identical API.
Billing is Paddle. Paddle is the merchant of record for checkouts. A completed purchase reaches your deployment as a signed webhook and becomes a licence automatically (see Webhooks). Operators can also issue licences directly through the admin API — for comps, trials, support, and migration imports.
State is derived, never stored as a flag. Neither the server nor the client library keeps a “licensed” boolean. Licence state is computed on every read from the licence record (or the token) and the clock, so there is no single switch anyone — attacker, bug, or operator — can flip to make an app licensed.
Concepts
Licence keys: the LVN- format
A licence key looks like this:
LVN-XXXXX-XXXXX-XXXXX-XXXXX
| Prefix | LVN- — every Leverine licence key starts with it. |
|---|---|
| Body | 20 characters in four groups of five, Crockford base32 (digits and letters, excluding I, L, O, U to avoid look-alikes). |
| Checksum | The last group is a CRC32 check group computed over the first fifteen characters. A typo fails the checksum locally — before the key ever reaches the service, and again server-side before any database lookup. |
| Tolerant input | Keys are normalized before use: case doesn’t matter, separators are ignored, and the classic confusions are repaired (O→0, I/L→1, U→V). Paste a key however your customer copied it. |
| Derived, not stored | A key is derived deterministically from the licence’s id with a secret pepper (HMAC-SHA256). The database stores only a keyed hash of the key — used for lookup — plus its last four characters (keyLookup) for display in support contexts. The full key is shown exactly once, at issuance; because it is derived, an operator can always re-derive a customer’s key from the licence id for support. |
| The key is the credential | The lifecycle API (activate, deactivate, refresh, status) authenticates with the licence key itself. A signed token is not accepted as an API credential — tokens prove entitlement offline; the key talks to the API. |
Concepts
Licence tokens
Activation and refresh return a licence token: a three-segment envelope, header.payload.signature, each segment base64url. Header and payload are canonical JSON (sorted keys), and the signature covers the encoded segments exactly as transmitted.
| Algorithm | ML-DSA-65 (FIPS 204, post-quantum) — named in the header’s alg from the first token ever issued, so a future algorithm arrives as a new key id, not a new format. |
|---|---|
| Header | { "alg": "ML-DSA-65", "kid": "<key id>", "typ": "LVN" }. The kid selects the verification key. The current production key is 2026-12-prod. |
| Public keys | Served at GET /v1/keys — current and retiring keys together, so apps rotate trust without an update. Public keys are public: fetch them, cache them, and pin a fallback set in your app build. |
| Token lifetime | 30 days by default (configurable per plan), and never past the licence’s own expiry. An app can verify offline until the token expires, then through the 7-day grace window — see states below. |
Token claims
| Claim | Type | Meaning |
|---|---|---|
| iss | string | Issuer — the deployment’s issuer string. Production: licence.leverine.com. Clients must not hard-code it; read it from the token. |
| sub | string | Subject — the licence id (UUID). |
| product | string | The product id this token entitles. A verifier refuses a token for any other product. |
| tier | string | Plan / tier name within the product. |
| cap | number | Deployment (device) cap for the licence. 0 means the plan sets no deployment cap. |
| feats | string[] | Feature grants for this licence, from the plan configuration. |
| iat | number | Issued-at, unix seconds. |
| exp | number | Token expiry, unix seconds. Licence state derives from this plus grace. |
| jti | string | Token id (UUID), for correlating with the service’s audit events. |
| ver | number | Envelope version — currently 1. |
An example token header, decoded — this is the real production header shape:
eyJhbGciOiJNTC1EU0EtNjUiLCJraWQiOiIyMDI2LTEyLXByb2QiLCJ0eXAiOiJMVk4ifQ
→ { "alg": "ML-DSA-65", "kid": "2026-12-prod", "typ": "LVN" }
Concepts
Licence states
Two vocabularies describe the same reality. The API reports server states; the client library derives its own states from the token and the clock, and maps the server’s answer onto them when it refreshes.
| API state | Client state | What it means |
|---|---|---|
| active | licensed | Paid up and inside term. Full function. |
| grace | grace | Past expiry — or a Paddle payment is past due — but inside the 7-day grace window. Full function; the app should warn that renewal is overdue. |
| read-only | read-only | Past the grace window. The licence no longer activates new deployments and no longer entitles full function — but data stays readable and exportable. A lapsed licence is never simply dead. |
| revoked | unlicensed | An operator revoked the licence. Refresh answers state: "revoked" with no token, and the client derives unlicensed — even if the token in hand hasn’t expired, because revocation is exactly the fact a token cannot know. |
| — | unlicensed | Also the client state for a structurally invalid token: malformed, wrong alg, unknown kid, bad signature, or a token for a different product. |
The grace window is 7 days everywhere: past expiry, past a cancellation’s paid-through date, and in the client library’s derivation (GRACE_SECONDS = 7 × 86,400).
Terms, as issued today
- A licence’s term follows the billing period of the price bought, with the 7-day grace window after it. Monthly prices issue one-month licences that run their monthly term and renew monthly; annual prices issue 365-day licences, paid up front.
- Tokens live at most 30 days (plan-configurable) and never past the licence’s expiry; refresh mints a fresh one.
- A cancellation never kills a licence mid-term: the webhook shortens expiry to the paid-through date, and no further.
Billing periods are live: terms are billing-period-aware in production — the billing period recorded on each licence sets its term at issuance: one month for monthly prices, 365 days for annual prices.
Concepts
Deployments and device caps
A deployment is one installation bound to a licence, identified by an instanceId your app chooses (a stable per-install id, up to 200 characters) and may describe with a label and appVersion.
- Hard-refuse caps. When a licence’s active deployments reach its cap, a new activation is refused with
409 device_cap_reached— an existing deployment is never silently displaced. The refusal carries the cap and the live count so your app can explain it and offer to deactivate another device. - Idempotent check-in. Re-activating an already-active deployment just updates its last-seen time — it is never a cap event, however full the licence is.
- Deactivation frees the slot and is itself idempotent. A deactivated deployment can be reactivated later, subject to the same cap.
- Cap 0 means uncapped at the deployment level (the service’s own tiers limit by active-licence count instead).
- Everything is audited. Activations, deactivations, refreshes, cap refusals, revocations, and forced state changes all write rows to the licence’s event log, visible through the admin API. Event payloads carry ids and lookups — never key material.
Ready to build? Start with the integration guide, and keep the API reference open beside it.