Skip to content

License

Branko Conjic edited this page Feb 8, 2024 · 2 revisions

activateLicense

Activate a license key and receive an instance ID in return.

Usage

import { type ActivateLicense, activateLicense } from '@lemonsqueezy/lemonsqueezy.js';

const licenseKey = '38b1460a-5104-4067-a91d-77b872934d51';
const { statusCode, error, data } = await activateLicense(licenseKey, 'Test');

Type Declarations

/**
 * Activate a license key.
 *
 * @param licenseKey The license key.
 * @param instanceName A label for the new instance to identify it in Lemon Squeezy.
 * @returns A response object containing `activated`, `error`, `license_key`, `instance`, `meta`.
 */
declare function activateLicense(licenseKey: string, instanceName: string): Promise<FetchResponse<ActivateLicense>>;

Returns

{
	statusCode: number | null;
	error: Error | null;
	data: ActivateLicense | null;
}

Source

Source ~ Type ~ Test

validateLicense

Validate a license key or license key instance.

Usage

import { type ValidateLicense, validateLicense } from '@lemonsqueezy/lemonsqueezy.js';

const licenseKey = '38b1460a-5104-4067-a91d-77b872934d51';
const { statusCode, error, data } = await validateLicense(licenseKey);

With the optional instanceId:

import { type ValidateLicense, validateLicense } from '@lemonsqueezy/lemonsqueezy.js';

const licenseKey = '38b1460a-5104-4067-a91d-77b872934d51';
const instanceId = '47596ad9-a811-4ebf-ac8a-03fc7b6d2a17';
const { statusCode, error, data } = await validateLicense(licenseKey, instanceId);

Type Declarations

/**
 * Validate a license key or license key instance.
 *
 * @param licenseKey The license key.
 * @param [instanceId] (Optional) If included, validate a license key instance, otherwise a license key. If no `instance_id` is provided, the response will contain "instance": `null`.
 * @returns A response object containing `valid`, `error`, `license_key`, `instance`, `meta`.
 */
declare function validateLicense(licenseKey: string, instanceId?: string): Promise<FetchResponse<ValidateLicense>>;

Returns

{
	statusCode: number | null;
	error: Error | null;
	data: ValidateLicense | null;
}

Source

Source ~ Type ~ Test

deactivateLicense

Deactivate a license key instance.

Usage

import { type DeactivateLicense, deactivateLicense } from '@lemonsqueezy/lemonsqueezy.js';

const licenseKey = '38b1460a-5104-4067-a91d-77b872934d51';
const instanceId = '47596ad9-a811-4ebf-ac8a-03fc7b6d2a17';
const { statusCode, error, data } = await deactivateLicense(licenseKey, instanceId);

Type Declarations

/**
 * Deactivate a license key instance.
 *
 * @param licenseKey The license key.
 * @param instanceId The instance ID returned when activating a license key.
 * @returns A response object containing `deactivated`, `error`, `license_key`, `meta`.
 */
declare function deactivateLicense(licenseKey: string, instanceId: string): Promise<FetchResponse<DeactivateLicense>>;

Returns

{
	statusCode: number | null;
	error: Error | null;
	data: DeactivateLicense | null;
}

Source

Source ~ Type ~ Test

Clone this wiki locally