License keys
A key with every sale, checked from inside your app with one call and no API key.
Choose License key as the delivery of your Buy with Guiru offer. Every sale issues a key, the buyer finds it on their purchase page, and your app checks it. Nothing to host and no secret to ship: the key is the credential, so this works inside a desktop app, a game, a plugin or a CLI.
/api/v1/licenses/validate{ product_id, key, instance_id? }. Is the key valid right now? With instance_id, also whether it is active on that machine.
/api/v1/licenses/activate{ product_id, key, instance_id, label? }. Take a seat for this machine. Idempotent. 409 activation_limit when every seat is taken; 403 invalid when the key is not valid.
/api/v1/licenses/deactivate{ product_id, key, instance_id }. Free this machine's seat — on sign-out or uninstall. Idempotent.
- validboolean
- The only field your gate should branch on.
- statusstring
active;canceled(still valid untilexpires_at);expired;refunded;revoked(you revoked it);not_found(a wrong key, or a key of another product — the same answer on purpose).- expires_atISO 8601 | null
- When it stops.
nullmeans it does not expire on its own. - activations{ used, limit }
- Seats in use and your limit (
null= no limit). - instance_activeboolean | null
- With an
instance_id: whether the key is active on that machine.
curl -X POST https://onguiru.com/api/v1/licenses/activate \
-H 'content-type: application/json' \
-d '{"product_id":"<your product id>","key":"GURU-XXXXX-XXXXX-XXXXX-XXXXX","instance_id":"<a stable id for this machine>","label":"Work laptop"}'import { createLicenseClient } from "@guiru/sdk";
const licenses = createLicenseClient({ productId: "<your product id>" });
const check = await licenses.activate(key, { instanceId: machineId, label: hostname });
if (check.valid) start();
else if (check.error === "activation_limit") askToFreeAMachine();
else explain(check.status);Machines
Set Machines per key on the offer (blank means no limit). instance_id is yours to choose — a stable id for the install, hashed before it is stored. Buyers free a machine themselves from their purchase page; from the Licenses tab of your console you can free every machine of a key, or revoke a key that leaked.
Offline
Check on start and then every few hours, not on every action, and keep working through a network error with the last answer you got. Calls are rate-limited per address and per key; an app that checks sensibly never meets the limit.