License Manager for WooCommerce

Easily sell and manage software license keys through your shop

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/THE-PRETENDER

Body

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

Request Example (PHP)

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{host}}/wp-json/lmfwc/v2/licenses/FOO-FIGHTERS?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 => "PUT",
  CURLOPT_POSTFIELDS =>"{
	"order_id": null,
	"product_id": null,
	"license_key": "THE-PRETENDER",
	"valid_for": null,
	"times_activated_max": 999,
	"status": "ACTIVE"
}",
  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": "2",
    "orderId": null,
    "productId": null,
    "licenseKey": "THE-PRETENDER",
    "expiresAt": null,
    "validFor": null,
    "source": "3",
    "status": "3",
    "timesActivated": null,
    "timesActivatedMax": "999",
    "createdAt": "2019-09-04 18:12:38",
    "createdBy": "1",
    "updatedAt": "2019-09-04 18:15:14",
    "updatedBy": "1"
  }
}