Skip to content
LICENTIVO / INTEGRATION

Feature-based licensing with monthly metered usage limits

Control feature access and monthly usage limits in licensed software. Check permissions before execution, reserve and commit metered usage, and handle retries without consuming the same operation twice.

Feature workflow · all nine SDKsUpdated

Application scenario and acceptance checks

For a reporting app, let the basic tier view reports and let the professional tier export them. Configure a metered export feature with a monthly limit of 500. Verify the last permitted export and the next denied operation, plus retry recovery with the same operation ID. Customer feature usage is separate from your workspace API quota.

1. Configure the feature counter

Feature-based licensing applies entitlements at the operation itself. Enable the export feature and set a monthly quota of 500 uses, then choose whether the configured overage rule blocks or allows additional uses. A visible feature flag alone does not enforce that quota.

Feature counters belong to the customer's license. They are separate from the vendor workspace's device and API subscription quotas. Daily and monthly feature periods use UTC; a monthly period resets at the start of the next UTC calendar month.

2. Open one SDK client

Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.

For a normal entitlement use RunFeature. For a limited usage action use RunMeteredFeature. A successful local entitlement check does not prove that online quota remains.

3. Wrap the business action

Persist a unique job ID before calling the SDK. Reuse that ID when retrying the same business task. The SDK first reserves one use, then invokes the callback, then confirms successful work or cancels a known business failure.

Go · inside a function returning error
// client was opened once at application startup.
// jobID comes from your durable business task record.
jobID := os.Getenv("LICENTIVO_OPERATION_ID")
if jobID == "" {
    return fmt.Errorf("persist a unique task ID before exporting")
}
err := client.RunMeteredFeature(ctx, "export", 1, jobID, func() error {
    // Return success only after the output has been saved.
    return os.WriteFile("licensed-report.txt", []byte("Metered export\n"), 0600)
})
if err != nil {
    return err
}

4. Recover interrupted work

When a task is already recorded as successful, retrying its ID lets the SDK settle pending accounting without rerunning its callback. If the process died while the business callback was running, the SDK cannot know whether the external operation finished.

Inspect your saved business result. Call ResolveMeteredFeature(ctx, jobID, true) for confirmed success, or false for confirmed failure. This resolves accounting only. Never blindly repeat a payment, file delivery or other irreversible action.

The Go SDK 0.11.9 attempts to renew the reservation while the callback runs. The default hold is 15 minutes and the UTC quota reset still limits it. If renewal or settlement fails, recover from your saved business result. A deliberately new attempt after cancellation uses a new operation ID.

5. Verify counter behavior

  1. Start with a small test limit. A successful export should increase used by one.
  2. Make the callback return an error before completing work: its reservation should be canceled.
  3. Retry a successfully recorded job ID and confirm the callback is not repeated.
  4. Exhaust a blocked quota and confirm the callback does not run. Show a clear message with the next reset time.
  5. Simulate an interrupted task on your test environment and resolve it from the durable business record.

Common mistakes

Counter operations require connectivity. An offline cached license alone does not authorize an offline reserve or commit. Do not silently turn a denied metered action into an unmetered action.

A direct Consume call deducts immediately. Use the metered callback when usage should count only after business success. A network failure after work completes is an accounting recovery problem; do not assume the work failed.

Stable task IDs and SDK journals help retries; they do not replace your business transaction or durable result storage. Keep both the business result and the SDK's private cache available during recovery.

Configuration and next steps