Skip to content

Noctix for vendors

This is the documentation for vendors: software companies that license their products with Noctix. It covers installing an SDK, the first valid license check, the concepts behind it, and the Management API for your own servers.

Pre-release. The SDKs are alpha versions (0.x.y-alpha.n) and not published yet. The quickstart below runs against the real Management API and Client API; there is no hosted service yet, so you run the service yourself (see scripts/quickstart-e2e.sh in the repository). Names of packages and hosts are provisional.

Page What it is for
This page Quickstart: from installation to the first valid check
Concepts Products, plans, entitlements, licenses, activations, test and live, offline tolerance
Vendor guide How to get real protection out of a license check
Import from KeyAuth Move keys, subscriptions and users from KeyAuth, with new keys
Discord roles Give Discord roles to customers with a license, and take them back when it ends
Rust SDK Reference for the Rust core SDK
C SDK Stable C interface of the core, prebuilt libraries, CMake
C++ SDK Header-only C++17 wrapper with RAII and exceptions
C# SDK .NET 8 wrapper with async calls and exceptions, one NuGet package
Python SDK Python 3.10+ wrapper without dependencies, one wheel per platform
Java SDK Java 8+ wrapper over JNA, one JAR for all platforms
Kotlin SDK Kotlin calls on top of the Java SDK, for the JVM and as an Android package (Android Keystore, Play Integrity)
Swift SDK Swift package for iOS and macOS over the C interface (Keychain, Secure Enclave), partly untested
Node backend SDK Verify tokens and webhooks, call the Management API from your server
MCP server Let a coding agent integrate the SDK and answer questions about your licenses
Assets Ship models, content packs and other files outside releases, per license
Modules Run WebAssembly modules you signed in a sandbox, to change logic without a release
Crash reports Send crashes, unexpected exits and error reports from your app
Remote actions Send named actions with checked parameters to one running app
Example updater Install, check and roll back an update on Linux, Windows and macOS, and report the outcome
Publish from CI Publish releases from GitHub Actions, GitLab CI or any pipeline with release-tool publish
Buy button Sell a plan from your website: embed the button, the checkout and its events
Download button Hand out release files from your website against a license key: embed the button and its events
Key vault button Let customers find their license keys from your website: allow hosts and embed the button
Automations Act on events without your own server: suspend, flag or tag licenses on chargebacks, resets and more
Webhooks v1 Format and signature of the webhooks sent to your endpoints
Management API Endpoint reference, generated from the OpenAPI description
Device identification Exactly which hardware features the SDK reads
Security information Secure setup, updates, support period, removal (Cyber Resilience Act)
Privacy texts Text modules for your privacy notice and license terms, and the consent dialog for crash reports
Data export and switching Format of the data export, and how to move to another provider or your own infrastructure (EU Data Act)
Data location Where the servers are, who takes part in running the service, and how data is protected against access from outside the EU
Protocol v1 The normative specification for SDK authors

Quickstart

Goal: a fresh developer gets from nothing to the first valid check in under 15 minutes. The whole flow uses the test environment, so nothing you do here touches real customers.

1. Set up a product (about 5 minutes)

In the dashboard, or through the Management API with a test API key (mk_test_...):

  1. Create a product. Note its product ID (prod_...). It is public and goes into your app.
  2. In the product's test environment, copy the public key (k4.public....). It is public too. Keep a second key slot free for key rotation.
  3. Create a plan with an entitlement pro and a device limit of 1.
  4. Create a license from the plan. Copy its license key.

With the Management API, the same steps look like this. MANAGEMENT_URL is your Management API base URL and MANAGEMENT_KEY a test API key with the products, entitlements, plans and licenses write scopes:

auth=(-H "authorization: Bearer $MANAGEMENT_KEY" -H "content-type: application/json")
curl -s "${auth[@]}" "$MANAGEMENT_URL/v1/products" -d '{"name": "My app"}'
# -> {"id": "prod_...", ...}
curl -s "${auth[@]}" "$MANAGEMENT_URL/v1/products/prod_.../keys"
# -> the key with "status": "active" holds the public key
curl -s "${auth[@]}" "$MANAGEMENT_URL/v1/entitlements" -d '{"product_id": "prod_...", "code": "pro", "label": "Pro"}'
curl -s "${auth[@]}" "$MANAGEMENT_URL/v1/plans" \
  -d '{"product_id": "prod_...", "name": "Pro", "term_model": "perpetual", "device_limit": 1, "entitlements": {"pro": true}}'
# -> {"id": "plan_...", ...}
curl -s "${auth[@]}" "$MANAGEMENT_URL/v1/licenses" -d '{"plan_id": "plan_..."}'
# -> {"data": [{"id": "lic_...", "key": "...", ...}]}; later from GET /v1/licenses/lic_.../key

Nothing secret goes into your app. There is no app secret in Noctix.

2. Check the license in your app (about 5 minutes)

Pick your language. Both flows have the same shape: check locally at every start, activate with the user's key when nothing is stored yet, then renew.

Rust

The Rust SDK is crates/sdk-core. Until it is published, depend on it by path or git:

[dependencies]
sdk-core = { git = "https://github.com/Sparx-Foundation/Noctix", package = "sdk-core" }

