SDKs
...
Licensing Scenarios
License Type Options

Consumption-Based

12min

Consumption licenses are ideal for applications where usage is metered based on a chosen metric, for example the number of API calls, data transfer volume, or any other measurable unit.

These licenses allow developers to set usage limits and track consumption, ensuring fair and flexible licensing for their users.

Prerequisites

  1. Completed the Getting Started Tutorial, including:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Activated a license of any type.

Implementing a Consumption License



Configuring a Consumption License
Configuring a Consumption License


When granting a license, choose the "consumption" type as the preferred option. The key parameters associated with this type are as follows:

  1. Max Consumption: This parameter specifies the upper limit for the license usage, defining the maximum number of permitted uses.
  2. Allow Overages: By using this parameter, the software vendor can determine whether to block any additional usage beyond the maximum consumption limit. This can be further configured to allow a limited number of over usages or to have no restrictions (unlimited) on overages.
  3. Reset Consumption: This parameter facilitates periodic resetting of the available usage count back to the value provided in the "Max Consumption" field. The reset period can be set to daily, weekly, monthly, or annually, as per the vendor's requirements.

Obtaining Maximum and Total Consumption

maxConsumption() defines the upper limit or cap on the license usage, indicating the maximum number of allowed usages for the licensed product or service. This parameter ensures that users do not exceed a predetermined threshold, enabling software vendors to control and manage the license's usage scope. This method is shown below:

C++
Swift
C#
Python


On the other hand, totalConsumption() refers to the actual number of times the license has been utilized by the end-users. Monitoring the total consumption is crucial for both software vendors and users, as it provides insights into the software's popularity and usage patterns.

C++
Swift
C#
Python


Adding and Synchronizing Consumption

The function named updateConsumption(), shown below, serves to modify the license consumptions based on the value specified in the first parameter.

C++
Swift
C#
Python


By default, the value is set to 1, but it can be increased or decreased as needed.

Additionally, the function allows users to control whether the updated license information should be saved to a file or not, depending on the saveLicense boolean parameter.

If saveLicense is set to true, the changes will be saved to a file, ensuring persistent license data.

NotEnoughConsumptionException: The consumption license or feature has depleted its available resources.

Seen below, the syncConsumption() function is responsible for synchronizing the consumption license values with the server.

C++
Swift
C#
Python


This synchronization guarantees that the server is up-to-date with the latest accurate consumption-based data.

The function accepts an optional parameter, requestOverage, which allows users to request consumption overages if necessary.

If no specific overage value is provided, the function will not request any particular overage amount from the server during synchronization.

Unlimited Consumption

In an unlimited consumption model, users are granted access to the software with unrestricted usage rights.

There are no predefined limits or quotas on the number of times the software can be used or the features that can be accessed.

Users can utilize the software freely and continuously, without any concerns about overages or exceeding usage limits.

Whether this is enabled can be checked within the SDK by using the following Boolean method:

C++
Swift
C#
Python


Consumption Overages

In a consumption license, an overage refers to the additional usage beyond the predefined limits or allocated resources set in the license agreement.

Max overages refers to the maximum allowable number of additional usages beyond the defined consumption limit in a given period. Max overages can be accessed by using:

C++
Swift
C#
Python


Note: In the case of unlimited overages, maxOverages() returns the maximum possible value.

In addition, developers have the option to verify whether overages are permitted by utilizing:

C++
Swift
C#
Python


Consumption Reset and Period Management

Consumption licenses can be rest on regular intervals, whether it be daily, weekly, monthly, or annually, as per the vendor's requirements. This consumption reset sets the totalConsumption() to equal maxConsumption() as previously defined.

The period of time after which the consumption is reset can be accessed, in the form of a ConsumptionPeriod object using the following method:

C++
Swift
C#
Python


Developers can also check for whether this periodic reset is enabled, by using the isResetConsumptionEnabled() method on a License object:

C++
Swift
C#
Python




Updated 16 Oct 2024
Doc contributor
Doc contributor
Doc contributor
Did this page help you?