Integrate license key validations to your premium software application


Introduction

UpdaterCloud provides public API endpoints that you can use to check the user's entered download key before saving it to database. If the download key is valid, your users will benefit of automatic updates. If the download key is not valid, you can point your users to your online shop, display a warning message, etc. Automatic updates won't be provided to users with invalid download keys.

Checking download keys

You can check the user provided download key by simply making a GET request to the public Check Download Key API endpoint. This endpoint can be used no matter if your product download keys are managed by UpdaterCloud, or you're using the Envato or Easy Digital Downloads integration. However, the responses will be slightly different depending on the service used.

{warning} Make sure to replace the {{SUBDOMAIN}} with your personal UpdaterCloud subdomain, the {{PRODUCT_ID}} with your UpdaterCloud product id and the {{DOWNLOAD_KEY}} with your customer's download key that you're trying to check.


// Initialize the CURL session
$ch = curl_init();

// Set options for CURL transfer
curl_setopt_array($ch, array(
    CURLOPT_URL => "https://@{{SUBDOMAIN}}.updatercloud.com/api/v1/products/@{{PRODUCT_ID}}/download-keys/check?download_key=@{{DOWNLOAD_KEY}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Accept: application/json"
    ),
));

// Perform the CURL request
$response = @curl_exec($ch);

// Close the CURL session and free all resources
curl_close($ch);

// Parse the response with warnings supressed
$body = @json_decode($response);

Sample success response (status code 200)

You'll get a success response if the download key is found. However, the download key may be valid or invalid. If the download key is invalid, the valid and message properties will reflect that. Also, the responses will be slightly different depending on the service used (e.g. the Envato and EDD responses won't have the activations property).

{
    "valid": true,
    "message": "Download key is valid.",
    "download_key": "X4F9Q-FK2XW-QATHJ-K9JXY-6TVX8",
    "product_id": "8fa6e6ec-6941-46b9-87df-7854a685b8d1",
    "expires_at": "2020-01-12 11:05:22"
    "activations": [
        {
            "id": "8fce54c8-5ca3-426d-b129-ff550c64e7a2",
            "domain": "example.com",
            "created_at": "2020-02-08 12:04:44"
        }
    ]
}

Sample error response (status code other than 200)

If the download key can't be found or is not for the requested product id, you'll get a 404 - Not Found response with an error message.

{
    "error": "Download key is invalid.",
}