Back to Docs

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:

  1. /wcsn/validate
  2. /wcsn/activate 
  3. /wcsn/deactivate
  4. /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:

ParameterTypeRequired/ OptionalDescription
product_idNumberRequiredThe ID of the product to which the serial key is assigned.
serial_keyStringRequiredThe serial key that you want to validate.
emailstringBothIf you enable the duplicate key feature then it is a required field. If a duplicate key is not enabled then it will not required.
instancestringOptionalInstance 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.
platformstringOptionalThe 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:

ParameterTypeDescription
codeStringThe response code. If the serial key is valid, the code will be “key_valid”.
messageStringThe response message. If the serial key is valid, the message will be “Serial key is valid”.
activation_limitNumberThe activation limit for the serial key.
activation_countNumberThe number of activations for the serial key.
activations_leftNumberThe number of activations left for the serial key.
expire_dateNumberThe expiration date for the serial key.
statusStringThe status of the serial key.
product_idNumberThe ID of the product to which the serial key is assigned.
productStringThe name of the product for which the serial key is valid.
activationsStringThe 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:

ParameterTypeRequired/ OptionalDescription
product_idNumberRequiredThe ID of the product to which the serial key is assigned.
serial_keyStringRequiredThe serial key is to validate.
instanceStringRequiredInstance 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.
platformStringoptionalOptional. The platform on which the serial key is used. For example, “Windows” or “Mac”.
emailStringoptionalThe 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:

ParameterTypeDescription
codeStringThe response code. “key_activated” or “key_deactivated” if the request was successful. “invalid_key” or “invalid_request” if the request was not successful.
messageStringThe response message. If the serial key is valid, the message will be “Serial key is valid”.
activatedNumberActivated when the request is successful.
activation_limitNumberThe number of activations for the serial key.
activation_countNumberThe number of activations left for the serial key.
activations_leftNumberThe expiration date for the serial key.
expire_dateStringThe expiration date for the serial key.
expires_atNumberThe expiration date for the serial key in Unix timestamp format.
product_idStringThe ID of the product to which the serial key is assigned.
productStringThe name of the product for which the serial key is valid.
activationsStringThe 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:

ParameterTypeRequired/ OptionalDescription
product_idNumberRequiredThe ID of the product to which the serial key is assigned.
serial_keyStringRequiredThe serial key is to validate.
instanceStringRequiredInstance 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.
platformStringOptionalOptional. The platform on which the serial key is used. For example, “Windows” or “Mac”.
emailStringOptionalThe 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:

ParameterTypeDescription
codeStringThe response code. “key_activated” or “key_deactivated” if the request was successful. “invalid_key” or “invalid_request” if the request was not successful.
messageStringThe response message. If the serial key is valid, the message will be “Serial key is valid”.
deactivatedNumberDeactivated when the request is successful.
activation_limitNumberThe number of activations for the serial key.
activation_countNumberThe number of activations left for the serial key.
activations_leftNumberThe expiration date for the serial key.
expire_dateStringThe expiration date for the serial key.
expires_atNumberThe expiration date for the serial key in Unix timestamp format.
product_idStringThe ID of the product to which the serial key is assigned.
productStringThe name of the product for which the serial key is valid.
activationsStringThe 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:

ParameterTypeRequired/ OptionalDescription
product_idNumberRequiredThe ID of the product to which the serial key is assigned.
serial_keyStringRequiredThe serial key is to validate.
emailStringOptionalThe 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:

ParameterTypeDescription
codeStringThe response code is “version_checked” if the request was successful.
product_idNumberThe product ID is being shown.
productStringThe product name is being shown.
versionStringThe version information is being shown.