### Clone and Run Next.js Starter Source: https://keymint.dev/docs/templates/nextjs-saas-starter Clone the repository, install dependencies, set up environment variables, and run the development server to get started with the Next.js SaaS License Starter. ```bash git clone https://github.com/keymint-dev/keymint-nextjs-starter.git cd keymint-nextjs-starter npm install cp .env.example .env.local npm run dev ``` -------------------------------- ### Install Keymint Go SDK Source: https://keymint.dev/docs/sdks/go Install the Keymint Go SDK using the go get command. ```bash go get github.com/keymint-dev/keymint-go ``` -------------------------------- ### Install Keymint Python SDK Source: https://keymint.dev/docs/sdks/python Install the official Python SDK using pip. ```bash pip install keymint ``` -------------------------------- ### Install Keymint Client Library (Node.js) Source: https://keymint.dev/docs/introduction/getting-started Install the Keymint client SDK for Node.js environments using npm. ```bash npm install keymint ``` -------------------------------- ### Install Keymint C# SDK Source: https://keymint.dev/docs/sdks/csharp Install the Keymint SDK package using the .NET CLI. Supports .NET Standard 2.0+. ```bash dotnet add package Keymint ``` -------------------------------- ### Install Keymint SDK and Dependencies Source: https://keymint.dev/docs/guides/electron-licensing Install the necessary npm packages for license management and hardware fingerprinting in your Electron project. ```bash npm install keymint node-machine-id ``` -------------------------------- ### Clone and Run PyQt License Starter Source: https://keymint.dev/docs/templates/pyqt-license-starter Clone the repository, install dependencies, configure environment variables, and run the main application script. ```bash git clone https://github.com/keymint-dev/keymint-pyqt-starter.git cd keymint-pyqt-starter pip install -r requirements.txt cp .env.example .env python main.py ``` -------------------------------- ### cURL Request Example Source: https://keymint.dev/docs/api-reference/authentication This example shows how to make a request to the customer endpoint using cURL, including the necessary Authorization and Content-Type headers. ```bash curl https://api.keymint.dev/customer \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` -------------------------------- ### Build Tauri Application Source: https://keymint.dev/docs/templates/tauri-license-starter Execute this command to build a platform-specific installer for your Tauri application. The output will be located in `src-tauri/target/release/bundle/`. ```bash npm run tauri build ``` -------------------------------- ### Successful License Key Creation Response Source: https://keymint.dev/docs/api-reference/license-keys/create Example response body indicating successful creation of a license key. ```json { "code": 0, "key": "T8XTR-AI21B-2990H-85SB5" } ``` -------------------------------- ### Get License Key Info (cURL) Source: https://keymint.dev/docs/api-reference/license-keys/get-info Use this cURL command to make a GET request to retrieve information about a specific license key. Replace placeholders with your actual product ID, license key, and API key. ```bash curl -X GET "https://api.keymint.dev/key?productId=%3CPRODUCT_ID%3E&licenseKey=%3CLICENSE_KEY%3E" \ -H "Authorization: Bearer " ``` -------------------------------- ### Clone and Run Tauri Starter Project Source: https://keymint.dev/docs/templates/tauri-license-starter Use these commands to clone the starter project, install dependencies, configure your API key and product ID, and run the development server. ```bash git clone https://github.com/keymint-dev/keymint-tauri-starter.git cd keymint-tauri-starter npm install # Edit src-tauri/.cargo/config.toml with your KEYMINT_CLIENT_API_KEY and KEYMINT_PRODUCT_ID npm run tauri dev ``` -------------------------------- ### Quick Start: Keymint Go SDK Usage Source: https://keymint.dev/docs/sdks/go Demonstrates basic usage of the Keymint Go SDK, including creating keys with allowed hosts and activating licenses. Use admin keys for key management and client keys for license activation. ```go package main import ( "fmt" keymint "github.com/keymint-dev/keymint-go" ) func main() { admin, err := keymint.New("YOUR_ADMIN_API_KEY", "") if err != nil { panic(err) } client, err := keymint.New("YOUR_CLIENT_API_KEY", "") if err != nil { panic(err) } // Create a key with allowed hosts (Node-locking) newKey, err := admin.CreateKey(keymint.CreateKeyParams{ ProductID: "your_product_id", AllowedHosts: []string{"machine-a", "machine-b"}, }) // Activate a license result, err := client.ActivateKey(keymint.ActivateKeyParams{ ProductID: "your_product_id", LicenseKey: "XXXXX-XXXXX-XXXXX-XXXXX", HostID: keymint.String("machine-a"), }) if err != nil { panic(err) } fmt.Println(result.Message) // "License valid" } ``` -------------------------------- ### Clone and Run Electron License Starter Source: https://keymint.dev/docs/templates/electron-license-starter Clone the repository, install dependencies, configure environment variables, and run the development server to test the license activation flow. ```bash git clone https://github.com/keymint-dev/keymint-electron-starter.git cd keymint-electron-starter npm install cp .env.example .env # Fill in KEYMINT_CLIENT_API_KEY and KEYMINT_PRODUCT_ID npm run dev ``` -------------------------------- ### Customer Endpoint Example Source: https://keymint.dev/docs/api-reference/authentication Example of how to authenticate a request to the customer endpoint using a Bearer token. ```APIDOC ## GET /customer ### Description Retrieves customer information. Requires authentication. ### Method GET ### Endpoint /customer ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Content-Type** (string) - Required - application/json ### Request Example ```bash curl https://api.keymint.dev/customer \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example { "example": "response body" } ``` -------------------------------- ### Quick Start: Keymint C# SDK Source: https://keymint.dev/docs/sdks/csharp Demonstrates creating a key with authorized hosts and activating a license using the Keymint C# SDK. Use admin keys for key management and client keys for license activation. ```csharp using KeyMint.Services; var admin = new KeyMintSDK("YOUR_ADMIN_API_KEY"); var client = new KeyMintSDK("YOUR_CLIENT_API_KEY"); // Create a key with authorized hosts var createResult = await admin.CreateKey(new CreateKeyParams { ProductId = "your_product_id", AllowedHosts = new List { "machine-a", "machine-b" } }); // Activate a license var result = await client.ActivateKey(new ActivateKeyParams { ProductId = "your_product_id", LicenseKey = "XXXXX-XXXXX-XXXXX-XXXXX", HostId = "machine-a" }); if (result.IsSuccess) { Console.WriteLine(result.Data.Message); // "License valid" } ``` -------------------------------- ### Authentication Example Source: https://keymint.dev/docs/api-reference/overview Demonstrates how to authenticate API requests using a Bearer token in the Authorization header. ```APIDOC ## Authentication Example ### Description Every API request requires authentication using a Bearer token in the `Authorization` header. You can generate API keys with scoped permissions in the developer settings. ### Method GET (example, actual method may vary) ### Endpoint `/customer` ### Request Example ```bash curl https://api.keymint.dev/customer \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` ``` -------------------------------- ### Keymint Python SDK Quick Start Source: https://keymint.dev/docs/sdks/python Demonstrates basic usage of the Keymint Python SDK for creating keys and activating licenses. Use admin keys for key management and client keys for license activation. ```python from keymint import KeyMint admin = KeyMint(api_key="YOUR_ADMIN_API_KEY") client = KeyMint(api_key="YOUR_CLIENT_API_KEY") # Create a key with authorized hosts new_key = admin.create_key({ "productId": "your_product_id", "allowedHosts": ["machine-a", "machine-b"] }) # Activate a license result = client.activate_key({ "productId": "your_product_id", "licenseKey": "XXXXX-XXXXX-XXXXX-XXXXX", "hostId": "machine-a", "licensee": {"name": "Jane Doe", "email": "jane@example.com"} }) print(result['message']) # "License valid" ``` -------------------------------- ### Quick Start: Keymint Node.js SDK Source: https://keymint.dev/docs/sdks/nodejs Demonstrates creating a key with allowed hosts and activating a license using the Keymint Node.js SDK. Use admin keys for key management and client keys for license activation. ```typescript import { KeyMint } from 'keymint'; const admin = new KeyMint('YOUR_ADMIN_API_KEY'); const client = new KeyMint('YOUR_CLIENT_API_KEY'); // Create a key with allowed hosts (Node-locking) const newKey = await admin.createKey({ productId: 'your_product_id', allowedHosts: ['machine-a', 'machine-b'] }); // Activate a license const result = await client.activateKey({ productId: 'your_product_id', licenseKey: 'XXXXX-XXXXX-XXXXX-XXXXX', hostId: 'machine-a', licensee: { name: 'Jane Doe', email: 'jane@example.com' } }); console.log(result.message); // "License valid" ``` -------------------------------- ### Customer Update Response Example Source: https://keymint.dev/docs/api-reference/customers/update Shows the expected JSON response when a customer is successfully updated. ```JSON { "action": "updateCustomer", "status": true, "code": 0 } ``` -------------------------------- ### Idempotency Example Source: https://keymint.dev/docs/api-reference/overview Shows how to use the `Idempotency-Key` header for safe retries on mutating endpoints. ```APIDOC ## Idempotency Example ### Description All mutating endpoints (`POST`, `PATCH`, `DELETE`) support safe retries by passing an `Idempotency-Key` (or `X-Idempotency-Key`) header. This prevents duplicate resource creation if the connection drops. Idempotency keys and cached response payloads are retained for **24 hours**. ### Method POST ### Endpoint `/key/checkout` ### Parameters #### Request Body - **productId** (string) - Required - The ID of the product. - **licenseKey** (string) - Required - The license key to checkout. ### Request Example ```bash curl -X POST https://api.keymint.dev/key/checkout \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" \ -d '{"productId": "prod_123", "licenseKey": "XXXXX-XXXXX-XXXXX-XXXXX"}' ``` ``` -------------------------------- ### Tauri App Setup with License Commands Source: https://keymint.dev/docs/guides/tauri-licensing Registers license-related commands with the Tauri application builder. This is the main entry point for your Tauri application. ```rust #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] mod license; fn main() { tauri::Builder::default() .invoke_handler(tauri::generate_handler![ license::activate_license, license::deactivate_license, license::is_activated, license::get_license_status, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -------------------------------- ### Get Customer By ID (cURL) Source: https://keymint.dev/docs/api-reference/customers/get-by-id Use this cURL command to make a GET request to retrieve a specific customer's information. Ensure you replace `` and `` with actual values. Authentication is required via a Bearer Token. ```bash curl -X GET "https://api.keymint.dev/customer/by-id?customerId=%3CCUSTOMER_ID%3E" \ -H "Authorization: Bearer " ``` -------------------------------- ### Create License Key Request Source: https://keymint.dev/docs/api-reference/license-keys/create Example cURL request to create a license key with various custom options including customer details, metadata, and formatting. ```shell curl -X POST "https://api.keymint.dev/key" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "allowedHosts": [], "productId": "string", "maxActivations": "string", "customerId": "string", "newCustomer": { "name": "string", "email": "user@example.com" }, "metadata": { "is_trial": true, "features": { "pro_mode": true } }, "versionId": "string", "amountKeys": "string", "expiryDate": "2026-07-01T10:43:48.474Z", "format": { "sections": 1, "sectionLength": 1, "separator": "string", "charset": "string", "prefix": "string", "suffix": "string", "case": "string" }, "licenseType": "string", "maxConcurrentSessions": 1, "heartbeatInterval": 60, "sessionLeaseDuration": 300 }' ``` -------------------------------- ### Activate License Key Response (200 OK) Source: https://keymint.dev/docs/api-reference/license-keys/activate This is an example of a successful response (200 OK) after activating a license key. It includes a status code, message, licensee details, and authorized hosts for node-locked licenses. ```json { "code": 0, "message": "License valid", "licenseeName": "License Test Customer", "licenseeEmail": "license-1756752346942@example.com", "allowedHosts": [ "MACHINE-A1B2C3" ] } ``` -------------------------------- ### Manage Floating License Seats in TypeScript Source: https://keymint.dev/docs/topics/floating-licenses This example demonstrates how to lease, extend, and release floating license seats using the Keymint SDK. It includes setting up a periodic heartbeat and a shutdown hook for graceful checkin. ```typescript import { KeyMint } from 'keymint'; const keymint = new KeyMint('YOUR_API_KEY'); const productId = 'prod_100'; const licenseKey = 'KM-A8E2-9F1B-C3D4'; // 1. Resolve a stable host identifier for this device const hostId = KeyMint.getOrCreateInstallationId(); async function manageFloatingLicense() { try { // 2. Checkout a seat session const session = await keymint.floatingCheckout({ productId, licenseKey, hostId }); console.log(`License leased. Session ID: ${session.sessionId}`); let currentNonce = session.nextNonce; // 3. Set up a periodic heartbeat loop based on the returned interval const heartbeatIntervalMs = session.heartbeatInterval * 1000; const intervalId = setInterval(async () => { try { // Generate the HMAC signature using the rotating nonce const signature = KeyMint.generateSessionSignature( session.sessionId, currentNonce, session.sessionSecret ); const heartbeatRes = await keymint.floatingHeartbeat({ productId, licenseKey, sessionId: session.sessionId, timestamp: currentNonce, signature }); // Rotate the nonce for the next heartbeat challenge currentNonce = heartbeatRes.nextNonce; console.log('Heartbeat extended successfully.'); } catch (err) { console.error('Heartbeat failed:', err.message); // Implement backup retry/grace logic here (e.g. warn user or restrict features) } }, heartbeatIntervalMs); // 4. Register a clean shutdown hook to check in the seat process.on('SIGTERM', async () => { clearInterval(intervalId); try { const signature = KeyMint.generateSessionSignature( session.sessionId, currentNonce, session.sessionSecret ); await keymint.floatingCheckin({ productId, licenseKey, sessionId: session.sessionId, timestamp: currentNonce, signature }); console.log('Session checked in. Seat released.'); process.exit(0); } catch (err) { console.error('Graceful checkin failed:', err.message); process.exit(1); } }); } catch (error) { console.error('Checkout failed (no available seats or invalid license):', error.message); } } manageFloatingLicense(); ``` -------------------------------- ### Customer Direct Keymint Activation Source: https://keymint.dev/docs/guides/nextjs-saas-licensing Example of how a customer's self-hosted instance can directly call Keymint to activate a license using their own client API key. Ensure you have a Keymint client instance initialized with the customer's API key. ```typescript // In your customer's self-hosted code import { KeyMint } from 'keymint'; const client = new KeyMint('CUSTOMER_CLIENT_API_KEY'); const result = await client.activateKey({ productId: 'prod_your_product_id', licenseKey: 'KM-XXXX-XXXX-XXXX', hostId: getHostId(), }); if (result.code === 0) { console.log('License valid'); } ``` -------------------------------- ### Get Customer Keys Response (200 OK) Source: https://keymint.dev/docs/api-reference/customers/get-with-keys This is an example of a successful response (200 OK) from the Keymint API when retrieving customer license keys. It indicates the action performed, status, and an empty data array if no keys are found. ```json { "action": "getCustomerLicenseKeys", "status": true, "data": [], "code": 0 } ``` -------------------------------- ### Idempotent Request Example Source: https://keymint.dev/docs/api-reference/overview Example of making a mutating API request with an Idempotency-Key header to ensure safe retries. The key should be a unique string, recommended to be a UUID v4. ```bash curl -X POST https://api.keymint.dev/key/checkout \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" \ -d '{"productId": "prod_123", "licenseKey": "XXXXX-XXXXX-XXXXX-XXXXX"}' ``` -------------------------------- ### Get Customer Keys (cURL) Source: https://keymint.dev/docs/api-reference/customers/get-with-keys Use this cURL command to make a GET request to the Keymint API to retrieve license keys for a specific customer. Ensure you replace `` and `` with actual values. ```curl curl -X GET "https://api.keymint.dev/customer/keys?customerId=%3CCUSTOMER_ID%3E" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Customer Source: https://keymint.dev/docs/api-reference/introduction Retrieves the details of a specific customer by their ID. ```APIDOC ## GET /customers/{id} ### Description Retrieve individual customer details. ### Method GET ### Endpoint /customers/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the customer to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the customer. - **name** (string) - The name of the customer. - **email** (string) - The email address of the customer. #### Response Example { "id": "cust_123", "name": "Acme Corp", "email": "contact@acme.com" } ``` -------------------------------- ### Offline License Signing with KeyMint Admin API Source: https://keymint.dev/docs/guides/pyqt-licensing Demonstrates how to sign an offline license using the KeyMint admin API. This process should be run on a backend server, not within the bundled PyQt application. Requires a Standard plan. ```python # Run from your backend/server (NOT bundled in the app) admin = KeyMint(api_key="YOUR_ADMIN_API_KEY") offline_license = admin.sign_offline_key({ "productId": "prod_your_product_id", "licenseKey": "KM-A8E2-9F1B-C3D4", "hostId": "machine-fingerprint", "ttl": 30 * 24 * 60 * 60, # 30 days }) # offline_license["file"] is a JSON string with the signed JWT ``` -------------------------------- ### Set Build-Time Environment Variables Source: https://keymint.dev/docs/guides/tauri-licensing Store product ID and client API key as build-time environment variables. Avoid hardcoding them directly in source files. ```bash KEYMINT_CLIENT_API_KEY=km_client_abc123... KEYMINT_PRODUCT_ID=prod_xyz789... ``` -------------------------------- ### PyQt License Activation Dialog Source: https://keymint.dev/docs/guides/pyqt-licensing Builds a PyQt6 dialog for license activation. It includes input fields for the license key, a button to trigger activation, and a status label. The dialog pre-fills the key if one was previously stored and deactivated. ```python from PyQt6.QtWidgets import ( QDialog, QVBoxLayout, QLabel, QLineEdit, QPushButton, QMessageBox ) from PyQt6.QtCore import Qt from license_manager import activate_license, get_stored_key class ActivationDialog(QDialog): def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("Activate License") self.setFixedSize(420, 220) self.setWindowFlags( self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint ) layout = QVBoxLayout() layout.setSpacing(12) title = QLabel("Enter your license key to activate") title.setAlignment(Qt.AlignmentFlag.AlignCenter) layout.addWidget(title) self.key_input = QLineEdit() self.key_input.setPlaceholderText("KM-XXXX-XXXX-XXXX-XXXX") self.key_input.setMaxLength(64) layout.addWidget(self.key_input) # Pre-fill if a key was stored but deactivated stored = get_stored_key() if stored: self.key_input.setText(stored) self.activate_btn = QPushButton("Activate") self.activate_btn.clicked.connect(self._on_activate) layout.addWidget(self.activate_btn) self.status_label = QLabel("") self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter) layout.addWidget(self.status_label) self.setLayout(layout) def _on_activate(self): key = self.key_input.text().strip() if not key: self.status_label.setText("Please enter a license key") return self.activate_btn.setEnabled(False) self.status_label.setText("Activating...") self.activate_btn.repaint() result = activate_license(key) if result["success"]: QMessageBox.information(self, "Success", "License activated successfully!") self.accept() else: self.status_label.setText(f"Failed: {result['message']}") self.activate_btn.setEnabled(True) ``` -------------------------------- ### Complete License Service Implementation Source: https://keymint.dev/docs/guides/nextjs-saas-licensing This TypeScript file provides a full implementation of a license service using KeyMint and a database. It includes functions for creating, blocking, unblocking, updating expiry, and retrieving license information. ```typescript import { KeyMint } from 'keymint'; import { db } from '@/lib/db'; import { licenseKeys } from '@/lib/db/schema'; import { eq } from 'drizzle-orm'; const admin = new KeyMint(process.env.KEYMINT_ADMIN_API_KEY!); const PRODUCT_ID = process.env.KEYMINT_PRODUCT_ID!; interface CreateLicenseParams { customerEmail: string; customerName: string; maxActivations: number; planName: string; subscriptionEndDate?: Date; userId: string; } export async function createCustomerLicense(params: CreateLicenseParams) { const license = await admin.createKey({ productId: PRODUCT_ID, maxActivations: params.maxActivations, licenseType: params.maxActivations > 100 ? 'floating' : 'node-locked', expiryDate: params.subscriptionEndDate?.toISOString(), newCustomer: { name: params.customerName, email: params.customerEmail, }, metadata: { plan: params.planName, }, }); // Store in your database await db.insert(licenseKeys).values({ userId: params.userId, licenseKey: license.key, productId: PRODUCT_ID, status: 'active', plan: params.planName, }); return license; } export async function blockLicense(licenseKey: string) { await admin.blockKey({ productId: PRODUCT_ID, licenseKey }); await db .update(licenseKeys) .set({ status: 'blocked' }) .where(eq(licenseKeys.licenseKey, licenseKey)); } export async function unblockLicense(licenseKey: string) { await admin.unblockKey({ productId: PRODUCT_ID, licenseKey }); await db .update(licenseKeys) .set({ status: 'active' }) .where(eq(licenseKeys.licenseKey, licenseKey)); } export async function getLicenseInfo(licenseKey: string) { return admin.getKeyInfo(PRODUCT_ID, licenseKey); } export async function updateLicenseExpiry( licenseKey: string, expiryDate: Date, ) { return admin.updateKey({ productId: PRODUCT_ID, licenseKey, expiryDate: expiryDate.toISOString(), }); } export async function getCustomerLicenses(userId: string) { return db .select() .from(licenseKeys) .where(eq(licenseKeys.userId, userId)); } ``` -------------------------------- ### Authorization Header Example Source: https://keymint.dev/docs/api-reference/authentication All requests to the Keymint API require your API key to be included in the Authorization header as a Bearer token. ```text Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### Get Customer By ID Source: https://keymint.dev/docs/api-reference/customers/get-by-id Retrieves detailed information for a specific customer by their ID. Authentication is required using a Bearer Token. ```APIDOC ## GET /customer/by-id ### Description Retrieve detailed information for a specific customer by their ID. ### Method GET ### Endpoint /customer/by-id ### Parameters #### Query Parameters - **customerId** (string) - Required - ID of the customer `e.g. ` ### Request Example ```curl curl -X GET "https://api.keymint.dev/customer/by-id?customerId=" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **action** (string) - **status** (boolean) - **data** (array) - **code** (integer) #### Response Example (200 OK) ```json { "action": "getCustomerById", "status": true, "data": [ { "id": "078116d0069c32407b4f63", "name": "Test Customer", "email": "test-1756752334256@example.com", "active": true, "createdAt": "2025-09-01T18:45:38.060Z", "updatedAt": "2025-09-01T18:45:38.060Z" } ], "code": 0 } ``` ``` -------------------------------- ### PyQt License Manager Script Source: https://keymint.dev/docs/guides/pyqt-licensing This script provides functions for managing PyQt application licenses using Keymint. It includes methods for generating a host ID, activating a license key, deactivating a license, and checking the activation status. Ensure KEYMINT_PRODUCT_ID and KEYMINT_CLIENT_API_KEY environment variables are set. ```python license_manager.py — Keymint license management for PyQt applications. Drop this file into your PyQt project and call activate_license() from your activation dialog. ``` ```python import hashlib import platform import subprocess import uuid import os from PyQt6.QtCore import QSettings from keymint import KeyMint PRODUCT_ID = os.environ.get("KEYMINT_PRODUCT_ID", "") CLIENT_API_KEY = os.environ.get("KEYMINT_CLIENT_API_KEY", "") if not PRODUCT_ID or not CLIENT_API_KEY: raise RuntimeError( "KEYMINT_PRODUCT_ID and KEYMINT_CLIENT_API_KEY must be set" ) client = KeyMint(api_key=CLIENT_API_KEY) settings = QSettings("YourCompany", "YourApp") def get_host_id() -> str: system = platform.system() try: if system == "Windows": output = subprocess.check_output( "wmic csproduct get uuid", shell=True ) raw = output.decode().split("\n")[1].strip() elif system == "Darwin": output = subprocess.check_output( "ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID", shell=True, ) raw = output.decode().split('"')[-2] else: with open("/etc/machine-id") as f: raw = f.read().strip() except Exception: raw = str(uuid.getnode()) return hashlib.sha256(raw.encode()).hexdigest()[:16] def get_stored_key() -> str | None: val = settings.value("license/key") return val if val else None def is_activated() -> bool: return settings.value("license/activated", False, type=bool) def activate_license(license_key: str) -> dict: host_id = get_host_id() try: result = client.activate_key({ "productId": PRODUCT_ID, "licenseKey": license_key, "hostId": host_id, }) if result.get("code") == 0: settings.setValue("license/key", license_key) settings.setValue("license/activated", True) return {"success": True, "message": result.get("message", "")} return {"success": False, "message": result.get("message", "Activation failed")} except Exception as e: return {"success": False, "message": str(e)} def deactivate_license() -> bool: license_key = get_stored_key() if not license_key: return False host_id = get_host_id() try: result = client.deactivate_key({ "productId": PRODUCT_ID, "licenseKey": license_key, "hostId": host_id, }) if result.get("code") == 0: settings.remove("license/key") settings.remove("license/activated") return True return False except Exception: return False ``` -------------------------------- ### Environment Configuration for Keymint Source: https://keymint.dev/docs/templates/electron-license-starter Configure your Keymint client API key and product ID in the .env file. The client API key is used for license activation and management, while the product ID identifies your specific product on Keymint. ```text KEYMINT_CLIENT_API_KEY=km_client_your_key KEYMINT_PRODUCT_ID=prod_your_product_id ``` -------------------------------- ### Get Customer Keys Source: https://keymint.dev/docs/api-reference/customers/get-with-keys Lists all license keys currently assigned to a specific customer. Requires Bearer Token authentication. ```APIDOC ## GET /customer/keys ### Description List all license keys currently assigned to a specific customer. ### Method GET ### Endpoint /customer/keys ### Parameters #### Query Parameters - **customerId** (string) - Required - ID of the customer `e.g. ` ### Request Example ```curl curl -X GET "https://api.keymint.dev/customer/keys?customerId=%3CCUSTOMER_ID%3E" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **action** (string) - Description of the action performed. - **status** (boolean) - Indicates if the operation was successful. - **data** (array) - An array containing license key information. - **code** (integer) - A status code for the operation. #### Response Example ```json { "action": "getCustomerLicenseKeys", "status": true, "data": [], "code": 0 } ``` ``` -------------------------------- ### Get All Customers Source: https://keymint.dev/docs/api-reference/customers/get-all Retrieves a paginated list of all customers, with optional filtering by email address. Authentication is required using a Bearer Token. ```APIDOC ## GET /customer ### Description Retrieve a paginated list of all customers in your Keymint account. ### Method GET ### Endpoint /customer ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number for pagination. `e.g. 1` - **limit** (integer) - Optional - Number of items per page (max 100). `e.g. 10` - **email** (string) - Optional - Filter customers by email address. `e.g. user@example.com` ### Request Example ```curl curl -X GET "https://api.keymint.dev/customer?page=1&limit=10&email=user%40example.com" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **action** (string) - The action performed. - **status** (boolean) - Indicates if the operation was successful. - **data** (array) - A list of customer objects. - **meta** (object) - Metadata about the pagination. - **code** (integer) - The response code. #### Response Example ```json { "action": "getCustomers", "status": true, "data": [ { "id": "c9cbdf88f01f516815a59f", "name": "Test Customer", "email": "test@example.com", "active": true, "createdAt": "2025-09-01T14:46:10.932Z", "updatedAt": "2025-09-01T14:46:10.622Z" } ], "meta": { "total": 3, "page": 1, "limit": 10, "totalPages": 1 }, "code": 0 } ``` ``` -------------------------------- ### Configure Keymint Environment Variables Source: https://keymint.dev/docs/templates/pyqt-license-starter Set the Keymint client API key and product ID as environment variables for the application to use. ```bash export KEYMINT_CLIENT_API_KEY=km_client_your_key export KEYMINT_PRODUCT_ID=prod_your_product_id ``` -------------------------------- ### Get All Customers Response (200 OK) Source: https://keymint.dev/docs/api-reference/customers/get-all This is a successful response when retrieving a list of customers. It includes customer data and pagination metadata. ```json { "action": "getCustomers", "status": true, "data": [ { "id": "c9cbdf88f01f516815a59f", "name": "Test Customer", "email": "test@example.com", "active": true, "createdAt": "2025-09-01T14:46:10.932Z", "updatedAt": "2025-09-01T14:46:10.622Z" }, { "id": "10ba13e31f4dcf12368343", "name": "License Test Customer", "email": "license@example.com", "active": true, "createdAt": "2025-09-01T18:39:21.857Z", "updatedAt": "2025-09-01T18:39:21.372Z" }, { "id": "078116d0069c32407b4f63", "name": "Test Customer", "email": "test-1756752334256@example.com", "active": true, "createdAt": "2025-09-01T18:45:38.060Z", "updatedAt": "2025-09-01T18:45:38.060Z" } ], "meta": { "total": 3, "page": 1, "limit": 10, "totalPages": 1 }, "code": 0 } ``` -------------------------------- ### Get All Customers (cURL) Source: https://keymint.dev/docs/api-reference/customers/get-all Use this cURL command to retrieve a paginated list of customers. Include your API key in the Authorization header. ```bash curl -X GET "https://api.keymint.dev/customer?page=1&limit=10&email=user%40example.com" \ -H "Authorization: Bearer " ``` -------------------------------- ### Create Customer Source: https://keymint.dev/docs/api-reference/introduction Adds a new customer to your Keymint system. ```APIDOC ## POST /customers ### Description Add new customers to your system. ### Method POST ### Endpoint /customers ### Parameters #### Request Body - **name** (string) - Required - The name of the customer. - **email** (string) - Required - The email address of the customer. ### Request Example { "name": "Beta Inc", "email": "info@beta.inc" } ### Response #### Success Response (201) - **id** (string) - The unique identifier for the newly created customer. - **name** (string) - The name of the customer. - **email** (string) - The email address of the customer. #### Response Example { "id": "cust_456", "name": "Beta Inc", "email": "info@beta.inc" } ``` -------------------------------- ### Offline License Signing Source: https://keymint.dev/docs/guides/tauri-licensing Example of signing an offline license key using Keymint's offline signing capability. The signed file contains a JWT. ```typescript // Run from your backend const signedFile = await admin.signOfflineKey({ productId: "prod_your_product_id", licenseKey: "KM-A8E2-9F1B-C3D4", hostId: "machine-fingerprint", ttl: 60 * 60 * 24 * 30, // 30 days }); // signedFile.file is a JSON string with the signed JWT ``` -------------------------------- ### Configure Keymint via Cargo Config Source: https://keymint.dev/docs/templates/tauri-license-starter Alternatively, you can add your Keymint client API key and product ID directly to the `.cargo/config.toml` file. This method embeds the variables at build time. ```toml [env] KEYMINT_CLIENT_API_KEY = "km_client_your_key" KEYMINT_PRODUCT_ID = "prod_your_product_id" ``` -------------------------------- ### Build Tauri App with Environment Variables Source: https://keymint.dev/docs/guides/tauri-licensing Load environment variables from a .env file and then build the Tauri application. ```bash #!/bin/bash source .env cargo tauri build ``` -------------------------------- ### Successful Checkout Response (200 OK) Source: https://keymint.dev/docs/api-reference/license-keys/checkout This is an example of a successful response when checking out a floating license seat. It contains session details, secrets, and license metadata. ```json { "code": 0, "message": "string", "sessionId": "abc123sessionid22chars", "sessionSecret": "string", "nextNonce": "1700000000000", "expiresAt": "2026-07-01T10:43:48.357Z", "heartbeatInterval": 1, "metadata": {}, "currentSessions": 1, "maxSessions": 1, "licenseeName": "string", "licenseeEmail": "user@example.com" } ``` -------------------------------- ### Toggle Customer Status Response (200 OK) Source: https://keymint.dev/docs/api-reference/customers/toggle-status This is an example of a successful response when toggling a customer's status. It indicates the action performed and the new status. ```json { "action": "toggleActive", "status": true, "message": "Customer disabled", "code": 0 } ``` -------------------------------- ### Activate License Key (TypeScript) Source: https://keymint.dev/docs/introduction/getting-started Initialize the Keymint client with your API key and invoke the activateKey endpoint to register a host machine and check seat availability. Ensure your API key is kept secure. ```typescript import { KeyMint } from 'keymint'; // Initialize the Keymint client const keymint = new KeyMint('YOUR_API_KEY'); async function runActivation() { try { const response = await keymint.activateKey({ productId: 'prod_100', licenseKey: 'KM-A8E2-9F1B-C3D4', hostId: 'mac-studio-m2' // Unique identifier for the host machine }); if (response.code === 0) { console.log(`License validated. Seat active for ${response.licenseeName}`); } else { console.log(`Activation failed: ${response.message}`); } } catch (error) { console.error('API request failed:', error.message); } } runActivation(); ``` -------------------------------- ### Gate PyQt Application Entry Point Source: https://keymint.dev/docs/guides/pyqt-licensing Gate your PyQt application's entry point to check for license activation. If activated, it re-checks the token; otherwise, it prompts for activation. ```python import sys from PyQt6.QtWidgets import QApplication from license_manager import get_stored_key, is_activated, activate_license from activation_dialog import ActivationDialog from main_window import MainWindow def main(): app = QApplication(sys.argv) if is_activated(): # Token re-check on launch (validates license hasn't been revoked) stored_key = get_stored_key() if stored_key: result = activate_license(stored_key) if result["success"]: window = MainWindow() window.show() sys.exit(app.exec()) return # Show activation dialog dialog = ActivationDialog() if dialog.exec() == ActivationDialog.DialogCode.Accepted: window = MainWindow() window.show() sys.exit(app.exec()) if __name__ == "__main__": main() ``` -------------------------------- ### Authenticate API Request Source: https://keymint.dev/docs/api-reference/overview Example of how to authenticate an API request using a Bearer token in the Authorization header. Ensure your API keys are kept secure and not used in client-side code. ```bash curl https://api.keymint.dev/customer \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` ```typescript fetch('https://api.keymint.dev/customer', { method: 'GET', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' } }); ``` -------------------------------- ### Sign Offline Key Response (200 OK) Source: https://keymint.dev/docs/api-reference/license-keys/sign This is an example of a successful response when an offline license key is signed. The response contains the signed license file as a JSON string. ```json { "file": "string" } ``` -------------------------------- ### Build and Deploy Next.js App Source: https://keymint.dev/docs/templates/nextjs-saas-starter Build the Next.js application for production and deploy it to a Node.js host. Ensure the webhook secret is configured correctly for Keymint. ```bash npm run build # Deploy to Vercel, Railway, or any Node.js host ```