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

Warning: product released on a version before 1.10.0? Do not just rebuild with the new library. The default Host ID scheme is V2, so every device’s host id changes and all existing activations would have to re-activate. Keep the default and call migrateHostIdV1toV2() on every start instead: see Move a Released Product to Host ID V2.

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-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 because the serial itself cannot be used (for example SERIAL_INVALID), the library deletes the serial and the license file from 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: renew with the stored serial first,
    // see Typical Application Flow below
}

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();

// Dealer-distributed licenses also carry the issuing dealer's name
std::string dealerName = pValidator->getDealerName(); // empty string when the license has no dealer

getDealerName() is available in the C++ Client Library 1.9.0 and later, and is populated by both the online and offline flows. For a license that was not distributed through a dealer, it returns an empty string.

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. On every launch, check the stored license first. If it is not valid, renew with the stored serial before asking the user for anything; only ask for a serial when there is no usable one on the device:

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

// 2. Check the stored license
Keyzy::LicenseStatus status = pValidator->validateOffline();

if (status == Keyzy::LicenseStatus::VALID)
{
    // License is valid. Renew silently: refreshes if online, ignored if offline
    pActivator->activateSemiOnline();
}
else
{
    // 3. Not valid: renew with the stored serial first, without asking the user
    status = pActivator->activateSemiOnline();

    // 4. Ask for a serial only when there is no usable one on the device
    if (status == Keyzy::LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST ||
        status == Keyzy::LicenseStatus::SERIAL_INVALID ||
        status == Keyzy::LicenseStatus::ACTIVATION_DEACTIVATED)
    {
        std::string serial = getSerialFromUser(); // your UI code
        status = pActivator->activateSemiOnline(serial);
    }

    if (status != Keyzy::LicenseStatus::VALID)
    {
        // 5. Show a message that fits the status instead of the serial form:
        //    connection problems (CONNECTION_ERROR, NETWORK_*): ask the user to check the connection
        //    anything else: show the reason; the license comes back by itself once it is resolved
    }
}

Why not show the serial form as soon as the license is not valid? When the Offline License Life has run out, step 3 renews the license file and the user enters nothing. When the license is stopped for a reason that can be resolved, such as an expired subscription or a product switched off in the dashboard, entering the same serial again would not help; with SDK 1.10.1 and later the serial stays on the device, and the next launch after the cause is resolved renews the license by itself.

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