1.Getting started #

1.1.Requirements #

WordPress permalinks must be enabled at: Settings > Permalinks.

1.2.API keys #

To access the REST API routes, you will first need to create a pair of API keys. These API keys are used to access the REST API routes as a specific user.

Navigate to the License Manager → Settings → REST API keys. Here you will be presented with the following screen:

Overview of REST API keys

On this screen, press the “Add key” button at the top of the page. From here on, you will be redirected to the following form:

“Create REST API keys” form

All fields are required. The “Description” field provides a name for this REST API key pair, which should summarize what it is the keys are being used for. The “User” field is a searchable dropdown field which determines to whom these keys will be assigned to. The “Permissions” field grants the REST API keys either read, write, or read/write permissions.

After filling out the form and pressing the “Generate API key” button, you will be redirected to the following page:

REST API keys have been created

As the success message instructs, you should now store these keys somewhere safe, as this is the last time you will see the secret key. If you do not save the REST API keys, or lose them, you will not be able to recover them. Because the consumer secret is stored as a hash inside the database, it is impossible to revert. Should this occur, you will need to generate a pair of new REST API keys.

1.3.Test if the API is working #

Making a basic request

The request URL we’ll test is wp-json/lmfwc/v2/generators. On localhost the full URL may look something like this: http://dev.wordpress.local/wp-json/lmfwc/v2/orders. Modify this to use your own site URL.

In Postman, you need to set the fields for request type, request URL, and the settings on the authorization tab. For Authorization, choose basic auth and enter your consumer key and consumer secret keys from the License Manager for WooCommerce into the username and password fields.

Once you’re done, hit send, and you’ll see the JSON response from the API if everything went well. The response should look like this:

POSTMAN window

That’s it! The API is working.

If you have problems connecting, you may need to disable SSL verification – see the connection issues section below.

401 Unauthorized

Your API keys or signature is wrong. Ensure that:

  • The user you generated API keys for actually has access to those resources.
  • The username when authenticating is your consumer key.
  • The password when authenticating is your consumer secret.
  • Make a new set of keys to be sure.

If your server utilizes FastCGI, check that your authorization headers are properly read.

Consumer key is missing

If you are receiving the 403 HTTP status, coupled with the lmfwc_rest_no_ssl_error error message, the plugin is refusing the request because you are not using a secure (SSL) connection. You can use the plugin settings to allow the REST API to function on insecure HTTP connections. To do so, go to License Manager > Settings

Do not disable this setting on a productive environment. Allowing the REST API to be used on insecure connections will expose your license keys to Man-in-the-Middle attacks.

2.Developer documentation #

2.1.List licenses #

Description

This route is used to retrieve all license keys from the database. Be very careful, if you do not need to use this API route in your productive environment then it is best to disable the route altogether via the settings page. The response contains an array of license key data objects.

Request URL

GET
/wp-json/lmfwc/v2/licenses

Response example

{
  "success": true,
  "data": [
    {
      "id": "2",
      "orderId": null,
      "productId": "1777",
      "licenseKey": "FOO-FIGHTERS",
      "expiresAt": null,
      "validFor": "365",
      "source": "3",
      "status": "3",
      "timesActivated": null,
      "timesActivatedMax": "1",
      "createdAt": "2021-06-30 18:12:38",
      "createdBy": "1",
      "updatedAt": null,
      "updatedBy": null
    },
    {
      "id": "3",
      "orderId": null,
      "productId": "1777",
      "licenseKey": "THE-PRETENDER",
      "expiresAt": null,
      "validFor": "365",
      "source": "3",
      "status": "3",
      "timesActivated": null,
      "timesActivatedMax": "1",
      "createdAt": "2021-06-30 18:13:08",
      "createdBy": "1",
      "updatedAt": null,
      "updatedBy": null
    }
  ]
}

2.2.Retrieve a license #

Description

Retrieves a single license key by the license key string itself. The response contains the queried license key data object.

Request URL

GET
/wp-json/lmfwc/v2/licenses/{license_key}

Response example

 

{
  "success": true,
  "data": {
    "id": "2",
    "orderId": null,
    "productId": "1777",
    "licenseKey": "FOO-FIGHTERS",
    "expiresAt": null,
    "validFor": "365",
    "source": "3",
    "status": "3",
    "timesActivated": null,
    "timesActivatedMax": "1",
    "createdAt": "2021-06-30 18:12:38",
    "createdBy": "1",
    "updatedAt": null,
    "updatedBy": null
  }
}

