Getting Started with REST API
Introduction:
The WC Serial Numbers plugin API provides endpoints to facilitate serial number validation and management within the WooCommerce platform. This documentation outlines the available endpoints and their functionalities.
The WC Serial Numbers plugin API provides endpoints to facilitate serial number validation and management within the WooCommerce platform. This documentation outlines the available endpoints and their functionalities.
Base URL:
https://your-domain.com/wp-json/wcsn
Endpoints:
There are four Endpoints:
- /wcsn/validate
- /wcsn/activate
- /wcsn/deactivate
- /wcsn/version_check
Now let’s see the details about those endpoints.
1. Validate Serial Number:
Endpoint: /wcsn/validate
Method: GET
Description: This function verifies a license key’s current activation state. The response will include the number of activations, the maximum activation count, and the remaining activations.
How to make an API call:
https://your-domain.com/wp-json/wcsn/validate?product_id={id}&serial_key={key}&email={email}&instance={instance}&platform={platform}
Request Parameters:
The request must contain the following parameters:
Parameter | Type | Required/ Optional | Description |
product_id | Number | Required | The ID of the product to which the serial key is assigned. |
serial_key | String | Required | The serial key that you want to validate. |
string | Both | If you enable the duplicate key feature then it is a required field. If a duplicate key is not enabled then it will not required. | |
instance | string | Optional | Instance is the base of activation and deactivation. It is a unique identifier for the installation. For example, you can use the domain name of the website. |
platform | string | Optional | The platform on which the serial key is used. For example, “Windows” or “Mac”. |
Example of API call:
https://example.com/wp-json/wcsn/validate?product_id=26&serial_key=bb bb bb ss&[email protected]&instance=12345&platform=windows
Example of API response:
{
"code": "key_valid",
"message": "Serial key is valid.",
"activation_limit": 0,
"activation_count": 1,
"activations_left": 9999,
"expire_date": "",
"status": "active",
"product_id": 26,
"product": "(#26) Single (woo-single)",
"activations": [
{
"id": 7,
"serial_id": 70,
"instance": "12345",
"platform": "windows",
"activation_time": "2024-05-13 08:34:38"
}
],
"remaining": 9999
}
Fields in API response:
The API will return a JSON response with the following parameters:
Parameter | Type | Description |
code | String | The response code. If the serial key is valid, the code will be “key_valid”. |
message | String | The response message. If the serial key is valid, the message will be “Serial key is valid”. |
activation_limit | Number | The activation limit for the serial key. |
activation_count | Number | The number of activations for the serial key. |
activations_left | Number | The number of activations left for the serial key. |
expire_date | Number | The expiration date for the serial key. |
status | String | The status of the serial key. |
product_id | Number | The ID of the product to which the serial key is assigned. |
product | String | The name of the product for which the serial key is valid. |
activations | String | The list of activations for the serial key. |
2. Active Serial Number:
Endpoint: /wcsn/activate
Method: GET
Description: This function activates a license key.
How to make an API call:
https://yourdomain.com/wp-json/wcsn/activate?product_id={id}&serial_key={key}&email={email}&instance={instance}&platform={platform}
Request Parameters:
The request must contain the following parameters:
Parameter | Type | Required/ Optional | Description |
product_id | Number | Required | The ID of the product to which the serial key is assigned. |
serial_key | String | Required | The serial key is to validate. |
instance | String | Required | Instance is the base of activation and deactivation. It is a unique identifier for the installation. For example, you can use the domain name of the website. |
platform | String | optional | Optional. The platform on which the serial key is used. For example, “Windows” or “Mac”. |
String | optional | The API will verify that the serial number is associated with the given email address. |
Example of API call:
https://example.com/wp-json/wcsn/activate?product_id=26&serial_key= bb ss bb ss&[email protected]&instance=123s45&platform=windows
Example of API response:
{
"code": "key_activated",
"message": "Serial key is activated.",
"activated": true,
"instance": "123s45",
"platform": "windows",
"activation_limit": 0,
"activation_count": 3,
"activations_left": 9999,
"expires_at": "",
"product_id": 26,
"product": "(#26) Single (woo-single)",
"activations": [
{
"id": 7,
"serial_id": 70,
"instance": "12345",
"platform": "windows",
"activation_time": "2024-05-13 08:34:38"
},
{
"id": 8,
"serial_id": 70,
"instance": "12345ww",
"platform": "",
"activation_time": "2024-05-13 09:36:59"
},
{
"id": 9,
"serial_id": 70,
"instance": "123s45",
"platform": "windows",
"activation_time": "2024-05-13 09:38:37"
}
],
"remaining": 9999
}
If the key is already activated:
{
"code": "instance_already_activated",
"message": "Instance is already activated.",
"data": {
"status": 400
}
}
Fields in API response:
The API will return a JSON response with the following parameters:
Parameter | Type | Description |
code | String | The response code. “key_activated” or “key_deactivated” if the request was successful. “invalid_key” or “invalid_request” if the request was not successful. |
message | String | The response message. If the serial key is valid, the message will be “Serial key is valid”. |
activated | Number | Activated when the request is successful. |
activation_limit | Number | The number of activations for the serial key. |
activation_count | Number | The number of activations left for the serial key. |
activations_left | Number | The expiration date for the serial key. |
expire_date | String | The expiration date for the serial key. |
expires_at | Number | The expiration date for the serial key in Unix timestamp format. |
product_id | String | The ID of the product to which the serial key is assigned. |
product | String | The name of the product for which the serial key is valid. |
activations | String | The list of activations for the serial key. |
3. Deactive Serial Number:
Endpoint: /wcsn/deactivate
Method: GET
Description: This function deactivated a license key’.
How to make an API call:
https://yourdomain.com/wp-json/wcsn/deactivate?product_id={id}&serial_key={key}&email={email}&instance={instance}&platform={platform}
Request Parameters:
The request must contain the following parameters:
Parameter | Type | Required/ Optional | Description |
product_id | Number | Required | The ID of the product to which the serial key is assigned. |
serial_key | String | Required | The serial key is to validate. |
instance | String | Required | Instance is the base of activation and deactivation. It is a unique identifier for the installation. For example, you can use the domain name of the website. |
platform | String | Optional | Optional. The platform on which the serial key is used. For example, “Windows” or “Mac”. |
String | Optional | The API will verify that the serial number is associated with the given email address. |
Example of API call:
https://example.com/wp-json/wcsn/deactivate?product_id=26&serial_key= bb ss bb ss&[email protected]&instance=123s45&platform=windows
Example of API response:
{
"code": "key_deactivated",
"message": "Serial key is deactivated.",
"deactivated": true,
"instance": "",
"activation_limit": 0,
"activation_count": 3,
"activations_left": 9999,
"expires_at": "",
"product_id": 26,
"product": "(#26) Single (woo-single)",
"activations": [
{
"id": 7,
"serial_id": 70,
"instance": "12345",
"platform": "windows",
"activation_time": "2024-05-13 08:34:38"
},
{
"id": 8,
"serial_id": 70,
"instance": "12345ww",
"platform": "",
"activation_time": "2024-05-13 09:36:59"
},
{
"id": 10,
"serial_id": 70,
"instance": "5f9ee326747b14efab4bddf47f24bbee",
"platform": "",
"activation_time": "2024-05-13 09:39:05"
}
],
"remaining": 9999
}
Fields in API response:
The API will return a JSON response with the following parameters:
Parameter | Type | Description |
code | String | The response code. “key_activated” or “key_deactivated” if the request was successful. “invalid_key” or “invalid_request” if the request was not successful. |
message | String | The response message. If the serial key is valid, the message will be “Serial key is valid”. |
deactivated | Number | Deactivated when the request is successful. |
activation_limit | Number | The number of activations for the serial key. |
activation_count | Number | The number of activations left for the serial key. |
activations_left | Number | The expiration date for the serial key. |
expire_date | String | The expiration date for the serial key. |
expires_at | Number | The expiration date for the serial key in Unix timestamp format. |
product_id | String | The ID of the product to which the serial key is assigned. |
product | String | The name of the product for which the serial key is valid. |
activations | String | The list of activations for the serial key. |
4. Check Version:
Endpoint: /wcsn/version_check
Method: GET
Description: This function checks the version.
How to make an API call:
https://yourdomain.com/wp-json/wcsn/version_check?product_id={id}&serial_key={key}&email={email}
Request Parameters:
The request must contain the following parameters:
Parameter | Type | Required/ Optional | Description |
product_id | Number | Required | The ID of the product to which the serial key is assigned. |
serial_key | String | Required | The serial key is to validate. |
String | Optional | The API will verify that the serial number is associated with the given email address. |
Example of API call:
https://example.com/wp-json/wcsn/version_check?product_id=26&serial_key=bb bb bb ss&[email protected]
Example of API response:
{
"code": "version_checked",
"product_id": 26,
"product": "(#26) Single (woo-single)",
"version": ""
}
Fields in API response:
The API will return a JSON response with the following parameters:
Parameter | Type | Description |
code | String | The response code is “version_checked” if the request was successful. |
product_id | Number | The product ID is being shown. |
product | String | The product name is being shown. |
version | String | The version information is being shown. |