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 URL | Production: https://licence.leverine.com · Development: https://leverine-licensing-dev.leverine.workers.dev. Your own deployment has its own issuer host and the identical API. |
|---|---|
| Format | JSON request and response bodies throughout. POST bodies must be a JSON object; an unparseable or non-object body is 400 invalid_json. |
| Times | Timestamps 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 auth | Lifecycle 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 auth | Operator 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. |
| Errors | Errors 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 limits | POST /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
/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.
/
Service root: name, version, environment, and pointers to /health and /v1/keys.
/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.
/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.
| Field | Type | Required | Notes |
|---|---|---|---|
| key | string | yes | The LVN- licence key. |
| instanceId | string | yes | Stable per-install identifier chosen by your app. Max 200 characters. |
| label | string | no | Human-readable device label, shown in status and support views. Truncated to 200 characters. |
| appVersion | string | no | Your 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
}
| Error | HTTP | Meaning |
|---|---|---|
| device_cap_reached | 409 | The 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_revoked | 403 | The licence has been revoked. |
| licence_readonly | 403 | The licence is past its grace window. Renew to activate new deployments. |
| instance_id_required | 400 | instanceId missing or over 200 characters. |
| key_required | 400 | No key in the body. |
| invalid_key | 400 / 401 | 400: the key is malformed (fails the checksum). 401: well-formed, but no licence matches it. The 401 reveals nothing about which part failed. |
| rate_limited | 429 | Per-IP or per-key budget exhausted; see retryAfterSeconds. |
/v1/deactivate
Deactivate a deployment, freeing its cap slot. Idempotent: deactivating an already-deactivated deployment succeeds with alreadyDeactivated: true.
| Field | Type | Required | Notes |
|---|---|---|---|
| key | string | yes | The LVN- licence key. |
| instanceId | string | yes | The 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.
/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.
| Field | Type | Required | Notes |
|---|---|---|---|
| key | string | yes | The LVN- licence key. |
| instanceId | string | no | If 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.
/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.
/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.
| Field | Type | Required | Notes |
|---|---|---|---|
| productId | string | yes | A product registered on this deployment. |
| tier | string | yes | A plan defined in the product’s configuration. |
| kind | string | no | Licence kind. Default paid. |
| customerRef | string | no | Your reference for the customer. |
| customerEmail | string | no | Recorded on the licence row. |
| deviceCap | number | no | Overrides the plan’s device cap. |
| tokenTtlSeconds | number | no | Overrides the plan’s token TTL. |
| licenceDays | number | no | Licence 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).
/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.
/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.
| Field | Type | Required | Notes |
|---|---|---|---|
| licenceId | string | yes | The licence to revoke. |
| reason | string | no | Recorded 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.
/v1/admin/licences
List licences, newest first, with derived state, Paddle linkage, and live deployment counts.
| Query parameter | Notes |
|---|---|
| product | Filter by product id. |
| status | Filter by stored status (e.g. active, grace, revoked). |
| paddleCustomerId | Filter by Paddle customer id. |
| limit | Page size. Default 50, clamped to 1–200. |
| offset | Default 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.
/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.
/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.
| Field | Type | Required | Notes |
|---|---|---|---|
| status | string | yes | One of active, grace, readonly, revoked, expired. |
| reason | string | yes | Why — 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.
| Code | HTTP | Where |
|---|---|---|
| invalid_json | 400 | Any POST — body is not a JSON object. |
| not_found | 404 | Unknown route. |
| method_not_allowed | 405 | Known route, wrong method. |
| internal_error | 500 | Unhandled failure; the response reveals nothing further. |
| key_required | 400 | Lifecycle — no key presented. |
| invalid_key | 400 / 401 | Lifecycle — malformed key (400) or no matching licence (401). |
| instance_id_required | 400 | Activate / deactivate — missing or oversized instanceId. |
| licence_revoked | 403 | Activate — licence revoked. |
| licence_readonly | 403 | Activate — licence past grace. |
| device_cap_reached | 409 | Activate — cap full; body carries cap + activeDeployments. |
| deployment_not_found | 404 | Deactivate — unknown instanceId. |
| rate_limited | 429 | Activate / refresh — body carries retryAfterSeconds; Retry-After header set. |
| lifecycle_not_configured | 503 | Lifecycle — signing material or pepper unset on the deployment. |
| unauthorized | 401 | Admin — missing or wrong bearer token. |
| admin_not_configured | 503 | Admin — ADMIN_TOKEN unset; the surface fails closed. |
| issuance_not_configured | 503 | Issue / comp — signing material unset on the deployment. |
| productId_and_tier_required | 400 | Issue / comp — missing productId or tier. |
| unknown_product | 400 | Issue / comp — product not registered on this deployment. |
| unknown_tier | 400 | Issue / comp — the product has no such plan. |
| bad_product_config | 400 | Issue / comp — the product’s stored configuration is unparseable. |
| licence_id_required | 400 | Revoke — no licenceId. |
| licence_not_found | 404 | Revoke / admin get / admin state — unknown licence id. |
| invalid_status | 400 | Admin state — target not one of the forceable states. |
| reason_required | 400 | Admin state — a forced change needs its audit reason. |