2.3.Create a license #

Description

Creates a new license key with the given parameters from the request body. It is possible to leave out certain keys, or explicitly set them to “null”. The response will contain the newly created license key data object.

Request URL

POST
/wp-json/lmfwc/v2/licenses

Request headers

 

Content-Type: application/json

Request body

{
  "product_id": "1777",
  "license_key": "ECHOES-SILENCE-PATIENCE-AND-GRACE",
  "valid_for": "365",
  "status": "active",
  "times_activated_max": 1
}

Response example

{
  "success": true,
  "data": {
    "id": "4",
    "orderId": null,
    "productId": "1777",
    "licenseKey": "ECHOES-SILENCE-PATIENCE-AND-GRACE",
    "expiresAt": null,
    "validFor": "365",
    "source": "3",
    "status": "3",
    "timesActivated": null,
    "timesActivatedMax": "1",
    "createdAt": "2021-06-30 18:14:42",
    "createdBy": "1",
    "updatedAt": null,
    "updatedBy": null
  }
}

2.4.Update a license #

Description

Performs an update of the license key. The request will not update key values that aren’t present in the request body, however if they are present their value will be updated, even if it’s a null value. The request will return the updated license key data object.

Request URL

PUT
/wp-json/lmfwc/v2/licenses/{license_key}

Request headers

 

Content-Type: application/json

Request body

{
  "order_id": null,
  "product_id": null,
  "license_key": "THE-PRETENDER",
  "valid_for": null,
  "times_activated_max": 999,
  "status": "ACTIVE"
}

Response example

{
  "success": true,
  "data": {
    "id": "2",
    "orderId": null,
    "productId": null,
    "licenseKey": "THE-PRETENDER",
    "expiresAt": null,
    "validFor": null,
    "source": "3",
    "status": "3",
    "timesActivated": null,
    "timesActivatedMax": "999",
    "createdAt": "2021-06-30 18:12:38",
    "createdBy": "1",
    "updatedAt": "2021-06-30 18:15:14",
    "updatedBy": "1"
  }
}

2.5.Activate a license #

Description

Increments the times_activated value by one (1). The plugin will check if there is a times_activated_max value, if there is and if the times_activated value has not reached the limit set by times_activated_max, then the times_activated will be incremented by 1, and the updated license key data object will be returned.

Request URL

GET
/wp-json/lmfwc/v2/licenses/activate/{license_key}

Response example

{
  "success": true,
  "data": {
    "id": "2",
    "orderId": null,
    "productId": null,
    "licenseKey": "THE-PRETENDER",
    "expiresAt": null,
    "validFor": null,
    "source": "3",
    "status": "3",
    "timesActivated": "1",
    "timesActivatedMax": "999",
    "createdAt": "2021-06-30 18:12:38",
    "createdBy": "1",
    "updatedAt": "2021-06-30 18:19:23",
    "updatedBy": "1"
  }
}

2.6.Deactivate a license #

Description

Decreases the times_activated value by one (1). The plugin will check if the current value of times_activated is one (1) or greater. If so, the plugin will decrement the times_activated value by one, and return the updated license. It is not possible to deactivate a license key whose times_activated is null or already zero (0). The response will contain the updated license key data object.

Request URL

GET
/wp-json/lmfwc/v2/licenses/deactivate/{license_key}

Response example

{
  "success": true,
  "data": {
    "id": "2",
    "orderId": null,
    "productId": null,
    "licenseKey": "THE-PRETENDER",
    "expiresAt": null,
    "validFor": null,
    "source": "3",
    "status": "3",
    "timesActivated": "0",
    "timesActivatedMax": "999",
    "createdAt": "2021-06-30 18:12:38",
    "createdBy": "1",
    "updatedAt": "2021-06-30 18:19:39",
    "updatedBy": "1"
  }
}

2.7.Validate a license #

Description

Checks the current activation status of a license key. The response will contain the number of activations, the maximum activation count, and the remaining activations.

Request URL

GET
/wp-json/lmfwc/v2/licenses/validate/{license_key}

Response example

{
  "success": true,
  "data": {
    "timesActivated": 0,
    "timesActivatedMax": 999,
    "remainingActivations": 999
  }
}

2.8.List all generators #

Description

