Sell activation keys
For retail sale, for example a box on a shelf or a key sold by a reseller, sell activation keys. The customer types a key into your software, and LaaSio activates it on up to the key’s device limit. Every device on a key shares one term, which starts at the key’s first activation.
How it works
Section titled “How it works”- On the Keys tab in the console, generate keys or upload your own from a CSV file, and link each key to a SKU. A key without a SKU is stock: it can’t be activated yet.
- Your software sends the key once, when the customer enters it, in the body of
POST /api/v1/lookup. - LaaSio puts the device on the key, as an ordinary client holding the key’s SKU, and answers with its signed licenses and a verdict on the key.
- From then on, the ordinary lookup returns the device’s licenses. No key needed.
Like the lookup, these calls use only public values (your organization ID, the client ID and the key), so they are safe to build into your software. Activation keys are included from the Indie plan.
- Device limit: how many devices a key may activate. LaaSio enforces it. It is separate from your SKU’s limits, which your software reads and enforces itself.
- Values: generated keys look like
XXXXX-XXXXX-XXXXX-XXXXX(100 bits, so they can’t be guessed). Uploaded keys may be any 6 to 64 letters and digits. Matching ignores case, spaces and dashes, soabcde-12345andABCDE12345are the same key. - Term: starts at the first activation and runs for the SKU’s duration. Later devices join that term.
- Status: unused, active, expired, locked, used (spent as a renewal key) or revoked.
Activate with a key
Section titled “Activate with a key”POST /api/v1/lookup takes the lookup’s fields in a JSON body, plus the key:
| Field | Required | Description |
|---|---|---|
org |
yes | Your organization ID. |
client |
yes | The device’s client ID, as in the lookup. |
key |
no | The key the customer typed. Without it, the call is a plain lookup. |
key_action |
no | Leave out to activate. renew uses the key as a renewal key. |
app |
no | As in the lookup. |
The answer is the lookup’s answer plus activation, LaaSio’s verdict on the key:
{ "data": [ "…signed license entries, as in the lookup…" ], "activation": { "result": "refused", "reason": "key_full", "message": "This key is already active on the maximum number of devices. Remove a device from it first." }}result |
Meaning |
|---|---|
activated |
The device is on the key now. The first activation starts the key’s term. |
moved |
The device was on another key and moved to this one. Its old slot freed up. |
already_active |
The device was already on this key. Nothing changed. |
renewed |
The renewal key extended the device’s key, for all of its devices. |
refused |
Nothing changed. reason and message say why. Show message to the customer. |
A refused key changes nothing, and the lookup still answers. If the application has a default SKU, the device can still get its trial.
A device that already has a license for the key’s application:
- an automatic trial is replaced by the key, and counts as a converted trial;
- an assignment that has ended is replaced;
- a running license you assigned is kept, and the key is refused with
already_licensed.
Refusal reasons
Section titled “Refusal reasons”reason |
Meaning |
|---|---|
key_invalid |
No such key, or it was revoked or used up as a renewal key. |
key_locked |
The key is locked. |
key_not_ready |
The key is not linked to a SKU yet. |
key_expired |
The key’s term has ended. |
key_full |
The key is on its maximum number of devices. The customer can remove one first. |
key_in_use |
A renewal key that was already used or activated. |
no_key_to_renew |
Renewing, but the device is not on a key the renewal key can renew. |
already_licensed |
The device already has a running license you assigned. |
client_invalid |
The client ID contains spaces. |
plan_required |
Your LaaSio plan doesn’t include activation keys. |
plan_limit |
Adding clients is paused on your plan (see Plans and limits). Devices already activated keep working. |
too_many_attempts |
Too many invalid keys from this IP address. Invalid keys are limited to 10 per IP address per hour. |
Renewal keys
Section titled “Renewal keys”To sell renewals in the same way, sell another key for the same application. The customer enters it with
key_action: "renew". An unused renewal key extends the key the device is on:
- the term grows by the renewal key’s SKU duration, counted from the current end (even if it has lapsed);
- the key takes the renewal key’s SKU and device limit;
- every device on the key is renewed at once, so the customer enters the renewal key on one device only;
- the renewal key is used up and can’t be activated anywhere.
Without key_action, a new key always means use this key for this device: the device moves to it, and the
rest of the household stays on the old key.
Deactivate a device
Section titled “Deactivate a device”POST /api/v1/deactivate with org, client and key in the body takes the device off its key, for example
before the customer replaces the computer. Its slot frees up. Only the device on the key with that client ID
can leave, and it works even when the key is locked.
The answer is {"deactivation": {"result", "reason", "message"}}, with result either deactivated or
refused. A refusal’s reason is key_invalid, not_on_key or too_many_attempts.
Examples
Section titled “Examples”Each example defines activateKey() and deactivateKey(), then activates the example key and prints the
verdict. Check licenses with the lookup examples as usual.
# Activate (add "key_action": "renew" to use it as a renewal key)curl -s -X POST 'https://laasio.functual.com/api/v1/lookup' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"org":"lzo_YOUR_ORG_ID","client":"PC-123","key":"ABCDE-12345-FGHIJ-KLMNO"}'
# Deactivate this device (frees its slot on the key)curl -s -X POST 'https://laasio.functual.com/api/v1/deactivate' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"org":"lzo_YOUR_ORG_ID","client":"PC-123","key":"ABCDE-12345-FGHIJ-KLMNO"}'// Node.js 18+ (built-in fetch), save as activate.mjsconst LAASIO_URL = "https://laasio.functual.com";const ORG_ID = "lzo_YOUR_ORG_ID";
async function post(path, body) { const response = await fetch(`${LAASIO_URL}${path}`, { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" }, body: JSON.stringify(body), }); if (!response.ok) throw new Error(`LaaSio ${response.status}`); return response.json();}
/** Send the key the customer typed, once. renew: use it to renew the key this device is on. */export async function activateKey(clientId, key, renew = false) { const body = { org: ORG_ID, client: clientId, key }; if (renew) body.key_action = "renew"; return (await post("/api/v1/lookup", body)).activation; // { result, reason, message }}
/** Take this device off its key, e.g. before the customer moves to a new computer. */export async function deactivateKey(clientId, key) { return (await post("/api/v1/deactivate", { org: ORG_ID, client: clientId, key })).deactivation;}
const activation = await activateKey("PC-123", "ABCDE-12345-FGHIJ-KLMNO");if (activation.result === "refused") console.log("Refused:", activation.reason, "-", activation.message);else console.log("OK:", activation.result); // activated, moved, already_active or renewed# pip install requestsimport requests
LAASIO_URL = "https://laasio.functual.com"ORG_ID = "lzo_YOUR_ORG_ID"
def post(path, body): response = requests.post(f"{LAASIO_URL}{path}", json=body, headers={"Accept": "application/json"}, timeout=10) response.raise_for_status() return response.json()
def activate_key(client_id, key, renew=False): """Send the key the customer typed, once. renew: use it to renew the key this device is on.""" body = {"org": ORG_ID, "client": client_id, "key": key} if renew: body["key_action"] = "renew" return post("/api/v1/lookup", body)["activation"] # {"result", "reason", "message"}
def deactivate_key(client_id, key): """Take this device off its key, e.g. before the customer moves to a new computer.""" return post("/api/v1/deactivate", {"org": ORG_ID, "client": client_id, "key": key})["deactivation"]
activation = activate_key("PC-123", "ABCDE-12345-FGHIJ-KLMNO")if activation["result"] == "refused": print("Refused:", activation["reason"], "-", activation["message"])else: print("OK:", activation["result"]) # activated, moved, already_active or renewed// .NET 6+using System.Net.Http.Json;using System.Text.Json.Nodes;
var activation = await Keys.ActivateAsync("PC-123", "ABCDE-12345-FGHIJ-KLMNO");if ((string?)activation["result"] == "refused") Console.WriteLine($"Refused: {activation["reason"]} - {activation["message"]}");else Console.WriteLine($"OK: {activation["result"]}"); // activated, moved, already_active or renewed
public static class Keys{ const string LaasioUrl = "https://laasio.functual.com"; const string OrgId = "lzo_YOUR_ORG_ID"; static readonly HttpClient Http = new();
static async Task<JsonObject> PostAsync(string path, object body) { var response = await Http.PostAsJsonAsync(LaasioUrl + path, body); response.EnsureSuccessStatusCode(); return (await response.Content.ReadFromJsonAsync<JsonObject>())!; }
/// <summary>Send the key the customer typed, once. renew: use it to renew the key this device is on.</summary> public static async Task<JsonObject> ActivateAsync(string clientId, string key, bool renew = false) { var body = new Dictionary<string, string> { ["org"] = OrgId, ["client"] = clientId, ["key"] = key }; if (renew) body["key_action"] = "renew"; return (await PostAsync("/api/v1/lookup", body))["activation"]!.AsObject(); }
/// <summary>Take this device off its key, e.g. before the customer moves to a new computer.</summary> public static async Task<JsonObject> DeactivateAsync(string clientId, string key) => (await PostAsync("/api/v1/deactivate", new { org = OrgId, client = clientId, key }))["deactivation"]!.AsObject();}package main
import ( "bytes" "encoding/json" "fmt" "net/http")
const ( laasioURL = "https://laasio.functual.com" orgID = "lzo_YOUR_ORG_ID")
// Verdict is LaaSio's answer to a key: Result is activated, moved, already_active, renewed,// deactivated or refused (then Reason and Message say why).type Verdict struct { Result string `json:"result"` Reason *string `json:"reason"` Message *string `json:"message"`}
func post(path string, body map[string]string, field string) (Verdict, error) { payload, _ := json.Marshal(body) req, _ := http.NewRequest("POST", laasioURL+path, bytes.NewReader(payload)) req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { return Verdict{}, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return Verdict{}, fmt.Errorf("LaaSio %d", resp.StatusCode) } var answer map[string]json.RawMessage if err := json.NewDecoder(resp.Body).Decode(&answer); err != nil { return Verdict{}, err } var v Verdict err = json.Unmarshal(answer[field], &v) return v, err}
// ActivateKey sends the key the customer typed, once. renew: use it to renew the key this device is on.func ActivateKey(clientID, key string, renew bool) (Verdict, error) { body := map[string]string{"org": orgID, "client": clientID, "key": key} if renew { body["key_action"] = "renew" } return post("/api/v1/lookup", body, "activation")}
// DeactivateKey takes this device off its key, e.g. before the customer moves to a new computer.func DeactivateKey(clientID, key string) (Verdict, error) { return post("/api/v1/deactivate", map[string]string{"org": orgID, "client": clientID, "key": key}, "deactivation")}
func main() { v, err := ActivateKey("PC-123", "ABCDE-12345-FGHIJ-KLMNO", false) if err != nil { panic(err) } if v.Result == "refused" { fmt.Println("Refused:", *v.Reason, "-", *v.Message) } else { fmt.Println("OK:", v.Result) }}<?php// PHP 8+ with the curl extensionconst LAASIO_URL = "https://laasio.functual.com";const ORG_ID = "lzo_YOUR_ORG_ID";
function laasioPost(string $path, array $body): array{ $ch = curl_init(LAASIO_URL . $path); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Accept: application/json", "Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode($body), CURLOPT_TIMEOUT => 10, ]); $response = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); if ($status !== 200) { throw new RuntimeException("LaaSio $status"); } return json_decode($response, true);}
/** Send the key the customer typed, once. $renew: use it to renew the key this device is on. */function activateKey(string $clientId, string $key, bool $renew = false): array{ $body = ["org" => ORG_ID, "client" => $clientId, "key" => $key]; if ($renew) { $body["key_action"] = "renew"; } return laasioPost("/api/v1/lookup", $body)["activation"]; // ["result", "reason", "message"]}
/** Take this device off its key, e.g. before the customer moves to a new computer. */function deactivateKey(string $clientId, string $key): array{ return laasioPost("/api/v1/deactivate", ["org" => ORG_ID, "client" => $clientId, "key" => $key])["deactivation"];}
$activation = activateKey("PC-123", "ABCDE-12345-FGHIJ-KLMNO");echo $activation["result"] === "refused" ? "Refused: {$activation["reason"]} - {$activation["message"]}\n" : "OK: {$activation["result"]}\n";Manage keys from your server
Section titled “Manage keys from your server”Your servers can manage keys with the provisioning key, for example to build a “My devices” page in your customer portal, or to revoke a key after a chargeback. Keys are addressed by their ID, shown in the address of the key’s page in the console. Devices are addressed by their client ID.
| Endpoint | Body | Effect |
|---|---|---|
POST /api/v1/activation-keys/{id}/devices/add |
client_id |
Puts a device on the key, under the same rules as activating from the software. Refused: 422 with reason. |
POST /api/v1/activation-keys/{id}/devices/remove |
client_id |
Takes a device off the key. Its slot frees up. |
POST /api/v1/activation-keys/{id}/renew |
end (optional) |
Extends an activated key by one SKU duration, or to a later end. Every device follows. |
POST /api/v1/activation-keys/{id}/lock |
No new activations, moves or renewals. Devices already on the key keep working. | |
POST /api/v1/activation-keys/{id}/unlock |
Undoes a lock. | |
POST /api/v1/activation-keys/{id}/revoke |
Revokes the key for good. Every device on it loses the license at once. |
Each answers with the key: its status, devices (how many devices are on it), max_devices, its SKU and
its term. An unknown key ID is a 404.
Example: removing a device from a key.
curl -X POST 'https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove' \ -H "X-API-Key: $LAASIO_PROVISIONING_KEY" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"client_id":"PC-123"}'// Node.js 18+ (built-in fetch)const response = await fetch("https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove", { method: "POST", headers: { "X-API-Key": process.env.LAASIO_PROVISIONING_KEY, "Accept": "application/json", "Content-Type": "application/json", }, body: JSON.stringify({"client_id":"PC-123"}),});if (!response.ok) throw new Error(`LaaSio ${response.status}: ${await response.text()}`);
const { data: key } = await response.json();console.log(key.status, key.devices, "of", key.max_devices);# pip install requestsimport osimport requests
response = requests.post( "https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove", headers={"X-API-Key": os.environ["LAASIO_PROVISIONING_KEY"], "Accept": "application/json"}, json={"client_id": "PC-123"}, timeout=10,)response.raise_for_status()
key = response.json()["data"]print(key["status"], key["devices"], "of", key["max_devices"])// .NET 6+using System.Net.Http.Json;
using var http = new HttpClient();http.DefaultRequestHeaders.Add("X-API-Key", Environment.GetEnvironmentVariable("LAASIO_PROVISIONING_KEY"));http.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await http.PostAsJsonAsync("https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove", new { client_id = "PC-123" });var body = await response.Content.ReadAsStringAsync();if (!response.IsSuccessStatusCode) throw new Exception($"LaaSio {(int)response.StatusCode}: {body}");
Console.WriteLine(body);package main
import ( "bytes" "encoding/json" "fmt" "io" "net/http" "os")
func main() { payload, _ := json.Marshal(map[string]string{"client_id": "PC-123"})
req, _ := http.NewRequest("POST", "https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove", bytes.NewReader(payload)) req.Header.Set("X-API-Key", os.Getenv("LAASIO_PROVISIONING_KEY")) req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body) if resp.StatusCode >= 300 { panic(fmt.Sprintf("LaaSio %d: %s", resp.StatusCode, body)) } fmt.Println(string(body))}<?php// PHP 8+ with the curl extension$ch = curl_init("https://laasio.functual.com/api/v1/activation-keys/KEY_ID/devices/remove");curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "X-API-Key: " . getenv("LAASIO_PROVISIONING_KEY"), "Accept: application/json", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode(["client_id" => "PC-123"]),]);$body = curl_exec($ch);$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);if ($status >= 300) { throw new RuntimeException("LaaSio $status: $body");}
$key = json_decode($body, true)["data"];echo $key["status"], " ", $key["devices"], " of ", $key["max_devices"], "\n";