Leverine · Licensing · Documentation

API reference

The complete HTTP surface of a Leverine Licensing deployment — every route the production service (version 0.4.2) answers, with parameters, response shapes, and error codes.

Reference

Conventions

Base URLProduction: https://licence.leverine.com · Development: https://leverine-licensing-dev.leverine.workers.dev. Your own deployment has its own issuer host and the identical API.
FormatJSON request and response bodies throughout. POST bodies must be a JSON object; an unparseable or non-object body is 400 invalid_json.
TimesTimestamps in responses are ISO 8601 UTC strings (e.g. 2027-12-04T00:00:00.000Z), except fields whose names end in At on token-bearing responses (tokenExpiresAt, serverTime), which are unix seconds.
Key authLifecycle endpoints authenticate with the licence key: in the JSON body as key for POSTs, or as Authorization: Bearer <key> for GET /v1/status. There is deliberately no query-string form — keys don’t belong in URLs or logs.
Admin authOperator endpoints require Authorization: Bearer <ADMIN_TOKEN>. Comparison is constant-time; while the token is unset on a deployment the surface fails closed with 503 admin_not_configured. There is no unauthenticated operator path and no master key.
ErrorsErrors are JSON: { "error": "<code>", "message": "<human-readable>" } — some carry extra machine-readable fields (documented per endpoint). Unknown routes answer 404 { "error": "not_found" }, wrong methods 405 { "error": "method_not_allowed" }.
Rate limitsPOST /v1/activate and POST /v1/refresh are throttled, in fixed 60-second windows: 300 requests/minute per IP (counted before authentication, failures included) and, per licence key, 20/minute for activate and 60/minute for refresh. Over the limit: 429 rate_limited with retryAfterSeconds in the body and a matching Retry-After header. Deactivate and status are not throttled — they mint nothing and are how a throttled customer checks their state.

Reference

Service endpoints

GET

/health

Liveness and database reachability. Unauthenticated by design; reports no configuration, no counts, and no key material.

curl https://licence.leverine.com/health
{
  "status": "ok",
  "service": "leverine-licensing",
  "version": "0.4.2",
  "environment": "production",
  "db": "up",
  "dbLatencyMs": 82,
  "time": "2026-12-04T06:05:35.387Z"
}

If the database is unreachable the same shape answers 503 with "status": "degraded", "db": "down", and "dbLatencyMs": null.

GET

/

Service root: name, version, environment, and pointers to /health and /v1/keys.

GET

/v1/keys

The deployment’s public verification keys — current and retiring, by kid — so client apps rotate trust without an update. Public by design and cacheable (Cache-Control: public, max-age=300). Fetch this set, cache it, and pin a fallback copy in your app build.

curl https://licence.leverine.com/v1/keys
{
  "keys": [
    {
      "kid": "2026-12-prod",
      "alg": "ML-DSA-65",
      "status": "current",
      "publicKey": "ORU5yQ7/VQtK… (base64, 1,952 bytes)"
    },
    {
      "kid": "2026-12-dev",
      "alg": "ML-DSA-65",
      "status": "retiring",
      "publicKey": "Gn229JhvlFDw… (base64, 1,952 bytes)"
    }
  ]
}

Verifiers accept tokens signed by either key while both are listed. A key is dropped from this list only once every token it signed has expired.

Reference

Lifecycle endpoints

Authenticated by the licence key. States below use the API vocabulary: active, grace, read-only, revoked.

POST

/v1/activate

Bind a deployment (one installation) to the licence and receive a fresh licence token. Re-activating an already-active deployment is an idempotent check-in — it updates last-seen and returns a fresh token, and never counts against the cap. A licence in grace can still activate; a revoked or read-only licence cannot.

FieldTypeRequiredNotes
keystringyesThe LVN- licence key.
instanceIdstringyesStable per-install identifier chosen by your app. Max 200 characters.
labelstringnoHuman-readable device label, shown in status and support views. Truncated to 200 characters.
appVersionstringnoYour app’s version string. Truncated to 64 characters.
curl -X POST https://licence.leverine.com/v1/activate \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "LVN-XXXXX-XXXXX-XXXXX-XXXXX",
    "instanceId": "install-9f27c1",
    "label": "Studio Mac",
    "appVersion": "2.4.1"
  }'
{
  "licenceId": "9b1e…(uuid)",
  "product": "pvez-v2",
  "tier": "shop",
  "state": "active",
  "deployment": {
    "id": "c41a…(uuid)",
    "instanceId": "install-9f27c1",
    "status": "active",
    "reactivated": false
  },
  "token": "eyJhbGciOi…(three base64url segments)",
  "tokenExpiresAt": 1798934400,
  "deviceCap": 3,
  "activeDeployments": 1
}
ErrorHTTPMeaning
device_cap_reached409The cap is full. Body adds cap and activeDeployments. Deactivate a deployment first — nothing is silently displaced. The refusal is written to the licence’s audit log.
licence_revoked403The licence has been revoked.
licence_readonly403The licence is past its grace window. Renew to activate new deployments.
instance_id_required400instanceId missing or over 200 characters.
key_required400No key in the body.
invalid_key400 / 401400: the key is malformed (fails the checksum). 401: well-formed, but no licence matches it. The 401 reveals nothing about which part failed.
rate_limited429Per-IP or per-key budget exhausted; see retryAfterSeconds.
POST

