# License API

Provides a direct interface to the [**LicenseSpring API**](https://docs.licensespring.com/license-api/). The LicenseAPI class encapsulates API calls, input checks, authentication and signature verification. Typescript definitions are provided for the arguments and return types of the class methods.

To import the LicenseAPI class use:

{% code title="example.js" %}

```javascript
const { LicenseAPI } = require('@licensespring/node-sdk');
```

{% endcode %}

#### Creating an instance

{% code title="example.js" %}

```javascript
const licenseAPI = new LicenseAPI({
  apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
  sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
  appName: 'js-sdk-test-1',
  appVersion: '0.0.1',
  /** NOTE: the following properties are set to their default values by the SDK and can be overriden manually: */
  // apiPath: 'http://api.dev.licensespring.com/api/v4',
  // publicKey: '...',
});
```

{% endcode %}

The constructor takes a single argument of the following type:

{% code title="types.ts" %}

```typescript
{
  /** your Licensespring API key */
  apiKey: string,
  /** your Licensespring API Shared key **/
  sharedKey: string,
  /** custom name for your application */
  appName: string,
  /** custom version string for your application */
  appVersion: string,
  /** your Air Gap Activation key (optional) */
  airGapKey?: string,
  /** override for License API url (default is https://api.licensespring.com/api/v4/) **/
  apiPath?: string,
  /** override for License API public key (default is pub key for api.licensespring.com) **/
  publicKey?: string,
  /** override for License File filename (default is "License") */
  filename?: string,
  /** override for License File path (default is current directory) */
  filePath?: string,
  /** override for License File encryption key */
  fileKey?: string,
  /** override for license grace period duration in hours (default is 24) */
  gracePeriod?: number,
  /** override for License File guard file (default is false) */
  isGuardFileEnabled?: boolean,
  /** override for Hardware ID calculation method (default is 0, for more info see "Hardware ID" section) */
  hardwareIDMethod?: number,
  /** a custom provided Hardware ID (overrides HWID calculation) */
  hardwareID?: string,
}
```

{% endcode %}

### API methods

For type declarations see [**Type Declarations**](https://www.npmjs.com/package/@licensespring/node-sdk#types).

#### Hardware ID

Generates a [**Hardware ID**](https://www.npmjs.com/package/@licensespring/node-sdk#hardware-id). This value is required for various API method calls.

If the optional argument is not provided, it defaults to the value set in the configuration object provided when instantiating the LicensespringAPI object. If no value was provided in the config object, it defaults to 0 (the default Hardware ID method).

{% code title="types.ts" %}

```typescript
getHardwareID(algorithm?: HardwareIdAlgorithm): string
```

{% endcode %}

#### Check License

See: [**Check License**](/license-api/license-check/check-license.md)

{% code title="types.ts" %}

```typescript
checkLicense(
  payload: CheckLicensePayload, 
  includeExpiredFeatures: boolean = false
): Promise<CheckLicenseResponse>

type CheckLicensePayload = ({
  username: string;
} | {
  license_key: string;
}) & {
  product: string;
  hardware_id: string;
  env: string | undefined;
  license_id: number | undefined;
  sdk_ver: string | undefined;
  app_ver: string | undefined;
  hostname: string | undefined;
  os_hostname: string | undefined;
  ip_local: string | undefined;
  mac_address: string | undefined;
  ip: string | undefined;
  os_ver: string | undefined;
  channel: string | undefined;
};

type CheckLicenseResponse = {
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  allow_offline_activation: boolean,
  can_borrow: boolean,
  custom_fields: CustomField[],
  customer: CustomerResponse,
  enable_maintenance_period: boolean,
  floating_timeout: number,
  floating_users?: number,
  grace_period: number | null,
  is_air_gapped: boolean,
  is_floating: boolean,
  is_floating_cloud: boolean,
  is_hardware_key_auth: boolean,
  license_key: string | undefined,
  license_template_id?: number,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users?: number,
  max_overages: number,
  max_transfers?: number,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  order_store_id?: string,
  prevent_vm: boolean,
  company: {
    id: number,
  },
  product_details?: ProductDetailsResponse,
  product_features: FeatureResponse[],
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null,
  is_trial: boolean,
  trial_days?: number,
  user?: LicenseUserResponse,
  license_type: LicenseTypes,
  allow_negative_consumptions?: boolean,
  allow_unlimited_consumptions?: boolean,
  consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
  max_consumptions?: number,
  reset_consumption?: boolean,
  total_consumptions?: number,
  borrowed_until: string | null,
  floating_in_use_devices?: number,
  is_borrowed: boolean,
  is_expired: boolean,
  license_active: boolean,
  license_enabled: boolean,
  license_signature: string,
};
```

{% endcode %}

#### Check License Offline

Checks an offline license file

{% code title="types.ts" %}

```typescript
checkLicenseOffline(payloadBase64: string): Promise<LicenseFilePayload>

type LicenseFilePayload = {
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  allow_offline_activation: boolean,
  can_borrow: boolean,
  custom_fields: CustomField[],
  customer: CustomerResponse,
  enable_maintenance_period: boolean,
  floating_timeout: number,
  floating_users?: number,
  grace_period: number | null,
  is_air_gapped: boolean,
  is_floating: boolean,
  is_floating_cloud: boolean,
  is_hardware_key_auth: boolean,
  license_key: string | undefined,
  license_template_id?: number,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users?: number,
  max_overages: number,
  max_transfers?: number,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  order_store_id?: string,
  prevent_vm: boolean,
  company: {
    id: number,
  },
  product_details?: ProductDetailsResponse,
  product_features: FeatureResponse[],
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null,
  is_trial: boolean,
  trial_days?: number,
  user?: LicenseUserResponse,
  license_type: LicenseTypes,
  allow_negative_consumptions?: boolean,
  allow_unlimited_consumptions?: boolean,
  consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
  max_consumptions?: number,
  reset_consumption?: boolean,
  total_consumptions?: number,
  request: string,
  active: boolean,
  device_id: number,
  validity_period: string | null,
  is_expired: boolean,
  hardware_id: string,
  username?: string,
  max_license_users?: number,
  is_floating_cloud: boolean,
  floating_in_use?: boolean,
  license_signature: string,
  variables?: ({
    value: string;
    device_id: number;
    variable: string;
    created_at: string | null;
  })[];
  date: string,
  offline_signature: string,
  date: string,
  offline_signature: string,
  license_signature_v2: string,
  offline_signature: string,
};
```

{% endcode %}

#### Check Bundle

See: [**Check Bundle**](/license-api/license-check/check-bundle.md)

{% code title="types.ts" %}

```typescript
checkBundle(
  payload: CheckBundlePayload, 
  includeExpiredFeatures: boolean = false
): Promise<CheckBundleResponse>

type CheckBundlePayload = ({
  username: string;
} | {
  license_key: string;
}) & {
  product: string;
  hardware_id: string;
  env: string | undefined;
  license_id: number | undefined;
  sdk_ver: string | undefined;
  app_ver: string | undefined;
  hostname: string | undefined;
  os_hostname: string | undefined;
  ip_local: string | undefined;
  mac_address: string | undefined;
  ip: string | undefined;
  os_ver: string | undefined;
  channel: string | undefined;
};

type CheckBundleResponse = CheckLicenseResponse[];
// see CheckLicenseResponse declaration in "Check License" section above
```

{% endcode %}

#### Check Bundle Offline

Checks an offline bundle license file

{% code title="types.ts" %}

```typescript
checkBundleOffline(payloadBase64: string): Promise<Record<string, LicenseFilePayload>>

// see LicenseFilePayload declaration in "Check License Offline" section above
```

{% endcode %}

#### Activate License Online

See: [**Activate License (Online Method)**](/license-api/license-activation-and-deactivation/activate-license-online-method.md)

{% code title="types.ts" %}

```typescript
activateLicense(payload: ActivateLicensePayload): Promise<ActivateLicenseResponse>

type ActivateLicensePayload = ({ 
  license_key: string; 
} | {
  username: string;
  password: string;
} | {
  code: string;
  customer_account_code: string;
} | {
  id_token: string;
  customer_account_code: string;
}) & {
  hardware_id: string;
  product: string;
  variables: { [key: string]: string | number | boolean } | undefined;
};

type ActivateLicenseResponse = {
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  allow_offline_activation: boolean,
  can_borrow: boolean,
  custom_fields: CustomField[],
  customer: CustomerResponse,
  enable_maintenance_period: boolean,
  floating_timeout: number,
  floating_users?: number,
  grace_period: number | null,
  is_air_gapped: boolean,
  is_floating: boolean,
  is_floating_cloud: boolean,
  is_hardware_key_auth: boolean,
  license_key: string | undefined,
  license_template_id?: number,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users?: number,
  max_overages: number,
  max_transfers?: number,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  order_store_id?: string,
  prevent_vm: boolean,
  company: {
    id: number,
  },
  product_details?: ProductDetailsResponse,
  product_features: FeatureResponse[],
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null,
  is_trial: boolean,
  trial_days?: number,
  user?: LicenseUserResponse,
  license_type: LicenseTypes,
  allow_negative_consumptions?: boolean,
  allow_unlimited_consumptions?: boolean,
  consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
  max_consumptions?: number,
  reset_consumption?: boolean,
  total_consumptions?: number,
  request: string,
  active: boolean,
  device_id: number,
  validity_period: string | null,
  is_expired: boolean,
  hardware_id: string,
  username?: string,
  max_license_users?: number,
  is_floating_cloud: boolean,
  floating_in_use?: boolean,
  license_signature: string,
  variables?: ({
    value: string;
    device_id: number;
    variable: string;
    created_at: string | null;
  })[];
};
```

{% endcode %}

#### Deactivate License Online

See: [**Deactivate License (Online Method)**](/license-api/license-activation-and-deactivation/deactivate-license-online-method.md)

{% code title="types.ts" %}

```typescript
deactivateLicense(payload: ({  
  username: string;
} | {
  license_key: string;
}) & {
  product: string;
  hardware_id: string;
}): Promise<boolean>
```

{% endcode %}

#### Activate License Offline

See: [**Activate License (Offline Method)**](/license-api/license-activation-and-deactivation/activate-license-offline-method.md)

{% code title="types.ts" %}

```typescript
activateOffline(payload: string): Promise<ActivateOfflineResponse>

type ActivateOfflineResponse = {
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  allow_offline_activation: boolean,
  can_borrow: boolean,
  custom_fields: CustomField[],
  customer: CustomerResponse,
  enable_maintenance_period: boolean,
  floating_timeout: number,
  floating_users?: number,
  grace_period: number | null,
  is_air_gapped: boolean,
  is_floating: boolean,
  is_floating_cloud: boolean,
  is_hardware_key_auth: boolean,
  license_key: string | undefined,
  license_template_id?: number,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users?: number,
  max_overages: number,
  max_transfers?: number,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  order_store_id?: string,
  prevent_vm: boolean,
  company: {
    id: number,
  },
  product_details?: ProductDetailsResponse,
  product_features: FeatureResponse[],
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null,
  is_trial: boolean,
  trial_days?: number,
  user?: LicenseUserResponse,
  license_type: LicenseTypes,
  allow_negative_consumptions?: boolean,
  allow_unlimited_consumptions?: boolean,
  consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
  max_consumptions?: number,
  reset_consumption?: boolean,
  total_consumptions?: number,
  request: string,
  active: boolean,
  device_id: number,
  validity_period: string | null,
  is_expired: boolean,
  hardware_id: string,
  username?: string,
  max_license_users?: number,
  is_floating_cloud: boolean,
  floating_in_use?: boolean,
  license_signature: string,
  variables?: ({
    value: string;
    device_id: number;
    variable: string;
    created_at: string | null;
  })[];
  date: string,
  offline_signature: string,
  license_signature_v2: string,
};
```

{% endcode %}

#### Deactivate License Offline

See: [**Deactivate License (Offline Method)**](/license-api/license-activation-and-deactivation/deactivate-license-offline-method.md)

{% code title="types.ts" %}

```typescript
deactivateOffline(payload: string): Promise<boolean>
```

{% endcode %}

#### Activate Bundle Online

See: [**Activate Bundle (Online Method)**](/license-api/license-activation-and-deactivation/activate-bundle-online-method.md)

{% code title="types.ts" %}

```typescript
activatBundle(payload: ActivateBundlePayload): Promise<ActivateBundleResponse>

type ActivateBundlePayload = ({ 
  license_key: string; 
} | {
  username: string;
  password: string;
} | {
  code: string;
  customer_account_code: string;
} | {
  id_token: string;
  customer_account_code: string;
}) & {
  hardware_id: string;
  product: string;
  variables: { [key: string]: string | number | boolean } | undefined;
};

type ActivateBundleResponse = ActivateLicenseResponse[];
// see ActivateLicenseResponse in "Activate License Online" section above
```

{% endcode %}

#### Deactivate Bundle Online

See: [**Deactivate Bundle (Online Method)**](/license-api/license-activation-and-deactivation/deactivate-bundle-online-method.md)

{% code title="types.ts" %}

```typescript
deactivateBundle(payload: ({  
  username: string;
} | {
  license_key: string;
}) & {
  product: string;
  hardware_id: string;
}): Promise<boolean>
```

{% endcode %}

#### Get Trial Key

See: [**Trial Key**](/license-api/trial-key.md)

{% code title="types.ts" %}

```typescript
getTrialKey(payload: GetTrialKeyPayload): Promise<TrialResponse>

type GetTrialKeyPayload = {
    sdk_ver: string | undefined;
    email: string | undefined;
    license_policy: string | undefined;
    first_name: string | undefined;
    last_name: string | undefined;
    phone: string | undefined;
    address: string | undefined;
    postcode: string | undefined;
    state: string | undefined;
    country: string | undefined;
    city: string | undefined;
    reference: string | undefined;
    company_name: string | undefined;
    hardware_id: string;
    product: string;
};

type TrialResponse = TrialExistingResponse | TrialNewResponse;

type TrialExistingResponse = {
  license_type: LicenseTypes,
  is_trial: boolean,
  license: string,
} | {
  license_type: LicenseTypes,
  is_trial: boolean,
  license_user: string,
};

type TrialNewResponse = {
  id: number;
  order_id: number;
  product_id: number;
  created_at: number;
  updated_at: number;
  active: boolean;
  enable_maintenance_period: boolean;
  enabled: boolean;
  is_floating: boolean;
  is_hardware_key_auth: boolean;
  is_trial: boolean;
  license_type: LicenseTypes;
  maintenance_duration: string | null;
  max_activations: number;
  max_transfers: number;
  metadata_string: string | undefined;
  metadata: JSONObjectRequired,
  prevent_vm: boolean;
  times_activated: number;
  trial_days: number;
  validity_period?: string;
  company: {
    id: number;
  };
  LicenseProductFeatures: ({
    id: number;
    product_feature_id: number;
    max_consumption: number;
    allow_overages: boolean;
    max_overages: number;
    reset_consumption: boolean;
    consumption_period?: ConsumptionPeriod;
    is_floating: boolean;
    is_floating_cloud: boolean;
    metadata: JSONObjectRequired,
    metadata_string?: string;
    floating_timeout?: number;
    floating_users?: number;
  })[];
  LicenseCustomFields: ({
    product_custom_field_id: number;
    value: string | undefined;
  })[];
  is_floating_cloud: boolean;
  floating_users: number;
  floating_timeout: number;
  allow_overages: boolean;
  max_overages: number;
  max_consumptions: number;
  valid_duration: null;
  consumption_period: ConsumptionPeriod | null;
  reset_consumption?: boolean;
  grace_period: number;
  allow_grace_period: boolean;
} & ({
  license: string;
  license_key: string;
} | {
  license_user: string;
  initial_password: string;
  license_user_id: number | null;
  max_license_users: number;
});
```

{% endcode %}

#### List Licenses for User

See: [**Licenses for User**](/license-api/list-licenses/licenses-for-user.md)

{% code title="types.ts" %}

```typescript
getUserLicenses(payload: GetUserLicensesPayload): Promise<GetUserLicensesResponse>

type GetUserLicensesPayload = ({ 
  license_key: string; 
} | {
  username: string;
  password: string;
} | {
  code: string;
  customer_account_code: string;
} | {
  id_token: string;
  customer_account_code: string;
}) & {
  product?: string;
};

type GetUserLicensesResponse = ({
  
  license: {
    id: number,
    allow_grace_period: boolean,
    allow_overages: boolean,
    allow_unlimited_activations: boolean,
    allow_offline_activation: boolean,
    can_borrow: boolean,
    custom_fields: CustomField[],
    customer: CustomerResponse,
    enable_maintenance_period: boolean,
    floating_timeout: number,
    floating_users?: number,
    grace_period: number | null,
    is_air_gapped: boolean,
    is_floating: boolean,
    is_floating_cloud: boolean,
    is_hardware_key_auth: boolean,
    license_key: string | undefined,
    license_template_id?: number,
    maintenance_period: string | null,
    max_activations: number,
    max_borrow_time: number,
    max_license_users?: number,
    max_overages: number,
    max_transfers?: number,
    metadata: JSONObjectRequired,
    metadata_string?: string,
    order_store_id?: string,
    prevent_vm: boolean,
    company: {
      id: number,
    },
    product_details?: ProductDetailsResponse,
    product_features: FeatureResponse[],
    start_date: string | null,
    times_activated: number,
    transfer_count: number,
    validity_period: string | null,
    is_trial: boolean,
    trial_days?: number,
    user?: LicenseUserResponse,
    license_type: LicenseTypes,
    allow_negative_consumptions?: boolean,
    allow_unlimited_consumptions?: boolean,
    consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
    max_consumptions?: number,
    reset_consumption?: boolean,
    total_consumptions?: number,
    license_active: boolean,
    license_enabled: boolean,
  },
  
  user: {
    id: number,
    email: string,
    first_name: string,
    is_initial_password: boolean,
    last_name: string,
    phone_number: string,
    allow_unlimited_activations?: boolean,
    max_activations?: number,
    total_activations?: number,
  },
})[];
```

{% endcode %}

#### List License Users for Customer

See: [**List License Users for Customer**](/license-api/list-license-users-for-customer.md)

{% code title="types.ts" %}

```typescript
getCustomerLicenseUsers(payload: {
    product: string;
    customer: string;
}): Promise<CustomerLicenseUsersResponse>

type CustomerLicenseUsersResponse = {
  company: {
    id: number;
  };
  customer: CustomerResponse;
  users: ({
    email: string | undefined;
    allow_unlimited_activations: boolean;
    first_name: string;
    initial_password: string;
    is_active: boolean;
    is_initial_password: boolean;
    last_name: string;
    license_id: number;
    max_activations: number;
    order_id: number;
    order_store_id: string;
    phone_number: string;
    total_activations: number;
  })[];
};
```

{% endcode %}

#### Check License Feature

See: [**License Feature Check**](/license-api/license-feature-check.md)

{% code title="types.ts" %}

```typescript
checkLicenseFeature(payload: CheckLicenseFeaturePayload): Promise<CheckLicenseFeatureResponse>

type CheckLicenseFeaturePayload = ({
  license_key: string;
} | {
  username: string;
}) & {
  license_id: number | undefined;
  sdk_ver: string | undefined;
  include_metadata_string: boolean | undefined;
  hardware_id: string;
  product: string;
  feature: string;
};

type CheckLicenseFeatureResponse = {
  id: number;
  license_id: number;
  code: string;
  name: string;
  metadata: JSONObjectRequired,
  metadata_string?: string;
  is_floating: boolean;
  is_floating_cloud: boolean;
  floating_in_use_devices?: number;
  expiry_date: string | null;
  feature_type: 'activation';
} | {
  id: number;
  license_id: number;
  code: string;
  name: string;
  metadata: JSONObjectRequired,
  metadata_string?: string;
  is_floating: boolean;
  is_floating_cloud: boolean;
  floating_in_use_devices?: number;
  expiry_date: string | null;
  feature_type: 'consumption';
  consumption_period: ConsumptionPeriod;
  allow_negative_consumptions: boolean;
  allow_overages: boolean;
  allow_unlimited_consumptions: boolean;
  max_consumption: number;
  max_overages: number;
  reset_consumption: boolean;
  total_consumptions: number;
};
```

{% endcode %}

#### Add License Consumption

See: [**Add Consumption**](/license-api/consumption/add-consumption.md)

{% code title="types.ts" %}

```typescript
addConsumption(payload: AddConsumptionPayload): Promise<AddConsumptionResponse>

type AddConsumptionPayload = ({
  license_key: string;
} | {
  username: string;
}) & {
  product: string;
  hardware_id: string;
  consumptions: number;
  sdk_ver: string | undefined;
  license_id: number | undefined;
  ignore_events: boolean | undefined;
  allow_overages: boolean | undefined;
  max_overages: number | undefined;
  event: ("consumption_add" | "offline_floating_consumptions_sync")[] | undefined;
};

type AddConsumptionResponse = {
  id: number;
  max_consumptions: number;
  allow_unlimited_consumptions: boolean;
  allow_negative_consumptions: boolean;
  allow_overages: boolean;
  max_overages: number;
  reset_consumption: boolean;
  consumption_period: ConsumptionPeriod | undefined;
  total_consumptions: number;
  company: {
    id: number;
  };
};
```

{% endcode %}

#### Add License Feature Consumption

See: [**Add Feature Consumption**](/license-api/consumption/add-feature-consumption.md)

{% code title="types.ts" %}

```typescript
addFeatureConsumption(payload: AddFeatureConsumptionPayload): Promise<AddFeatureConsumptionResponse>

type AddFeatureConsumptionPayload = ({
  license_key: string;
} | {
  username: string;
}) & {
  product: string;
  hardware_id: string;
  consumptions: number;
  feature: string;
  sdk_ver: string | undefined;
  license_id: number | undefined;
  ignore_events: boolean | undefined;
  allow_overages: boolean | undefined;
  max_overages: number | undefined;
  event: ("consumption_add" | "offline_floating_consumptions_sync")[] | undefined;
};

type AddFeatureConsumptionResponse = {
  id: number;
  license_id: number;
  company: {
    id: number;
  };
  total_consumptions: number;
  max_consumptions: number;
  allow_negative_consumptions: boolean;
  allow_unlimited_consumptions: boolean;
  allow_overages: boolean;
  max_overages: number;
  reset_consumption: boolean;
  consumption_period: ConsumptionPeriod;
  is_floating: boolean;
  is_floating_cloud: boolean;
  floating_timeout?: number;
  floating_users?: number;
};
```

{% endcode %}

#### Get Product Details

See: [**Get Product Details**](/license-api/products/get-product-details.md)

{% code title="types.ts" %}

```typescript
getProductDetails(payload: ProductDetailsPayload): Promise<GetProductDetailsResponse>

type ProductDetailsPayload = {
    product: string;
    include_latest_version: boolean | undefined;
    include_custom_fields: boolean | undefined;
    env: string | undefined;
};

type GetProductDetailsResponse = {
  product_id: number,
  product_name: string,
  short_code: string,
  allow_trial: boolean,
  trial_days: number,
  authorization_method: AuthorizationMethod,
  floating_timeout: number,
  allow_overages: boolean,
  max_overages: number,
  prevent_vm: boolean,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  company: {
    id: number
  },
  latest_version?: {
    id: number;
    version: string | undefined;
    full_link: string | undefined;
    filename: string | undefined;
    release_date: string | null;
    hash_md5: string | undefined;
    environment: string;
    eula_link: string | undefined;
    release_notes_link: string | undefined;
    size: string | undefined;
    requires_version: string | undefined;
    channel: string | undefined;
    created_at: string | null;
    updated_at: string | null;
    enabled: boolean;
    product_id: number;
  } | null,
  custom_fields?: { id: number, name: string, default_value: string }[]
};
```

{% endcode %}

#### Get Device Variables

See: [**Get Device Variables**](/license-api/device-variables/get-device-variables.md)

{% code title="types.ts" %}

```typescript
getDeviceVariables(payload: GetDeviceVariablesPayload): Promise<GetDeviceVariablesResponse>

type GetDeviceVariablesPayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    sdk_ver: string | undefined;
    license_id: number | undefined;
};

type GetDeviceVariablesResponse = {
  id: number;
  created_at: string;
  variable?: string;
  value?: string;
  device_id: number;
}[];
```

{% endcode %}

#### Track Device Variables

See: [**Track Device Variables**](/license-api/device-variables/track-device-variables.md)

{% code title="types.ts" %}

```typescript
trackDeviceVariables(payload: TrackDeviceVariablesPayload): Promise<TrackDeviceVariablesResponse>

type TrackDeviceVariablesPayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    variables: { [key: string]: string | number | boolean },
    sdk_ver: string | undefined;
    license_id: number | undefined;
};

type TrackDeviceVariablesResponse = {
  variable: string;
  value: string;
  device_id: number;
  created_at: number;
}[];
```

{% endcode %}

#### Borrow Floating License

See: [**Borrow Floating License**](/license-api/floating/license/borrow-floating-license.md)

{% code title="types.ts" %}

```typescript
floatingBorrow(payload: FloatingBorrowPayload): Promise<FloatingBorrowResponse>

type FloatingBorrowPayload = ({
    license_key: string;
} | {
    username: string;
    password: string;
}) & {
    product: string;
    hardware_id: string;
    borrowed_until: string | null;
    sdk_ver: string | undefined;
    license_id: number | undefined;
};

type FloatingBorrowResponse = {
  borrowed_until: string | null;
  max_borrow_time: number;
  device_id: number;
  license_id: number;
  company: {
    id: number;
  };
};
```

{% endcode %}

#### Release Floating License

See: [**Release Floating License**](/license-api/floating/license/release-floating-license.md)

{% code title="types.ts" %}

```typescript
floatingRelease(payload: FloatingReleasePayload): Promise<boolean>

type FloatingReleasePayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    sdk_ver: string | undefined;
    license_id: number | undefined;
};
```

{% endcode %}

#### Release Floating Feature

See: [**Release Floating Feature**](/license-api/floating/features/release-floating-feature.md)

{% code title="types.ts" %}

```typescript
featureRelease(payload: FloatingFeatureReleasePayload): Promise<boolean>

type FloatingFeatureReleasePayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    feature: string;
    sdk_ver: string | undefined;
    license_id: number | undefined;
};
```

{% endcode %}

#### Change Password

See: [**Change Password**](/license-api/change-password.md)

{% code title="types.ts" %}

```typescript
changePassword(payload: {
    username: string;
    password: string;
    new_password: string;
}): Promise<boolean>
```

{% endcode %}

#### Get Product Versions

See: [**Get Product Versions**](/license-api/get-product-versions.md)

{% code title="types.ts" %}

```typescript
getVersions(payload: GetVersionsPayload): Promise<VersionsResponse>

type GetVersionsPayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    sdk_ver: string | undefined;
    env: string | undefined;
    channel: string | undefined;
};

type VersionsResponse = ({
  version: string | undefined;
  release_date: string | null;
})[];
```

{% endcode %}

#### Get Product Installation File

See: [**Get Installation File**](/license-api/get-installation-file.md)

{% code title="types.ts" %}

```typescript
getInstallationFile(payload: GetInstallationFilePayload): Promise<InstallationFileResponse>

type GetInstallationFilePayload = ({
    license_key: string;
} | {
    username: string;
}) & {
    product: string;
    hardware_id: string;
    sdk_ver: string | undefined;
    env: string | undefined;
    channel: string | undefined;
    version: string | undefined;
};

type InstallationFileResponse = {
  id: number;
  version: string | undefined;
  installation_file: string | undefined;
  release_date: string | null;
  hash_md5: string | undefined;
  environment: string;
  eula_link: string | undefined;
  release_notes_link: string | undefined;
  size: string | undefined;
  requires_version: string | undefined;
  channel: string | undefined;
  company: {
    id: number;
  };
};
```

{% endcode %}

#### Get Single Sign-On URL

See: [**Single Sign On URL**](/license-api/single-sign-on-url.md)

{% code title="types.ts" %}

```typescript
getSSOUrl(payload: {
    response_type: 'token' | 'code' | undefined;
    product: string;
    customer_account_code: string;
}): Promise<SSOUrlResponse>

type SSOUrlResponse = {
  url: string;
  openid_configuration: {
    [key: string]: string | number | boolean;
  };
};
```

{% endcode %}

#### Air-Gapped License Code

[**https://docs.licensespring.com/license-entitlements/activation-types/air-gapped**](https://docs.licensespring.com/license-entitlements/activation-types/air-gapped)

{% code title="types.ts" %}

```typescript
getAirGapActivationCode(
  initializationCode: string, 
  licenseKey: string
): string

verifyConfirmationCode(
  confirmationCode: string, 
  licenseKey: string, 
  policyId?: string
): boolean

activateAirgappedLicense(
  activationPayload: OfflineActivation, 
  licenseKey: string, 
  policyId: string
): LicenseSaved

type LicenseSaved = {
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  allow_offline_activation: boolean,
  can_borrow: boolean,
  custom_fields: CustomField[],
  customer: CustomerResponse,
  enable_maintenance_period: boolean,
  floating_timeout: number,
  floating_users?: number,
  grace_period: number | null,
  is_air_gapped: boolean,
  is_floating: boolean,
  is_floating_cloud: boolean,
  is_hardware_key_auth: boolean,
  license_key: string | undefined,
  license_template_id?: number,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users?: number,
  max_overages: number,
  max_transfers?: number,
  metadata: JSONObjectRequired,
  metadata_string?: string,
  order_store_id?: string,
  prevent_vm: boolean,
  company: {
    id: number,
  },
  product_details?: ProductDetailsResponse,
  product_features: FeatureResponse[],
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null,
  is_trial: boolean,
  trial_days?: number,
  user?: LicenseUserResponse,
  license_type: LicenseTypes,
  allow_negative_consumptions?: boolean,
  allow_unlimited_consumptions?: boolean,
  consumption_period?: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
  max_consumptions?: number,
  reset_consumption?: boolean,
  total_consumptions?: number,
  borrowed_until: string | null,
  floating_in_use_devices?: number,
  is_borrowed: boolean,
  is_expired: boolean,
  policy_id: string;
};
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/sdks/node.js-sdk/license-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
