Using Web API

We strongly recommend using LexActivator library for license activation. Web API should only be used for license activation, in case LexActivator library is not available for your OS e.g. Android and iOS.

Adding licensing to your app

After you've added a product for your app in the dashboard, go to the product page of the product you will be adding licensing to. You will need to do two things:

  • Note the product id for the product.

  • Download the 2048-bit RSA public key for the product.

RSA public key is needed to verify the signature of the activation token which you get on activating a license. Product id is the identifier of your product which is to be licensed.

In the license policies make sure fingerprintMatchingStrategy is set to "exact" as you will be using a custom fingerprint.

Activating the license key

To activate the license in your app using the license key, you need to send a POST request to the /v3/activations API endpoint. Following is a sample request which creates a license activation:

post
Create a license activation

https://api.cryptlex.com/v3/activations
Request
Response
Request
Body Parameters
key
required
string
License key to activate the license.
hostname
required
string
Name of the host machine.
os
required
string
Name of the operating system.
osVersion
optional
string
Version of the operating system.
fingerprint
required
string
Fingerprint of the machine.
vmName
optional
string
Name of the virtual machine.
metadata
optional
array
List of metadata key/value pairs.
appVersion
required
string
Version of the application.
userHash
required
string
Hash of the machine user name.
productId
required
string
Unique identifier for the product.
Response
201: Created
{
"activationToken": "string"
}

On successful activation it returns an activation token. Activation token is basically a JWT and you can easily verify it's signature using any of the JWT libraries available for your language. You can then parse the JWT activation token to get the license details.

Verifying license activation

Each time, your app starts, you need to verify whether your license is already activated or not. This verification should occur locally by verifying the signature of the JWT activation token using the RSA public key.

It is recommended to store the JWT activation token in an encrypted form though not required unless you have any sensitive metadata information in the token.

You can then parse the JWT activation token to get the license details.

Syncing license activation

In order to sync the client changes with the server and vice-versa you need to frequently sent an update request. You can decide on the update frequency as per your requirement, or use the frequency interval set for the license (available in JWT activation token). If you choose latter you can control it from dashboard.

patch
Updating a license activation

https://api.cryptlex.com/v3/activations/:id
Request
Response
Request
Path Parameters
id
required
string
Unique identifier for the activation.
Body Parameters
key
required
string
License key to activate the license.
hostname
required
string
Name of the host machine.
os
required
string
Name of the operating system.
osVersion
optional
string
Version of the operating system.
fingerprint
required
string
Fingerprint of the machine.
vmName
optional
string
Name of the virtual machine.
metadata
optional
array
List of metadata key/value pairs.
appVersion
required
string
Version of the application.
userHash
required
string
Hash of the machine user name.
productId
required
string
Unique identifier for the product.
Response
200: OK
{
"activationToken": "string"
}