Code Example

$curl = curl_init();

$endpoint = '{{domain}}/wp-json/wclm/v3/get-current-user-licenses';
$parameters = array();

curl_setopt_array($curl, array(
     CURLOPT_URL => $endpoint,
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_MAXREDIRS => 10,
     CURLOPT_TIMEOUT => 0,
     CURLOPT_FOLLOWLOCATION => true,
     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
     CURLOPT_CUSTOMREQUEST => 'POST',
     CURLOPT_POSTFIELDS => $parameters,
     CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
     CURLOPT_SSL_VERIFYPEER => false,
     CURLOPT_HTTPHEADER => array(
         // Authenticated user token
         'Authorization: Bearer {{User Token}}'
     )
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

API Responses

The API returns all license keys purchased by the currently authenticated user.
The license keys need to have a valid order ID belonging to the authenticated user. You will have to keep this in mind when manually editing the license keys.

If the user doesn’t have any license keys, the API will return an empty JSON Array.

{
  "response": {
    "licenses": [
      {
        "license_id": "497",
        "product_id": "31",
        "variation_id": "0",
        "license_key": "204E-6914-EA60-185E",
        "image_license_key": null,
        "license_status": "sold",
        "owner_first_name": "Test",
        "owner_last_name": "Test",
        "owner_email_address": "contact@example.com",
        "activation_date": null,
        "creation_date": "2021-04-23",
        "expiration_date": "2021-05-23",
        "valid": "30",
        "order_id": "270",
        "sold_date": "2021-04-23",
        "product_name": "Product name",
        "variation_name": "Variation name",
        "delivery_limit": "0",
        "remaining_delivery_times": "0",
        "activation_limit": "1",
        "remaining_activations": "1",
        "device_ids": [
          "domain.ltd",
          "domain2.ltd"
        ],
        "license_key_meta": [
          {
            "id": "15",
            "meta_key": "example_key_1",
            "meta_value": "example value 1"
          },
          {
            "id": "16",
            "meta_key": "example_key_2",
            "meta_value": "example value 2"
          }
        ]
      },
      {
        "license_id": "496",
        "product_id": "31",
        "variation_id": "0",
        "license_key": "812A-434E-8805-F24F",
        "image_license_key": null,
        "license_status": "sold",
        "owner_first_name": "Test",
        "owner_last_name": "Test",
        "owner_email_address": "contact@example.com",
        "activation_date": null,
        "creation_date": "2021-04-23",
        "expiration_date": "2021-05-23",
        "valid": "30",
        "order_id": "270",
        "sold_date": "2021-04-23",
        "product_name": "Product name",
        "variation_name": "Variation name",
        "delivery_limit": "0",
        "remaining_delivery_times": "0",
        "activation_limit": "1",
        "remaining_activations": "1",
        "device_ids": [],
        "license_key_meta": []
      },
      {
        "license_id": "495",
        "product_id": "31",
        "variation_id": "0",
        "license_key": "2B9D-1F8A-A36B-582D",
        "image_license_key": null,
        "license_status": "sold",
        "owner_first_name": "Test",
        "owner_last_name": "Test",
        "owner_email_address": "contact@example.com",
        "activation_date": null,
        "creation_date": "2021-04-23",
        "expiration_date": "2021-05-23",
        "valid": "30",
        "order_id": "270",
        "sold_date": "2021-04-23",
        "product_name": "Product name",
        "variation_name": "Variation name",
        "delivery_limit": "0",
        "remaining_delivery_times": "0",
        "activation_limit": "1",
        "remaining_activations": "1",
        "device_ids": [],
        "license_key_meta": []
      }
    ],
    "api_timestamp": 'current timestamp'
  },
  "signature": "Signature or OpenSSL error"
}

The license status returned by this endpoint is as-is in the database(expiration status is not calculated based on the expiration date). Custom license statuses set using the API can be accessed using this endpoint.

It is recommended to set custom data as meta keys instead; the plugin can overwrite the license status at any time if you have the auto-expire option enabled.

WordPress’s built-in REST API responses.

{
    "code": "rest_forbidden",
    "message": "Sorry, you are not allowed to do that.",
    "data": {
        "status": 403
    }
}