Migration
Change the base URL. Keep the calls.
Keyharbor answers the three public License API routes. Requests are form-encoded. Responses use the JSON fields from the API reference, with timestamps like 2021-01-24T14:15:07.000000Z.
The one-line diff
- https://api.lemonsqueezy.com
+ https://licenses.yourdomain.comcurl -X POST https://licenses.yourdomain.com/v1/licenses/activate \
-H "Accept: application/json" \
-d "license_key=YOUR_KEY" \
-d "instance_name=office-mac"Routes
POST /v1/licenses/activate—license_key,instance_name. Returnsactivated,license_key,instance,meta.POST /v1/licenses/validate—license_key, optionalinstance_id. Without an instance id,instanceis null.POST /v1/licenses/deactivate—license_key,instance_id. Removes that instance. The key itself stays.
Status is inactive (valid, no activations), active, expired, or disabled. Missing fields are HTTP 422. An unknown key is 404. A known key that cannot be used — expired, disabled, over the activation limit, or a bad instance — is 400, and the body still includes error plus the license when we have it. A null activation_limit means unlimited.
Deploy
- Install dependencies and log in with Wrangler.
- Create a D1 database and paste its id into
wrangler.toml. - Apply migrations, set
ADMIN_TOKENand the webhook secrets, deploy. - Import your seed, then ship an app build whose base URL is your worker.
The repository README has the commands, in order, including the local seed key.
New sales
Point signed webhooks at /v1/webhooks/stripe, /v1/webhooks/creem, /v1/webhooks/dodo, or /v1/webhooks/paddle. A paid checkout mints UUID keys. Put product_name, activation_limit, and license_days in the provider metadata when you want those values. The worker does not email the customer. Read the key from the webhook response or keyharbor-admin list, and send it yourself.
Offline grace
Store the last successful validate response and the instance.id from activate. If a later check fails because the device is offline, the worker timed out, or the worker returned a 5xx, keep the last valid result for a window you choose — seven days is a reasonable start. If the response is a 4xx that says the key is expired, disabled, unknown, or over its limit, lock immediately. A network error is not an invalid key.
Pass-through
Set PASSTHROUGH_UNTIL to a date. Until the end of that day, a key this worker has never seen is forwarded to Lemon Squeezy and cached. After the date, unknown keys are simply not found. Keys you imported never take that trip.