Using Keymint Node.js SDK for License Management
If you’re building a Node.js app, whether it’s a desktop tool, CLI app, or SaaS backend, you need an easy, reliable way to manage license keys.
While you can use direct HTTP calls to the Keymint API, the official Keymint Node.js SDK makes it faster and safer by handling the heavy lifting for you. With prebuilt methods, type support, and standardized error handling, you can integrate licensing in minutes.
Why Use the SDK? Here’s why most developers prefer the SDK over raw API calls:
✅ Prebuilt methods for key creation, activation, and management
🔒 Type safety and autocomplete when using TypeScript
🚫 Fewer manual errors when handling requests and responses
⚡ Faster to implement and easier to maintain over time
Install the SDK Add the package to your project:
npm install keymintMake sure you have the right Keymint access token for the job: use an admin key for creating/blocking keys, a client key for activation/deactivation/floating sessions, and a read-only or admin key for detailed key lookup.
Example: Create and Activate a License Key Initialize the SDK
import { KeyMint } from "keymint";
const adminSdk = new KeyMint(process.env.KEYMINT_ADMIN_API_KEY);
const clientSdk = new KeyMint(process.env.KEYMINT_CLIENT_API_KEY);Store admin/read-only keys securely in environment variables. Only client-scoped keys should be bundled into runtime app integrations.
Create a License Key
async function createLicense() {
const response = await adminSdk.createKey({
productId: "your_product_id",
maxActivations: "5",
expiryDate: "2025-12-31T23:59:59Z",
newCustomer: { name: "Alice Example", email: "alice@example.com" },
});
console.log("New license key:", response.key);
}This creates a new license tied to a product and customer.
Activate a License
async function activateLicense(licenseKey: string) {
const response = await clientSdk.activateKey({
productId: "your_product_id",
licenseKey,
hostId: "device-1234",
deviceTag: "Alice’s MacBook",
});
console.log("Activation successful:", response.message);
}This registers the license to a device or machine.
Deactivate or Manage Licenses You can also deactivate a device:
await clientSdk.deactivateKey({
productId: "your_product_id",
licenseKey,
hostId: "device-1234",
});Block a key entirely:
await adminSdk.blockKey({
productId: "your_product_id",
licenseKey,
});Or fetch license details:
const details = await adminSdk.getKey({
productId: "your_product_id",
licenseKey,
});
console.log("License details:", details.data.license);Use a read-only or admin key for getKey; client-scoped keys are blocked from detailed license lookup.
Handle Errors Gracefully
The SDK provides clear error objects:
try {
await sdk.activateKey(...);
} catch (error) {
console.error("Error:", error.message);
console.error("Code:", error.code);
console.error("Status:", error.status);
}This makes it easier to troubleshoot and provide meaningful feedback to users.
Build Smarter with Keymint The Keymint Node.js SDK helps you:
Launch license management faster
Reduce maintenance overhead
Scale with confidence as your app grows
Whether you're building indie software or scaling a SaaS platform, Keymint gives you the tools to protect your work and manage access smoothly.
Start integrating today — see pricing and take full control over your licenses.