Using WC Key Manager, you can easily verify whether a license key is valid or not. If you are selling software and want to validate a license is still valid after it has been activated.
Checking if a license is valid and not expired is very similar to activating a license key.
Validating a license key is a straightforward process. You need to send a GET/POST request to the Licensing API endpoint like this:
https://example.com?wckm-api=validate_key&key=YOUR_LICENSE
Parameters
Parameter | Description |
---|---|
key | The license key that you want to activate. |
label | The unique string to reference the activation. |
product_id | (Optional) The key will automatically detect the product ID if not provided. |
email | (Optional) The email address of the user who purchased the product. |
Example Response:
The response for this request will be a JSON object. If the license key is valid, the response will be:
{
"success": true,
"message": "Key is valid.",
"activation_limit": 0,
"activation_count": 0,
"activation_remaining": "unlimited",
"expires": "never",
"order_id": 139,
"customer_name": "Antoinette Mraz",
"customer_email": "[email protected]",
"checksum": "ab142974d13a28dc5da2321a705df0d6"
}
If you pass the label parameter, the API will validate the license key against the label and returns the status of that activation, the response will be:
{
"success": true,
"message": "Key is valid.",
"activation_limit": 0,
"activation_count": 0,
"activation_remaining": "unlimited",
"expires": "never",
"order_id": 139,
"customer_name": "Antoinette Mraz",
"customer_email": "[email protected]",
"checksum": "ec0728cdd0eac85ba65b3e13905233d9",
"label": "Hello",
"label_status": "inactive"
}
If the license is invalid, the response will be:
{
"success": false,
"error": "invalid_key",
"message": "Invalid key, please provide a valid key."
}
Possible errors:
Error | Description |
---|---|
invalid_key | When the key is empty or invalid. |
missing_label | When the label is empty or invalid. |
invalid_product | When the product ID provided but does not match with the key. |
invalid_email | When the email is provided but does not match with the key. |
expired | When the key is expired. |