Check licenses from your app
Your software asks one question: what is this client licensed for? It sends only public values, so it never holds a secret that could be extracted.
The request
Section titled “The request”GET https://laasio.functual.com/api/v1/lookup?org=<organization id>&client=<client id>[&app=<application id>]Accept: application/json| Parameter | Required | Description |
|---|---|---|
org |
yes | Your public organization ID (lzo_…), from LaaSio → Settings. |
client |
yes | The client’s ID: your own identifier for this install, machine or customer. |
app |
no | An application ID. Returns only that application’s licenses and enables auto-provisioning. |
From a terminal:
curl -H 'Accept: application/json' 'https://laasio.functual.com/api/v1/lookup?org=lzo_YOUR_ORG_ID&client=PC-123'The same lookup as a POST with a JSON body can also carry an activation key and
client attributes: data your software reports about itself, such as its version.
The answer
Section titled “The answer”One entry per license granted by each SKU the client holds:
{ "data": [ { "clientId": "PC-123", "name": "av-realtime", "displayName": "Real-time Protection", "type": "Paid", "start": "2026-10-28T00:00:00Z", "end": "2027-10-29T00:00:00Z", "limits": { "devices": 25, "scans_per_day": null }, "issued": "2026-10-28T14:32:05Z", "keyVersion": 1, "key": "<base64 Ed25519 signature>"} ] }| Field | Meaning |
|---|---|
clientId |
The client the entry was issued for. It is signed, so an entry can’t be moved to another client. |
name, displayName |
The license’s stable name (map it to a feature) and its label. |
type |
Free, Trial, Paid, NFR, Internal or Educational. Automatic trials report Paid licenses as Trial. |
start, end |
The term, in UTC. end: null means perpetual. |
limits |
Limits that apply to this license, by name. null = not set by the SKU (your software decides, usually no limit). A missing key means the limit doesn’t apply. Always an object, {} when none apply. |
issued |
When this answer was produced. Use it to reject stale cached copies. |
keyVersion, key |
The signing key’s version and the Ed25519 signature. See Verify signatures. |
Rules for your software
Section titled “Rules for your software”- Verify every entry before trusting it, and check that
clientIdmatches the client you asked about. - Compare
startandendwith the current time yourself. The answer includes expired and not-yet-started terms, so you can tell “expired” from “never licensed” and show the right message. {"data": []}means not licensed. Unknown organizations, applications and clients get the same empty answer, so the endpoint can’t be used to discover which IDs exist.- Keep working when LaaSio can’t be reached. Save the last verified answer and fall back to it; see below.
When LaaSio can’t be reached
Section titled “When LaaSio can’t be reached”A network outage, a firewall or an offline machine shouldn’t lock a paying customer out. Because every entry is signed, a saved answer is just as trustworthy as a fresh one, so your software can keep running from it.
- Save every verified answer, for example in a file in your app’s data folder. No encryption is needed: the signature covers every field, so an edited file fails verification.
- Fall back only when the lookup fails: a network error, a timeout, a
5xxor a429. A200is always the current truth, even when it says the client is no longer licensed, so replace the saved answer with it. - Verify the saved answer again when you load it, and check
clientId,startandendagainst the current time exactly as you would for a fresh answer. A term that has ended while offline has still ended. - Decide how long an answer may be used offline, based on its
issuedtime: for example 7 days for a subscription product, 30 or more for software that often runs without a connection. Past that, ask the user to connect. - Distrust a clock that runs backwards. If the current time is earlier than the saved answer’s
issued, the computer’s clock was probably set back to stretch the offline period. Ask the user to connect.
Lookups that keep failing are worth logging, so you can tell a customer’s firewall from an outage.
This example is the one from Verify signatures with these rules added. It is tested against LaaSio both online and with LaaSio unreachable.
// Node.js 18+, save as licenses.mjs. The verify example, plus a saved answer for when LaaSio can't be reached.import { createPublicKey, verify } from "node:crypto";import { readFileSync, writeFileSync } from "node:fs";
const LAASIO_URL = "https://laasio.functual.com";const ORG_ID = "lzo_YOUR_ORG_ID";const SAVED_ANSWER = "laasio-answer.json"; // the last answer, saved after every lookup; use one file per clientconst MAX_OFFLINE_MS = 7 * 24 * 60 * 60 * 1000; // how long a saved answer may be used without reaching LaaSio: your choiceconst PUBLIC_KEY = createPublicKey({ key: Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), Buffer.from("YOUR_PUBLIC_KEY_BASE64", "base64")]), format: "der", type: "spki",});
// Keys sorted at every level; JSON.stringify adds no whitespace and leaves "/" and Unicode as-isfunction canonical(value) { if (Array.isArray(value)) return value.map(canonical); if (value && typeof value === "object") { return Object.fromEntries(Object.keys(value).sort().map((k) => [k, canonical(value[k])])); } return value;}
/** The lookup answer as text, or null when LaaSio can't be reached (network error, timeout, 5xx, 429). */async function fetchAnswer(clientId) { const url = `${LAASIO_URL}/api/v1/lookup?${new URLSearchParams({ org: ORG_ID, client: clientId })}`; let response; try { response = await fetch(url, { headers: { Accept: "application/json" }, signal: AbortSignal.timeout(10_000) }); } catch { return null; } if (response.status === 429 || response.status >= 500) return null; if (!response.ok) throw new Error(`LaaSio ${response.status}`); // a bad request: fix it, don't fall back return response.text();}
/** The entries of an answer whose signature is valid for this client. */function verified(answer, clientId) { return JSON.parse(answer).data.filter(({ key, ...signed }) => signed.clientId === clientId && verify(null, Buffer.from(JSON.stringify(canonical(signed))), PUBLIC_KEY, Buffer.from(key, "base64")));}
/** The client's verified licenses from LaaSio, or from the saved answer when LaaSio can't be reached. */export async function getLicenses(clientId, now = new Date()) { const fresh = await fetchAnswer(clientId); if (fresh !== null) { writeFileSync(SAVED_ANSWER, fresh); // a 200 is the current truth, even "not licensed" return { source: "LaaSio", licenses: verified(fresh, clientId) }; }
let saved; try { saved = readFileSync(SAVED_ANSWER, "utf8"); } catch { throw new Error("LaaSio can't be reached and there is no saved answer"); } const licenses = verified(saved, clientId); // an edited file fails verification for (const { issued } of licenses) { const age = now - new Date(issued); if (age < 0) throw new Error("The clock is earlier than the saved answer: connect to LaaSio"); if (age > MAX_OFFLINE_MS) throw new Error("The saved answer is too old: connect to LaaSio"); } return { source: "saved answer", licenses };}
/** A license is active from its start until its end (end null = never expires). */export function isActive(license, now = new Date()) { return new Date(license.start) <= now && (license.end === null || now < new Date(license.end));}
const { source, licenses } = await getLicenses("PC-123");console.log(`From ${source}:`);for (const license of licenses.filter((l) => isActive(l))) { console.log(license.name, license.type, license.limits);}# pip install requests cryptography# The verify example, plus a saved answer for when LaaSio can't be reached.import base64import jsonfrom datetime import datetime, timedelta, timezone
import requestsfrom cryptography.exceptions import InvalidSignaturefrom cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
LAASIO_URL = "https://laasio.functual.com"ORG_ID = "lzo_YOUR_ORG_ID"SAVED_ANSWER = "laasio-answer.json" # the last answer, saved after every lookup; use one file per clientMAX_OFFLINE = timedelta(days=7) # how long a saved answer may be used without reaching LaaSio: your choicePUBLIC_KEY = Ed25519PublicKey.from_public_bytes(base64.b64decode("YOUR_PUBLIC_KEY_BASE64"))
def canonical(entry): # Keys sorted at every level, no whitespace, "/" and Unicode unescaped return json.dumps(entry, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
def parse_time(value): return datetime.fromisoformat(value.replace("Z", "+00:00"))
def fetch_answer(client_id): """The lookup answer as text, or None when LaaSio can't be reached (network error, timeout, 5xx, 429).""" try: response = requests.get( f"{LAASIO_URL}/api/v1/lookup", params={"org": ORG_ID, "client": client_id}, headers={"Accept": "application/json"}, timeout=10, ) except requests.RequestException: return None if response.status_code == 429 or response.status_code >= 500: return None response.raise_for_status() # a bad request: fix it, don't fall back return response.text
def verified(answer, client_id): """The entries of an answer whose signature is valid for this client.""" licenses = [] for entry in json.loads(answer)["data"]: signed = {k: v for k, v in entry.items() if k != "key"} try: PUBLIC_KEY.verify(base64.b64decode(entry["key"]), canonical(signed)) except InvalidSignature: continue if entry["clientId"] == client_id: licenses.append(entry) return licenses
def get_licenses(client_id): """The client's verified licenses from LaaSio, or from the saved answer when LaaSio can't be reached.""" fresh = fetch_answer(client_id) if fresh is not None: with open(SAVED_ANSWER, "w", encoding="utf-8") as file: # a 200 is the current truth, even "not licensed" file.write(fresh) return "LaaSio", verified(fresh, client_id)
try: with open(SAVED_ANSWER, encoding="utf-8") as file: saved = file.read() except FileNotFoundError: raise RuntimeError("LaaSio can't be reached and there is no saved answer") licenses = verified(saved, client_id) # an edited file fails verification now = datetime.now(timezone.utc) for license in licenses: age = now - parse_time(license["issued"]) if age < timedelta(0): raise RuntimeError("The clock is earlier than the saved answer: connect to LaaSio") if age > MAX_OFFLINE: raise RuntimeError("The saved answer is too old: connect to LaaSio") return "saved answer", licenses
def is_active(license): """A license is active from its start until its end (end None = never expires).""" now = datetime.now(timezone.utc) end = license["end"] and parse_time(license["end"]) return parse_time(license["start"]) <= now and (end is None or now < end)
source, licenses = get_licenses("PC-123")print(f"From {source}:")for license in licenses: if is_active(license): print(license["name"], license["type"], license["limits"])// .NET 8+ with NSec for Ed25519: dotnet add package NSec.Cryptography// (on .NET 8 add --version 24.4.0; newer NSec versions need .NET 9+)// The verify example, plus a saved answer for when LaaSio can't be reached.using System.Text;using System.Text.Encodings.Web;using System.Text.Json;using System.Text.Json.Nodes;using NSec.Cryptography;
var (source, licenses) = await Laasio.GetLicensesAsync("PC-123");Console.WriteLine($"From {source}:");foreach (var license in licenses){ if (Laasio.IsActive(license)) Console.WriteLine($"{license["name"]} {license["type"]} {license["limits"]!.ToJsonString()}");}
public static class Laasio{ const string LaasioUrl = "https://laasio.functual.com"; const string OrgId = "lzo_YOUR_ORG_ID"; const string SavedAnswer = "laasio-answer.json"; // the last answer, saved after every lookup; use one file per client static readonly TimeSpan MaxOffline = TimeSpan.FromDays(7); // how long a saved answer may be used without reaching LaaSio: your choice
static readonly PublicKey Key = PublicKey.Import(SignatureAlgorithm.Ed25519, Convert.FromBase64String("YOUR_PUBLIC_KEY_BASE64"), KeyBlobFormat.RawPublicKey); static readonly HttpClient Http = new() { Timeout = TimeSpan.FromSeconds(10) }; // No whitespace, and "/" and Unicode left unescaped static readonly JsonSerializerOptions Canonical = new() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
/// <summary>The client's verified licenses from LaaSio, or from the saved answer when LaaSio can't be reached.</summary> public static async Task<(string Source, List<JsonObject> Licenses)> GetLicensesAsync(string clientId) { var fresh = await FetchAnswerAsync(clientId); if (fresh is not null) { await File.WriteAllTextAsync(SavedAnswer, fresh); // a 200 is the current truth, even "not licensed" return ("LaaSio", Verified(fresh, clientId)); }
if (!File.Exists(SavedAnswer)) throw new Exception("LaaSio can't be reached and there is no saved answer"); var licenses = Verified(await File.ReadAllTextAsync(SavedAnswer), clientId); // an edited file fails verification foreach (var license in licenses) { var age = DateTimeOffset.UtcNow - DateTimeOffset.Parse((string)license["issued"]!); if (age < TimeSpan.Zero) throw new Exception("The clock is earlier than the saved answer: connect to LaaSio"); if (age > MaxOffline) throw new Exception("The saved answer is too old: connect to LaaSio"); } return ("saved answer", licenses); }
/// <summary>A license is active from its start until its end (end null = never expires).</summary> public static bool IsActive(JsonObject license) { var now = DateTimeOffset.UtcNow; var start = DateTimeOffset.Parse((string)license["start"]!); var end = license["end"] is null ? (DateTimeOffset?)null : DateTimeOffset.Parse((string)license["end"]!); return start <= now && (end is null || now < end); }
// The lookup answer as text, or null when LaaSio can't be reached (network error, timeout, 5xx, 429) static async Task<string?> FetchAnswerAsync(string clientId) { var url = $"{LaasioUrl}/api/v1/lookup?org={Uri.EscapeDataString(OrgId)}&client={Uri.EscapeDataString(clientId)}"; HttpResponseMessage response; try { response = await Http.SendAsync(new HttpRequestMessage(HttpMethod.Get, url) { Headers = { { "Accept", "application/json" } } }); } catch (Exception e) when (e is HttpRequestException or TaskCanceledException) { return null; } var status = (int)response.StatusCode; if (status == 429 || status >= 500) return null; response.EnsureSuccessStatusCode(); // a bad request: fix it, don't fall back return await response.Content.ReadAsStringAsync(); }
// The entries of an answer whose signature is valid for this client static List<JsonObject> Verified(string answer, string clientId) { var licenses = new List<JsonObject>(); foreach (var node in JsonNode.Parse(answer)!["data"]!.AsArray()) { var entry = node!.AsObject(); var signature = Convert.FromBase64String((string)entry["key"]!); var signed = Encoding.UTF8.GetBytes(Sorted(entry, skip: "key")!.ToJsonString(Canonical));
if ((string?)entry["clientId"] == clientId && SignatureAlgorithm.Ed25519.Verify(Key, signed, signature)) licenses.Add(entry); } return licenses; }
// Copy of a JSON value with object keys sorted (ordinal) at every level static JsonNode? Sorted(JsonNode? node, string? skip = null) => node switch { JsonObject o => new JsonObject(o.Where(p => p.Key != skip).OrderBy(p => p.Key, StringComparer.Ordinal) .Select(p => KeyValuePair.Create(p.Key, Sorted(p.Value)))), JsonArray a => new JsonArray(a.Select(n => Sorted(n)).ToArray()), _ => node?.DeepClone(), };}// The verify example, plus a saved answer for when LaaSio can't be reached.package main
import ( "bytes" "crypto/ed25519" "encoding/base64" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" "os" "time")
const ( laasioURL = "https://laasio.functual.com" orgID = "lzo_YOUR_ORG_ID" publicKey = "YOUR_PUBLIC_KEY_BASE64" savedAnswer = "laasio-answer.json" // the last answer, saved after every lookup; use one file per client maxOffline = 7 * 24 * time.Hour // how long a saved answer may be used without reaching LaaSio: your choice)
type License struct { ClientID string `json:"clientId"` Name string `json:"name"` DisplayName string `json:"displayName"` Type string `json:"type"` Start time.Time `json:"start"` End *time.Time `json:"end"` // nil = never expires Limits map[string]*int64 `json:"limits"` // nil = not set Issued time.Time `json:"issued"`}
// Active reports whether the license is in force: from its start until its end.func (l License) Active(now time.Time) bool { return !now.Before(l.Start) && (l.End == nil || now.Before(*l.End))}
// canonical encodes an entry the way it is signed. Go sorts map keys; HTML escaping is turned off// so "<", ">" and "&" stay as-is, and the encoder's trailing newline is dropped.func canonical(entry map[string]any) []byte { var buf bytes.Buffer enc := json.NewEncoder(&buf) enc.SetEscapeHTML(false) enc.Encode(entry) return bytes.TrimRight(buf.Bytes(), "\n")}
// fetchAnswer returns the lookup answer, or nil (and no error) when LaaSio can't be reached:// a network error, a timeout, a 5xx or a 429.func fetchAnswer(clientID string) ([]byte, error) { req, _ := http.NewRequest("GET", laasioURL+"/api/v1/lookup?"+url.Values{"org": {orgID}, "client": {clientID}}.Encode(), nil) req.Header.Set("Accept", "application/json") resp, err := (&http.Client{Timeout: 10 * time.Second}).Do(req) if err != nil { return nil, nil } defer resp.Body.Close() if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode >= 500 { return nil, nil } if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("LaaSio %d", resp.StatusCode) // a bad request: fix it, don't fall back } return io.ReadAll(resp.Body)}
// verified returns the entries of an answer whose signature is valid for this client.func verified(answer []byte, clientID string) ([]License, error) { pub, err := base64.StdEncoding.DecodeString(publicKey) if err != nil { return nil, err } var body struct { Data []json.RawMessage `json:"data"` } if err := json.Unmarshal(answer, &body); err != nil { return nil, err }
var licenses []License for _, raw := range body.Data { var entry map[string]any dec := json.NewDecoder(bytes.NewReader(raw)) dec.UseNumber() // keep numbers exactly as sent if err := dec.Decode(&entry); err != nil { continue } key, _ := entry["key"].(string) signature, err := base64.StdEncoding.DecodeString(key) delete(entry, "key") if err != nil || !ed25519.Verify(pub, canonical(entry), signature) { continue }
var license License if json.Unmarshal(raw, &license) == nil && license.ClientID == clientID { licenses = append(licenses, license) } } return licenses, nil}
// GetLicenses returns the client's verified licenses from LaaSio, or from the saved answer when// LaaSio can't be reached, and where they came from.func GetLicenses(clientID string) (string, []License, error) { fresh, err := fetchAnswer(clientID) if err != nil { return "", nil, err } if fresh != nil { // A 200 is the current truth, even "not licensed" if err := os.WriteFile(savedAnswer, fresh, 0o600); err != nil { return "", nil, err } licenses, err := verified(fresh, clientID) return "LaaSio", licenses, err }
saved, err := os.ReadFile(savedAnswer) if err != nil { return "", nil, errors.New("LaaSio can't be reached and there is no saved answer") } licenses, err := verified(saved, clientID) // an edited file fails verification if err != nil { return "", nil, err } for _, l := range licenses { age := time.Since(l.Issued) if age < 0 { return "", nil, errors.New("the clock is earlier than the saved answer: connect to LaaSio") } if age > maxOffline { return "", nil, errors.New("the saved answer is too old: connect to LaaSio") } } return "saved answer", licenses, nil}
func main() { source, licenses, err := GetLicenses("PC-123") if err != nil { panic(err) } fmt.Printf("From %s:\n", source) for _, l := range licenses { if !l.Active(time.Now()) { continue } devices := "not set" if d := l.Limits["devices"]; d != nil { devices = fmt.Sprint(*d) } fmt.Println(l.Name, l.Type, "devices:", devices) }}<?php// PHP 8+ (sodium is built in). The verify example, plus a saved answer for when LaaSio can't be reached.const LAASIO_URL = "https://laasio.functual.com";const ORG_ID = "lzo_YOUR_ORG_ID";const PUBLIC_KEY = "YOUR_PUBLIC_KEY_BASE64";const SAVED_ANSWER = __DIR__ . "/laasio-answer.json"; // the last answer, saved after every lookup; use one file per clientconst MAX_OFFLINE = 7 * 24 * 3600; // seconds; how long a saved answer may be used without reaching LaaSio: your choice
/** Copy of an entry with keys sorted at every level. */function canonical(array $value): array{ ksort($value, SORT_STRING); return array_map(fn ($v) => is_array($v) ? canonical($v) : $v, $value);}
/** The lookup answer as text, or null when LaaSio can't be reached (network error, timeout, 5xx, 429). */function fetchAnswer(string $clientId): ?string{ $url = LAASIO_URL . "/api/v1/lookup?" . http_build_query(["org" => ORG_ID, "client" => $clientId]); $body = @file_get_contents($url, false, stream_context_create([ "http" => ["header" => "Accept: application/json\r\n", "timeout" => 10, "ignore_errors" => true], ])); $status = isset($http_response_header[0]) ? (int) explode(" ", $http_response_header[0])[1] : 0; if ($body === false || $status === 0 || $status === 429 || $status >= 500) { return null; } if ($status !== 200) { throw new RuntimeException("LaaSio $status"); // a bad request: fix it, don't fall back } return $body;}
/** The entries of an answer whose signature is valid for this client. */function verified(string $answer, string $clientId): array{ $licenses = []; foreach (json_decode($answer, true)["data"] as $entry) { $signature = base64_decode($entry["key"]); unset($entry["key"]); // json_decode(..., true) turns an empty limits object into []; restore the object that was signed if ($entry["limits"] === []) { $entry["limits"] = new stdClass(); } $signed = json_encode(canonical($entry), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($entry["clientId"] === $clientId && sodium_crypto_sign_verify_detached($signature, $signed, base64_decode(PUBLIC_KEY))) { $licenses[] = $entry; } } return $licenses;}
/** The client's verified licenses from LaaSio, or from the saved answer when LaaSio can't be reached: [source, licenses]. */function getLicenses(string $clientId): array{ $fresh = fetchAnswer($clientId); if ($fresh !== null) { file_put_contents(SAVED_ANSWER, $fresh); // a 200 is the current truth, even "not licensed" return ["LaaSio", verified($fresh, $clientId)]; }
$saved = @file_get_contents(SAVED_ANSWER); if ($saved === false) { throw new RuntimeException("LaaSio can't be reached and there is no saved answer"); } $licenses = verified($saved, $clientId); // an edited file fails verification foreach ($licenses as $license) { $age = time() - strtotime($license["issued"]); if ($age < 0) { throw new RuntimeException("The clock is earlier than the saved answer: connect to LaaSio"); } if ($age > MAX_OFFLINE) { throw new RuntimeException("The saved answer is too old: connect to LaaSio"); } } return ["saved answer", $licenses];}
/** A license is active from its start until its end (end null = never expires). */function isActive(array $license): bool{ $now = new DateTimeImmutable(); return new DateTimeImmutable($license["start"]) <= $now && ($license["end"] === null || $now < new DateTimeImmutable($license["end"]));}
[$source, $licenses] = getLicenses("PC-123");echo "From $source:\n";foreach ($licenses as $license) { if (isActive($license)) { echo $license["name"], " ", $license["type"], " ", json_encode($license["limits"]), "\n"; }}Errors and limits
Section titled “Errors and limits”| Status | When | What to do |
|---|---|---|
200 |
Always for a valid request, licensed or not | Read data. |
422 |
org or client missing or too long |
Fix the request. |
429 |
More than 60 lookups a minute from one IP address | Back off and retry later; use your saved answer meanwhile. |
Lookups are never blocked or slowed because of your plan: going over your plan’s limits doesn’t affect your customers. See Plans and limits.