Create license

You can create licenses using the SDK. Here is an example of how to create a license:

import { Keyforge } from 'keyforge-js';
 
const keyforge = new Keyforge('sk_1234');
 
const license = await keyforge.licenses.create({
  productId: 'p_123456',
  type: 'perpetual',
  maxDevices: 2,
  email: '[email protected]',
});

Parameters

PropTypeDefault
productId
string
-
type
'perpetual' | 'timed'
-
maxDevices
number
-
email
string
-
expiresAt
Date | undefined
-
License email

Even though the email parameter is optional, it is recommended to provide it. Customers are able to manage licenses linked with their email in the portal.

Returns

Here is an example of the created license object:

{
  "key": "ABCDE-ABCDE-ABCDE-ABCDE-ABCDE",
  "userId": "05d27bfb-61c7-45f7-9d07-09a41defc88a",
  "productId": "p_123456",
  "type": "perpetual",
  "expiresAt": null,
  "revoked": false,
  "email": "[email protected]",
  "maxDevices": 2,
  "activeDevices": [],
  "createdAt": "2024-05-19T18:39:33.000Z"
}

On this page