> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/license-api/list-licenses/licenses-for-user.md).

# Licenses for User

Returns a list of licenses assigned to a user for a product (user-based product licenses only).

### Endpoint

* Method: `GET`
* Path: `/api/v4/user_licenses`

### Authentication

See [License API Authorization](/license-api/license-api-authorization.md).

#### Required headers

* `Date` (string)
* `Authorization` (string)

#### Recommended headers

* `Accept: application/json`

### Request

#### Query parameters

Required:

* `product` (string)

One of:

* `username` + `password` (string)
* `id_token` (use access\_token value) + `customer_account_code` (string)
* `code` + `customer_account_code` (string)

Optional:

* `redirect_uri`  (string)

### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request GET '/api/v4/user_licenses?product=PRODUCT_STRING&username=USERNAME_STRING&password=PASSWORD_STRING' \
--header 'Accept: application/json' \
--header 'Date: DATE_STRING' \
--header 'Authorization: AUTHORIZATION_STRING'
```

{% endtab %}

{% tab title="nodejs" %}

```javascript
var request = require('request');
var options = {
  method: 'GET',
  url: '/api/v4/user_licenses?product=PRODUCT_STRING&username=USERNAME_STRING&password=PASSWORD_STRING',
  headers: {
    'Accept': 'application/json',
    'Date': 'DATE_STRING',
    'Authorization': 'AUTHORIZATION_STRING'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

{% tab title="javascript (fetch)" %}

```javascript
const headers = new Headers();
headers.append("Accept", "application/json");
headers.append("Date", "DATE_STRING");
headers.append("Authorization", "AUTHORIZATION_STRING");

const requestOptions = {
  method: 'GET',
  headers: headers,
  redirect: 'follow'
};

const queryParams = new URLSearchParams({
  product: 'PRODUCT_STRING',
  username: 'USERNAME_STRING',
  password: 'PASSWORD_STRING'
}).toString();

fetch("/api/v4/user_licenses?" + queryParams, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = "/api/v4/user_licenses?product=PRODUCT_STRING&username=USERNAME_STRING&password=PASSWORD_STRING"

headers = {
  "Accept": "application/json",
  "Date": "DATE_STRING",
  "Authorization": "AUTHORIZATION_STRING"
}

response = requests.get(url, headers=headers)
print(response.text)
```

{% endtab %}

{% tab title="ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("/api/v4/user_licenses?product=PRODUCT_STRING&username=USERNAME_STRING&password=PASSWORD_STRING")

http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Date"] = "DATE_STRING"
request["Authorization"] = "AUTHORIZATION_STRING"

response = http.request(request)
puts response.read_body
```

{% endtab %}
{% endtabs %}

### Results

<details>

<summary><strong>200</strong></summary>

```json
[
    {
        "license": {
            "id": 10003,
            "order_store_id": "store_id_for_order_3",
            "license_active": true,
            "license_enabled": true,
            "license_type": "perpetual",
            "is_trial": false,
            "max_license_users": 1,
            "validity_period": null,
            "enable_maintenance_period": false,
            "maintenance_period": null,
            "allow_grace_period": false,
            "grace_period": 0,
            "max_activations": 1,
            "allow_unlimited_activations": false,
            "times_activated": 1,
            "start_date": null,
            "transfer_count": 0,
            "max_transfers": 0,
            "allow_overages": false,
            "max_overages": 0,
            "is_floating_cloud": false,
            "is_floating": false,
            "floating_timeout": 120,
            "can_borrow": false,
            "max_borrow_time": 0,
            "prevent_vm": false,
            "custom_fields": [],
            "product_features": [],
            "customer": {
                "email": "somecustomer@somedomain.com",
                "company_name": "Some Company",
                "reference": "ref_for_customer_1",
                "phone": "",
                "first_name": "",
                "last_name": "",
                "city": "",
                "postcode": "",
                "state": "",
                "country": "",
                "address": "",
                "customer_account": null,
                "metadata": {}
            },
            "product_details": {
                "product_id": 10006,
                "product_name": "User Product",
                "short_code": "up",
                "authorization_method": "user",
                "metadata": {}
            },
            "metadata": {},
            "is_hardware_key_auth": false,
            "is_air_gapped": false
        },
        "user": {
            "id": 10003,
            "email": "someuser@somedomain.com",
            "first_name": "Some",
            "last_name": "User",
            "phone_number": "",
            "is_initial_password": true,
            "max_activations": 1,
            "allow_unlimited_activations": false,
            "total_activations": 1
        }
    },
    {
        "license": {
            "id": 1719215304208059,
            "order_store_id": "trial_1719215304208039",
            "license_active": true,
            "license_enabled": true,
            "license_type": "perpetual",
            "is_trial": true,
            "max_license_users": 1,
            "validity_period": "2031-03-16",
            "enable_maintenance_period": false,
            "maintenance_period": null,
            "allow_grace_period": false,
            "grace_period": 0,
            "max_activations": 1,
            "allow_unlimited_activations": false,
            "times_activated": 1,
            "start_date": null,
            "transfer_count": 3,
            "max_transfers": 2,
            "allow_overages": false,
            "max_overages": 0,
            "is_floating_cloud": false,
            "is_floating": false,
            "floating_timeout": 120,
            "can_borrow": false,
            "max_borrow_time": 0,
            "prevent_vm": false,
            "custom_fields": [],
            "product_features": [],
            "customer": {
                "email": "someuser@somedomain.com",
                "company_name": "",
                "reference": "",
                "phone": "",
                "first_name": "",
                "last_name": "",
                "city": "",
                "postcode": "",
                "state": "",
                "country": "",
                "address": "",
                "customer_account": null,
                "metadata": {}
            },
            "product_details": {
                "product_id": 10006,
                "product_name": "User Product",
                "short_code": "up",
                "authorization_method": "user",
                "metadata": {}
            },
            "metadata": {},
            "is_hardware_key_auth": false,
            "is_air_gapped": false,
            "trial_days": 15
        },
        "user": {
            "id": 10003,
            "email": "someuser@somedomain.com",
            "first_name": "Some",
            "last_name": "User",
            "phone_number": "",
            "is_initial_password": true,
            "max_activations": 1,
            "allow_unlimited_activations": false,
            "total_activations": 1
        }
    }
]
```

\\

</details>

### Schema

<details>

<summary><strong>Request schema (TypeScript + JSON Schema)</strong></summary>

**TypeScript**

```typescript
type LicensesForUserRequestParameters = {
  
  product: string,
  redirect_uri?: string
  
} & ({

  // for username and password authentication:
  username: string
  password: string

} | {

  // for single sign-on Implicit grant authentication:
  id_token: string
  customer_account_code: string

} | {

  // for single sign-on using Authorization code grant authentication:
  code: string
  customer_account_code: string

})
```

**JSON Schema**

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "username": { "type": "string" },
        "password": { "type": "string" }
      },
      "required": ["username", "password"],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id_token": { "type": "string" },
        "customer_account_code": { "type": "string" }
      },
      "required": ["id_token", "customer_account_code"],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "code": { "type": "string" },
        "customer_account_code": { "type": "string" }
      },
      "required": ["code", "customer_account_code"],
      "additionalProperties": false
    }
  ]
}
```

</details>

<details>

<summary><strong>Response schema (TypeScript + JSON Schema)</strong></summary>

**TypeScript**

```typescript
type LicenseListResponseBody = ({
  id: number,
  allow_grace_period: boolean,
  allow_overages: boolean,
  allow_unlimited_activations: boolean,
  borrowed_until: string | null, // in ISO 8601 format (always in UTC timezone), e.g. 2024-09-27T23:30:48.016Z or 2024-09-27 23:30
  can_borrow: boolean,
  channel: string,
  device_id: number,
  enable_maintenance_period: boolean
  environment: string,
  eula_link: string,
  floating_timeout: number,
  grace_period: number,
  hash_md5: string,
  installation_file: string,
  is_air_gapped: boolean,
  is_borrowed: boolean,
  is_expired: boolean,
  is_floating_cloud: boolean,
  is_floating: boolean,
  is_hardware_key_auth: boolean,
  license_active: boolean,
  license_enabled: boolean,
  license_signature: string,
  license_signature_v2: string,
  offline_signature: string,
  license_type: string,
  maintenance_period: string | null,
  max_activations: number,
  max_borrow_time: number,
  max_license_users: number,
  max_overages: number,
  max_transfers: number,
  order_store_id: string,
  prevent_vm: boolean,
  release_date: string,
  release_notes_link: string,
  requires_version: string,
  size: string,
  start_date: string | null,
  times_activated: number,
  transfer_count: number,
  validity_period: string | null, // string is in DateISO8601UTC format
  version: string,
  company: { id: number },
  
  product_features: ({
    id: number,
    code: string,
    name: string,
    expiry_date: string,
    metadata: JSON,
    feature_type: 'activation' | 'consumption',
    is_floating: boolean,
    is_floating_cloud: boolean,

    // the following properties are only present if is_floating=true or is_floating_cloud=true
    floating_users: number,
    floating_timeout: number,

    // the following properties are only present if feature_type=consumption
    max_consumption: number,
    allow_unlimited_consumptions: boolean,
    total_consumptions: number,
    allow_overages: number,
    max_overages: number,
    reset_consumption: boolean,
    consumption_period: 'daily' | 'weekly' | 'monthly' | 'annualy' | null,
  })[],
  
  custom_fields: ({
    name: string,
    data_type: 'numer' | 'text' | 'date/time',
    value: string,
  })[],
  
  customer: {
    email: string,
    company_name: string,
    reference: string,
    phone: string,
    first_name: string,
    last_name: string,
    city: string,
    postcode: string,
    state: string,
    country: string,
    address: string,
    customer_account: string | null,
    metadata: JSON,
  },
  
  product_details: {
    product_id: number,
    product_name: string,
    short_code: string,
    authorization_method: 'license-key' | 'user',
    metadata: JSON,
  },
  
  // NOTE: all licenses in this response are for user-based products
  
  user: {
    id: number,
    email: string,
    first_name: string,
    last_name: string,
    phone_number: string,
    is_initial_password: boolean,
    max_activations: number,
    allow_unlimited_activations: boolean,
    total_activations: number
  },
  
  metadata: JSON,
  
  // the following property is only present if is_trial=true
  trial_days: number,
  
  // the following properties is only present if is_floating=true or is_floating_cloud=true
  floating_in_use_devices: number,
  floating_users: number,
  
  // the following properties are only present if license_type='consumption'
  max_consumptions: number,
  total_consumptions: number,
  allow_unlimited_consumptions: boolean,
  reset_consumption: boolean,
  consumption_period: string | null, // string is in DateISO8601UTC format
  
})[];
```

**JSON Schema**

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "number" },
      "allow_grace_period": { "type": "boolean" },
      "allow_overages": { "type": "boolean" },
      "allow_unlimited_activations": { "type": "boolean" },
      "borrowed_until": { "type": ["string", "null"] },
      "can_borrow": { "type": "boolean" },
      "channel": { "type": "string" },
      "device_id": { "type": "number" },
      "enable_maintenance_period": { "type": "boolean" },
      "environment": { "type": "string" },
      "eula_link": { "type": "string" },
      "floating_timeout": { "type": "number" },
      "grace_period": { "type": "number" },
      "hash_md5": { "type": "string" },
      "installation_file": { "type": "string" },
      "is_air_gapped": { "type": "boolean" },
      "is_borrowed": { "type": "boolean" },
      "is_expired": { "type": "boolean" },
      "is_floating_cloud": { "type": "boolean" },
      "is_floating": { "type": "boolean" },
      "is_hardware_key_auth": { "type": "boolean" },
      "license_active": { "type": "boolean" },
      "license_enabled": { "type": "boolean" },
      "license_signature": { "type": "string" },
      "license_signature_v2": { "type": "string" },
      "offline_signature": { "type": "string" },
      "license_type": { "type": "string" },
      "maintenance_period": { "type": ["string", "null"] },
      "max_activations": { "type": "number" },
      "max_borrow_time": { "type": "number" },
      "max_license_users": { "type": "number" },
      "max_overages": { "type": "number" },
      "max_transfers": { "type": "number" },
      "order_store_id": { "type": "string" },
      "prevent_vm": { "type": "boolean" },
      "release_date": { "type": "string" },
      "release_notes_link": { "type": "string" },
      "requires_version": { "type": "string" },
      "size": { "type": "string" },
      "start_date": { "type": ["string", "null"] },
      "times_activated": { "type": "number" },
      "transfer_count": { "type": "number" },
      "validity_period": { "type": ["string", "null"] },
      "version": { "type": "string" },
      "company": { "type": "object", "properties": {"id": { "type": "number" } } },
      "product_features": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": { "type": "number" },
            "code": { "type": "string" },
            "name": { "type": "string" },
            "expiry_date": { "type": "string" },
            "metadata": { "type": "object" },
            "feature_type": { "type": "string", "enum": ["activation", "consumption"] },
            "is_floating": { "type": "boolean" },
            "is_floating_cloud": { "type": "boolean" },
            "floating_users": { "type": "number" },
            "floating_timeout": { "type": "number" },
            "max_consumption": { "type": "number" },
            "allow_unlimited_consumptions": { "type": "boolean" },
            "total_consumptions": { "type": "number" },
            "allow_overages": { "type": "number" },
            "max_overages": { "type": "number" },
            "reset_consumption": { "type": "boolean" },
            "consumption_period": {
              "type": ["string", "null"],
              "enum": ["daily", "weekly", "monthly", "annualy", null]
            }
          },
          "required": ["id", "code", "name", "expiry_date", "metadata", "feature_type", "is_floating", "is_floating_cloud"]
        }
      },
      "custom_fields": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": { "type": "string" },
            "data_type": { "type": "string", "enum": ["numer", "text", "date/time"] },
            "value": { "type": "string" }
          },
          "required": ["name", "data_type", "value"]
        }
      },
      "customer": {
        "type": "object",
        "properties": {
          "email": { "type": "string" },
          "company_name": { "type": "string" },
          "reference": { "type": "string" },
          "phone": { "type": "string" },
          "first_name": { "type": "string" },
          "last_name": { "type": "string" },
          "city": { "type": "string" },
          "postcode": { "type": "string" },
          "state": { "type": "string" },
          "country": { "type": "string" },
          "address": { "type": "string" },
          "customer_account": { "type": ["string", "null"] },
          "metadata": { "type": "object" }
        },
        "required": ["email", "company_name", "reference", "phone", "first_name", "last_name", "city", "postcode", "state", "country", "address", "metadata"]
      },
      "product_details": {
        "type": "object",
        "properties": {
          "product_id": { "type": "number" },
          "product_name": { "type": "string" },
          "short_code": { "type": "string" },
          "authorization_method": { "type": "string", "enum": ["license-key", "user"] },
          "metadata": { "type": "object" }
        },
        "required": ["product_id", "product_name", "short_code", "authorization_method", "metadata"]
      },
      "user": {
        "type": "object",
        "properties": {
          "id": { "type": "number" },
          "email": { "type": "string" },
          "first_name": { "type": "string" },
          "last_name": { "type": "string" },
          "phone_number": { "type": "string" },
          "is_initial_password": { "type": "boolean" },
          "max_activations": { "type": "number" },
          "allow_unlimited_activations": { "type": "boolean" },
          "total_activations": { "type": "number" }
        },
        "required": ["id", "email", "first_name", "last_name", "phone_number", "is_initial_password", "max_activations", "allow_unlimited_activations", "total_activations"]
      },
      "metadata": { "type": "object" },
      "trial_days": { "type": "number" },
      "floating_users": { "type": "number" },
      "max_consumptions": { "type": "number" },
      "total_consumptions": { "type": "number" },
      "allow_unlimited_consumptions": { "type": "boolean" },
      "reset_consumption": { "type": "boolean" },
      "consumption_period": { "type": ["string", "null"] }
    },
    "required": [
      "id",
      "allow_grace_period",
      "allow_overages",
      "allow_unlimited_activations",
      "can_borrow",
      "channel",
      "device_id",
      "enable_maintenance_period",
      "environment",
      "eula_link",
      "floating_timeout",
      "grace_period",
      "hash_md5",
      "installation_file",
      "is_air_gapped",
      "is_borrowed",
      "is_expired",
      "is_floating_cloud",
      "is_floating",
      "is_hardware_key_auth",
      "license_active",
      "license_enabled",
      "license_signature",
      "license_signature_v2",
      "offline_signature",
      "license_type",
      "max_activations",
      "max_borrow_time",
      "max_license_users",
      "max_overages",
      "max_transfers",
      "order_store_id",
      "prevent_vm",
      "release_date",
      "release_notes_link",
      "requires_version",
      "size",
      "times_activated",
      "transfer_count",
      "user",
      "version",
      "product_features",
      "custom_fields",
      "product_details",
      "metadata"
    ],
    "additionalProperties": false
  }
}
```

</details>

### License Authorization Method

The licenses returned by this endpoint are always user-based product licenses. This means they don't have a license key, and instead each license has a "license user".

Accessing this endpoint requires license user authentication, which can be done in three ways:

* By providing the values for `username` and `password` for the license user
* By providing the values for `id_token` (use access\_token value) and `customer_account_code` if using single sign-on authentication using Implicit grant
* By providing the values for `code` and `customer_account_code` if using single sign-on authentication using Authorization code grant

### Errors

If an error occurs, the response will have an HTTP status code of 400 or higher, and the response body will contain an error description in the following format:

```typescript
{
  status: number,
  code: string,
  message: string
}
```

JSON Schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "status": { "type": "number" },
    "code": { "type": "string" },
    "message": { "type": "string" }
  },
  "required": [
    "status",
    "code",
    "message"
  ],
  "additionalProperties": false
}
```

#### List of exceptions


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.licensespring.com/license-api/list-licenses/licenses-for-user.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
