API Reference 🛠

Welcome to the Nucleus API! You can use this API to work with licenses and policies.

Something is missing? Would like to see something more? -> hello@nucleus.sh

Authentication

Nucleus expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: your_access_token

Example:

curl "api_endpoint_here"
    -H "Authorization: your_access_token"

You may also send it in the body of a POST request as the parameter token.

Policies

A policy defines how a license can be used. For example, it allows you to configure its expiration delay, how many machines the license should work, etc.. and can be used inside your app to separate licenses types.

Get All Policies

This endpoint retrieves all licenses.

HTTP Request

GET https://nucleus.sh/app/:appId/policies

It will return a JSON array structured like this:

[
    {
        "id": "basic",
        "duration": "365",
        "maxMachines": "5",
        "version": "0.8.1"
    },
    {
        "id": "lifetime",
        "duration": "0",
        "maxMachines": "0",
        "version": "all"
    }
]

Create a policy

HTTP Request

POST https://nucleus.sh/app/:appId/policy

Query Parameters

Parameter Optional Description
id required The id of the new policy
maxMachines optional Maximum number of machines the license will be allowed on (0 for no limits)
versionValidity optional On which version should the license be working ('all' )
durationValidity optional For how many days the licenses will be valid (0 for always)

Delete a policy

Completely remove a policy. Licenses created with the policy will keep working under their policies at the time of their creation.

HTTP Request

DELETE https://nucleus.sh/app/:appId/policy/:policyId

Licenses

Get All Licenses

This endpoint retrieves all licenses.

HTTP Request

GET https://nucleus.sh/app/:appId/licenses

This will return a JSON array structured like this:

[
    {
        "id": "license_id",
        "key": "eozUYGifqgoiZefjHDiz",
        "status": "active",
        "userEmail": "user@example.com",
        "policy": "basic",
        "created": "2018-02-13",
        "expire": "0"
    }
]

Create a license

This is the main endpoint. It should be used on your server to create licenses for your users after they paid.

HTTP Request

POST https://nucleus.sh/app/:appId/licenses/

Query Parameters

Parameter Optional Description
policy required The policy you want to apply to the license
userEmail optional Email of the user who bought the license

If successfull, it will return the newly created license objetc.

Get a license

HTTP Request

GET https://nucleus.sh/app/:appId/license/:license

:license can either be directly the license or its id.

It will return a license object looking like:

{
    "id": "license_id",
    "key": "eozUYGifqgoiZefjHDiz",
    "status": "active",
    "userEmail": "user@example.com",
    "policy": "basic",
    "created": "2018-02-13",
    "expire": "0"
}

Update a license

For now you can only modify a license's status property This can be used to remotely disable a license.

HTTP Request

PUT https://nucleus.sh/app/:appId/license/:licenseId

Query Parameters

Parameter Optional Description
status optional Set to disabled to disable the license or active to reenable it

Delete a license

Completely delete a license. It won't work anymore and won't show up in your dashboard.

You should prefeer to disable it in case you want to re-use it later.

HTTP Request

DELETE https://nucleus.sh/app/:appId/license/:licenseId