License Manager for WooCommerce

Easily sell and manage software license keys through your shop

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

Headers

Content-Type	application/json

Body

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

Request Example (PHP)

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{host}}/wp-json/lmfwc/v2/licenses?consumer_key={{consumer_key}}&consumer_secret={{consumer_secret}}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{
	"product_id": "1777",
	"license_key": "ECHOES-SILENCE-PATIENCE-AND-GRACE",
	"valid_for": "365",
	"status": "active",
	"times_activated_max": 1
}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

?>

Response

{
  "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": "2019-09-04 18:14:42",
    "createdBy": "1",
    "updatedAt": null,
    "updatedBy": null
  }
}