Semi-Online Activation

Semi-online activation is the most popular activation schema in the KEYZY C++ Client Library. It connects to the KEYZY server once to download an encrypted license file, then all subsequent validations happen locally on the device — no internet required.

This makes it ideal for desktop applications, audio plugins, and any software where users expect to work offline after initial activation.

Prerequisites

Setup

Create the activator and obtain the validator. These objects will be used throughout the activation and validation lifecycle:

#include "KeyzyLicenseActivator.h"

Keyzy::ProductData productData(
    "YOUR_APP_ID",
    "YOUR_API_KEY",
    "YOUR_PRODUCT_CODE",
    "YOUR_CRYPTION_KEY"
);

std::unique_ptr<Keyzy::KeyzyLicenseActivator> pActivator =
    std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);

std::shared_ptr<Keyzy::KeyzyLicenseValidator> pValidator =
    pActivator->getLicenseValidator();

Keep pActivator alive for the lifetime of your application. The validator references internal state owned by the activator.

Activate with a Serial Number

When a user enters their serial number for the first time, call activateSemiOnline() with the serial. The library connects to the KEYZY server, downloads an encrypted license file, validates it, and stores both the serial and the license file on the device:

std::string serialNumber = "XXXX-XXXX-XXXX-XXXX"; // entered by the user

Keyzy::LicenseStatus status = pActivator->activateSemiOnline(serialNumber);

if (status == Keyzy::LicenseStatus::VALID)
{
    // License activated — unlock your application
}
else
{
    // Activation failed — see Error Handling section below
}

If activation fails, the library automatically cleans up — no serial or license file remains on the device.

Validate Offline

Once activated, validate the license on every subsequent launch. Semi-online licenses use offline validation — the stored license file is checked locally without contacting the server:

Keyzy::LicenseStatus status = pValidator->validateOffline();

if (status == Keyzy::LicenseStatus::VALID)
{
    // License is valid — unlock your application
}
else
{
    // License is not valid — show the activation form
}

Offline License Life and Renewal

You can set an Offline License Life for your SKU in the KEYZY dashboard. This defines how long the downloaded license file remains valid (e.g. 30 days). After that period, validateOffline() will no longer return VALID, and the license file needs to be renewed.

To renew, call activateSemiOnline() without a serial number. The library uses the stored serial to download a fresh license file, resetting the timer:

// Renew the license file — uses the stored serial, no user input needed
Keyzy::LicenseStatus status = pActivator->activateSemiOnline();

Each successful call resets the Offline License Life timer. For example, if you set it to 30 days, your application should call this at least once every 30 days while the user has internet access.

Tip: A good pattern is to attempt silent renewal each time your application launches. If the user is online, the license file gets refreshed. If offline, the existing file continues to work until it expires.

Reading License Details

After a successful activation or validation, you can retrieve information about the license from the validator:

std::string licensee  = pValidator->getLicenseeName();
std::string email     = pValidator->getLicenseeEmail();
std::string sku       = pValidator->getSku();
std::string version   = pValidator->getVersion();
std::string type      = pValidator->getLicenseType();
std::string info      = pValidator->getInfo();

For subscription and trial licenses, you can also read time-related details:

std::int64_t  startTime = pValidator->getStartTime();
std::int64_t  endTime   = pValidator->getEndTime();
std::uint64_t daysLeft  = pValidator->getDaysLeft();
std::uint64_t daysTotal = pValidator->getDaysTotal();

Use these values to display remaining days or expiration warnings to your users.

Deactivation

To deactivate a semi-online license, call deactivateSemiOnline(). This contacts the KEYZY server to release the activation slot and deletes the local license file and serial number:

Keyzy::LicenseStatus status = pActivator->deactivateSemiOnline();

if (status == Keyzy::LicenseStatus::ACTIVATION_DELETED)
{
    // License deactivated — the user can activate on another device
}

Deactivation requires an internet connection since it needs to notify the KEYZY server.

Typical Application Flow

Here’s how a typical application uses semi-online activation:

// 1. Create the activator and validator (once, at startup)
auto pActivator = std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);
auto pValidator = pActivator->getLicenseValidator();

// 2. Try to validate the existing license
Keyzy::LicenseStatus status = pValidator->validateOffline();

if (status == Keyzy::LicenseStatus::VALID)
{
    // License is valid — optionally try a silent renewal
    pActivator->activateSemiOnline(); // refresh if online, ignore if offline
}
else
{
    // No valid license — show the activation form
    std::string serial = getSerialFromUser(); // your UI code
    status = pActivator->activateSemiOnline(serial);

    if (status != Keyzy::LicenseStatus::VALID)
    {
        // Show error to the user
    }
}

Error Handling

All activation and validation methods return a Keyzy::LicenseStatus enum. The most common values for semi-online activation are SERIAL_INVALID, REACHED_MAX_NUMBER_OF_HOST, CONNECTION_ERROR, and SUBSCRIPTION_LICENSE_EXPIRED.

For the complete list of all status codes and their descriptions, see the C++ License Status Codes reference.

Next Steps