Retrieves all currently available generators. The response will contain an array of generator data objects.

Request URL

GET
/wp-json/lmfwc/v2/generators

Response example

{
  "success": true,
  "data": [
    {
      "id": "1",
      "name": "My first generator",
      "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
      "chunks": "3",
      "chunkLength": "6",
      "timesActivatedMax": "1",
      "separator": "-",
      "prefix": null,
      "suffix": null,
      "expiresIn": null,
      "createdAt": "2021-06-30 18:09:06",
      "createdBy": "1",
      "updatedAt": null,
      "updatedBy": null
    },
    {
      "id": "2",
      "name": "My second generator",
      "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
      "chunks": "3",
      "chunkLength": "6",
      "timesActivatedMax": "1",
      "separator": "-",
      "prefix": null,
      "suffix": null,
      "expiresIn": null,
      "createdAt": "2021-06-30 18:11:38",
      "createdBy": "1",
      "updatedAt": null,
      "updatedBy": null
    }
  ]
}

2.9.Retrieve a generator #

Description

Retrieves a single generator by its ID. The response contains the generator data object.

Request URL

GET
/wp-json/lmfwc/v2/generators/{generator_id}

Response example

{
  "success": true,
  "data": {
    "id": "2",
    "name": "My second generator",
    "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
    "chunks": "3",
    "chunkLength": "6",
    "timesActivatedMax": "1",
    "separator": "-",
    "prefix": null,
    "suffix": null,
    "expiresIn": null,
    "createdAt": "2021-06-30 18:11:38",
    "createdBy": "1",
    "updatedAt": null,
    "updatedBy": null
  }
}

2.10.Create a generator #

Description

Creates a new generator. The response contains the newly created generator data object.

Request URL

POST
/wp-json/lmfwc/v2/generators

Request headers

Content-Type: application/json

Request body

{
  "name": "Generator created by the API",
  "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
  "chunks": 5,
  "chunk_length": 5,
  "times_activated_max": 2,
  "separator": "-",
  "prefix": null,
  "suffix": null,
  "expires_in": null
}

Response example

{
  "success": true,
  "data": {
    "id": "6",
    "name": "Generator created by the API",
    "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
    "chunks": "5",
    "chunkLength": "5",
    "timesActivatedMax": "2",
    "separator": "-",
    "prefix": null,
    "suffix": null,
    "expiresIn": null,
    "createdAt": "2021-06-30 20:28:46",
    "createdBy": "1",
    "updatedAt": null,
    "updatedBy": null
  }
}

2.11.Update a generator #

Description

Updates a generator by its ID. The response contains the updated generator data object.

Request URL

PUT
/wp-json/lmfwc/v2/generators/{generator_id}

Request headers

Content-Type: application/json

Request Body

{
  "name": "Generator edited by the API",
  "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
  "chunks": "5",
  "chunk_length": "6",
  "times_activated_max": 1,
  "separator": "+",
  "prefix": "API-",
  "suffix": "-GEN",
  "expires_in": 730
}

Response example

{
  "success": true,
  "data": {
    "id": "4",
    "name": "Generator edited by the API",
    "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
    "chunks": "5",
    "chunkLength": "6",
    "timesActivatedMax": "1",
    "separator": "+",
    "prefix": "API-",
    "suffix": "-GEN",
    "expiresIn": "730",
    "createdAt": "2021-06-30 18:21:51",
    "createdBy": "1",
    "updatedAt": "2021-06-30 18:22:37",
    "updatedBy": "1"
  }
}

3.Libraries #

3.1.Node.js library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

 

3.2.Python library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

3.3.PHP library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

Author GitHub Website
otakupahp otakupahp/sdk-license-manager-for-woocommerce otakupahp.com
TheWebSolver TheWebSolver/tws-license-manager-client thewebsolver.com
TheWebSolver TheWebSolver/tws-license-manager-server thewebsolver.com

3.4.Ruby library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

3.5..NET libraries #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

Author GitHub Website
stigzler stigzler/stigzler.support.wcLicenseManagerNet MagoArcade.org

3.6.C library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

3.7.C# library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

3.8.C++ library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

3.9.Golang library #

If you would like to submit your own library, please email us at libraries@licensemanager.at. We will feature your library here along with a link to your website.

No libraries available yet, but what about that yeet?

Help Guide Powered by Documentor
Suggest Edit
Scroll to Top