/v1/deactivate

Deactivate a deployment, freeing its cap slot. Idempotent: deactivating an already-deactivated deployment succeeds with alreadyDeactivated: true.

FieldTypeRequiredNotes
keystringyesThe LVN- licence key.
instanceIdstringyesThe deployment to deactivate.
curl -X POST https://licence.leverine.com/v1/deactivate \
  -H 'Content-Type: application/json' \
  -d '{ "key": "LVN-XXXXX-XXXXX-XXXXX-XXXXX", "instanceId": "install-9f27c1" }'
{
  "licenceId": "9b1e…(uuid)",
  "instanceId": "install-9f27c1",
  "deactivated": true,
  "alreadyDeactivated": false,
  "activeDeployments": 0
}

Unknown instanceId for this licence: 404 deployment_not_found.

POST

/v1/refresh

Exchange the key for the server’s current view: a freshly minted token (expiry capped at the licence’s own expiry) plus the licence’s state, expiry, and grace deadline. This is the call that learns about revocations, Paddle past-due grace, and cancellation caps — the things a token cannot know. If a past-due licence has since been paid, refresh is also where its grace is cleared back to active.

FieldTypeRequiredNotes
keystringyesThe LVN- licence key.
instanceIdstringnoIf given and that deployment is active, its last-seen time is updated.
curl -X POST https://licence.leverine.com/v1/refresh \
  -H 'Content-Type: application/json' \
  -d '{ "key": "LVN-XXXXX-XXXXX-XXXXX-XXXXX", "instanceId": "install-9f27c1" }'
{
  "licenceId": "9b1e…(uuid)",
  "product": "pvez-v2",
  "tier": "shop",
  "state": "active",
  "token": "eyJhbGciOi…(three base64url segments)",
  "tokenExpiresAt": 1798934400,
  "licenceExpiresAt": "2027-12-04T00:00:00.000Z",
  "graceUntil": "2027-12-11T00:00:00.000Z",
  "serverTime": 1796342400
}

A revoked licence still answers 200 — with "state": "revoked" and "token": null — so clients can fold the answer into their state derivation instead of treating it as a transport error.

GET · POST

/v1/status

Read a licence’s full state without minting anything: derived state, stored status, cap, every deployment, and Paddle linkage. GET takes the key as a bearer token; POST takes { "key": … } in the body (a bearer token also works).

curl https://licence.leverine.com/v1/status \
  -H 'Authorization: Bearer LVN-XXXXX-XXXXX-XXXXX-XXXXX'
{
  "licenceId": "9b1e…(uuid)",
  "product": "pvez-v2",
  "tier": "shop",
  "kind": "paid",
  "state": "active",
  "storedStatus": "active",
  "licenceExpiresAt": "2027-12-04T00:00:00.000Z",
  "graceUntil": "2027-12-11T00:00:00.000Z",
  "deviceCap": 3,
  "activeDeployments": 1,
  "deployments": [
    {
      "instanceId": "install-9f27c1",
      "label": "Studio Mac",
      "appVersion": "2.4.1",
      "status": "active",
      "firstSeenAt": "2026-12-04T00:00:00.000Z",
      "lastSeenAt": "2026-12-04T00:00:00.000Z",
      "deactivatedAt": null
    }
  ],
  "paddle": {
    "customerId": "ctm_…",
    "subscriptionId": "sub_…",
    "orderId": "txn_…"
  },
  "serverTime": 1796342400
}

paddle is null for licences with no Paddle linkage (comps, manual issues). kind records how the licence came to exist — paid, comp, or an operator-chosen kind.

Reference

Operator endpoints

For the deployment’s operator — issuance, comps, revocation, inspection, and forced state. All require Authorization: Bearer <ADMIN_TOKEN>, and every action writes an audit event. Operator tooling is API-only; there is no unauthenticated path and no master key.

POST

/v1/admin/issue

Issue a licence directly. The response contains the full key — shown once; the service stores only its hash and last four characters.