The complete, compiled example is crates/sdk-core/examples/quickstart.rs:

//! Quickstart: check the license at start, activate if needed.
//!
//! ```sh
//! PRODUCT_ID=prod_... PUBLIC_KEY=k4.public.... API_BASE=https://... \
//!   LICENSE_KEY=XXXXX-... cargo run -p sdk-core --example quickstart
//! ```
//!
//! `LICENSE_STORE=memory` keeps the state in memory instead of the
//! operating system's secure storage (CI, headless Linux).

use std::env::var;

use sdk_core::store::MemoryStore;
use sdk_core::transport::HttpTransport;
use sdk_core::{Client, Config, Environment, Error};

fn main() -> Result<(), Error> {
    let required = |name: &str| var(name).map_err(|_| Error::Config(format!("{name} is not set")));
    let config = Config {
        product_id: required("PRODUCT_ID")?,
        environment: if var("ENVIRONMENT").as_deref() == Ok("live") {
            Environment::Live
        } else {
            Environment::Test
        },
        public_keys: vec![required("PUBLIC_KEY")?],
        api_base: required("API_BASE")?,
        app_version: "1.0.0".into(),
    };
    let client = if var("LICENSE_STORE").as_deref() == Ok("memory") {
        Client::with_parts(
            config,
            Box::new(MemoryStore::new()),
            Box::new(HttpTransport::default()),
        )?
    } else {
        os_client(config)?
    };

    // 1. At every start: check locally, no network needed.
    let status = match client.check() {
        Ok(status) => status,
        // 2. First start: activate with the key the user entered.
        Err(Error::NotActivated) => client.activate(&required("LICENSE_KEY")?, None)?,
        Err(e) => return Err(e),
    };
    println!("license {} is {:?}", status.claims.lid, status.state);

    // 3. Gate features by entitlement.
    for (code, value) in &status.claims.ent.0 {
        println!("entitlement {code}: {value:?}");
    }

    // 4. Renew; offline the stored token keeps working until its offline end.
    match client.validate() {
        Ok(s) => println!("renewed, valid until {}", s.claims.exp.unix()),
        Err(Error::Unreachable(reason)) => println!("offline ({reason}), using the stored token"),
        Err(e) => return Err(e),
    }
    Ok(())
}

#[cfg(feature = "os-store")]
fn os_client(config: Config) -> Result<Client, Error> {
    Client::new(config)
}

#[cfg(not(feature = "os-store"))]
fn os_client(_: Config) -> Result<Client, Error> {
    Err(Error::Config(
        "built without os-store; set LICENSE_STORE=memory".into(),
    ))
}

Run it with your product ID, public key, Client API base URL and the license key from step 1:

PRODUCT_ID=prod_... PUBLIC_KEY=k4.public.... API_BASE=https://... LICENSE_KEY=... \
  cargo run -p sdk-core --example quickstart

On the first run it activates and prints the license ID and the entitlements. On the second run it prints the same without a network call, because the stored token is checked locally.

Node (your backend)

Use the Node SDK when your app has its own server and you want the server to refuse unlicensed requests. Your app sends the license token it stored; the backend verifies it with the product's public key. See the Node backend SDK for installation.

import { createServer } from "node:http";
import { Verifier, VerifyError } from "license-sdk-node";

const verifier = new Verifier({
  productId: process.env.PRODUCT_ID!, // prod_..., public
  environment: process.env.ENVIRONMENT === "live" ? "live" : "test",
  keys: [process.env.LICENSE_PUBLIC_KEY!], // k4.public...., from the dashboard
});

// Your app sends the license token it stored, for example in a header.
createServer((req, res) => {
  res.setHeader("content-type", "application/json");
  try {
    const { state, claims } = verifier.verifyLicense(String(req.headers["x-license-token"] ?? ""));
    if (claims.ent["pro"] !== true) {
      res.statusCode = 403;
      res.end(JSON.stringify({ error: "pro_required" }));
      return;
    }
    res.end(JSON.stringify({ ok: true, state })); // state: "fresh" or "grace"
  } catch (e) {
    if (!(e instanceof VerifyError)) throw e;
    res.statusCode = 401;
    res.end(JSON.stringify({ error: e.code }));
  }
}).listen(Number(process.env.PORT ?? 3000));

3. Try the failure cases (about 5 minutes)

A license check that only ever passes proves little. In the dashboard, then run your app again after each change:

Change What your app should do
Suspend the license The next renewal fails with license_suspended; the SDK deletes the stored token and your app asks for a key
Unplug the network validate fails with server_unreachable; the app keeps running until the offline end (7 days by default)
Reset the activation activation_not_found on the next renewal; activate again
Raise the product's minimum version above app_version version_outdated; show an update notice

All error codes are the same in every SDK. The full list is in protocol section 7.

4. Go live

  1. Repeat step 1 in the live environment. Product ID stays the same, the public key and the license keys are different.
  2. Switch Environment::Live or environment: "live" and the live public key. A test token is refused in live and the other way round (token_mismatch).
  3. Read the vendor guide before you ship. It decides whether the check protects anything.
  4. Add the privacy text modules to your privacy notice and license terms.

Getting help

  • Security issues: see SECURITY.md.
  • Anything else about these pages: open an issue in the repository.