FieldTypeRequiredNotes
productIdstringyesA product registered on this deployment.
tierstringyesA plan defined in the product’s configuration.
kindstringnoLicence kind. Default paid.
customerRefstringnoYour reference for the customer.
customerEmailstringnoRecorded on the licence row.
deviceCapnumbernoOverrides the plan’s device cap.
tokenTtlSecondsnumbernoOverrides the plan’s token TTL.
licenceDaysnumbernoLicence term in days. Default 365.
curl -X POST https://licence.leverine.com/v1/admin/issue \
  -H 'Authorization: Bearer <ADMIN_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "productId": "pvez-v2", "tier": "shop", "customerRef": "order-1042" }'
{
  "licenceId": "9b1e…(uuid)",
  "key": "LVN-…(full key, shown once)",
  "keyLookup": "…(last 4 characters)",
  "token": "eyJhbGciOi…(three base64url segments)",
  "kid": "2026-12-prod",
  "issuedAt": "2026-12-04T00:00:00.000Z",
  "licenceExpiresAt": "2027-12-04T00:00:00.000Z",
  "tokenExpiresAt": 1798934400
}

Errors: 400 productId_and_tier_required · 400 unknown_product / unknown_tier / bad_product_config · 503 issuance_not_configured (signing material unset on the deployment).

POST

/v1/admin/comp

Hand-issue a complimentary licence — the founding-dealer pattern. Same fields and response as /v1/admin/issue, with kind forced to comp, plus an optional reason string recorded in the licence.comped audit event.

POST

/v1/revoke

Revoke a licence. Revocation is a state, not a deletion: the row stays, refresh starts answering revoked, and clients derive unlicensed. Idempotent — re-revoking answers with alreadyRevoked: true and the original revokedAt.

FieldTypeRequiredNotes
licenceIdstringyesThe licence to revoke.
reasonstringnoRecorded in the licence.revoked audit event.
{
  "licenceId": "9b1e…(uuid)",
  "state": "revoked",
  "revokedAt": "2026-12-04T00:00:00.000Z",
  "alreadyRevoked": false
}

Errors: 400 licence_id_required · 404 licence_not_found.

GET

/v1/admin/licences

List licences, newest first, with derived state, Paddle linkage, and live deployment counts.

Query parameterNotes
productFilter by product id.
statusFilter by stored status (e.g. active, grace, revoked).
paddleCustomerIdFilter by Paddle customer id.
limitPage size. Default 50, clamped to 1–200.
offsetDefault 0.

Response: { "licences": [ … ], "limit": 50, "offset": 0 }, where each entry is a summary: licenceId, product, tier, kind, status (stored), state (derived), keyLookup, customerRef, customerEmail, deviceCap, paddle (or null), issuedAt, expiresAt, graceUntil, revokedAt, activeDeployments.

GET

/v1/admin/licences/:id

One licence in full: the list summary, plus its deployments (same shape as /v1/status) and its recentEvents — the 25 most recent audit events, each { id, type, actor, payload, createdAt }. Unknown id: 404 licence_not_found.

POST

/v1/admin/licences/:id/state

Force a licence’s stored status — support interventions such as un-gracing a paid-up licence or parking one as read-only. A reason is required and is recorded with the from/to states in a licence.state_forced audit event.

FieldTypeRequiredNotes
statusstringyesOne of active, grace, readonly, revoked, expired.
reasonstringyesWhy — written to the audit log. Missing or blank: 400 reason_required.
{
  "licenceId": "9b1e…(uuid)",
  "from": "grace",
  "status": "active",
  "state": "active"
}

Errors: 400 invalid_status · 400 reason_required · 404 licence_not_found. Forcing active restores the standard grace arithmetic (expiry + 7 days); forcing revoked stamps revokedAt, and forcing any other state on a revoked licence clears it.

Reference

Error index

Every error code the service answers, in one place. Webhook-specific failures live on the webhooks page.

CodeHTTPWhere
invalid_json400Any POST — body is not a JSON object.
not_found404Unknown route.
method_not_allowed405Known route, wrong method.
internal_error500Unhandled failure; the response reveals nothing further.
key_required400Lifecycle — no key presented.
invalid_key400 / 401Lifecycle — malformed key (400) or no matching licence (401).
instance_id_required400Activate / deactivate — missing or oversized instanceId.
licence_revoked403Activate — licence revoked.
licence_readonly403Activate — licence past grace.
device_cap_reached409Activate — cap full; body carries cap + activeDeployments.
deployment_not_found404Deactivate — unknown instanceId.
rate_limited429Activate / refresh — body carries retryAfterSeconds; Retry-After header set.
lifecycle_not_configured503Lifecycle — signing material or pepper unset on the deployment.
unauthorized401Admin — missing or wrong bearer token.
admin_not_configured503Admin — ADMIN_TOKEN unset; the surface fails closed.
issuance_not_configured503Issue / comp — signing material unset on the deployment.
productId_and_tier_required400Issue / comp — missing productId or tier.
unknown_product400Issue / comp — product not registered on this deployment.
unknown_tier400Issue / comp — the product has no such plan.
bad_product_config400Issue / comp — the product’s stored configuration is unparseable.
licence_id_required400Revoke — no licenceId.
licence_not_found404Revoke / admin get / admin state — unknown licence id.
invalid_status400Admin state — target not one of the forceable states.
reason_required400Admin state — a forced change needs its audit reason.