# Get Product Versions

### Endpoint

* Method: `GET`
* Path: `/api/v4/versions`
* Description: Returns metadata on all available versions of a product.

{% hint style="info" %}
Product versions are returned up to the existing **maintenance\_period** *or* **validity\_period** on the license. If those fields are not defined on a license, all versions will be returned by default.
{% endhint %}

### Authentication

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

#### Required headers

* `Date` (string) — RFC7231 GMT date string
* `Authorization` (string)

#### Recommended headers

* `Accept: application/json`

### Request

#### Query parameters

* hardware\_id (required, string) — Unique hardware ID generated for the client device
* product (required, string) — Product short code
* license\_key (optional, string) — Required if product is key-based
* username (optional, string) — Required if product is user-based
* license\_id (optional, number) — Ensures the action affects only the license with the specified ID (useful if multiple licenses for same product assigned to same user)
* env (optional, string) — Environment identifier, e.g. "win", "win32", "win64", "mac", "linux", "linux32", "linux64"
* channel (optional, string) — Channel identifier, e.g. "staging", "prod"

### Examples

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

```bash
curl --location --request GET '/api/v4/versions?hardware_id=string&product=string&license_key=string' \
--header 'Accept: application/json' \
--header 'Date: string' \
--header 'Authorization: string'
```

{% endtab %}

{% tab title="nodejs" %}

```javascript
var request = require('request');
var options = {
  method: 'GET',
  url: '/api/v4/versions?hardware_id=string&product=string&license_key=string',
  headers: {
    'Accept': 'application/json',
    'Date': 'string',
    'Authorization': 'string'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

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

```javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Date", "string");
myHeaders.append("Authorization", "string");

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

fetch("/api/v4/versions?hardware_id=string&product=string&license_key=string", 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/versions?hardware_id=string&product=string&license_key=string"

headers = {
  "Accept": "application/json",
  "Date": "string",
  "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/versions?hardware_id=string&product=string&license_key=string")

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

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

{% endtab %}
{% endtabs %}

### Response

Array of version metadata objects:

```typescript
type GetProductVersionsResponseBody = ({
  version: string,
  release_date: string, // Date string in full ISO 8601 format, e.g. "2024-09-27T23:30:48.016Z"
})[];
```

<details>

<summary><strong>Example response body</strong></summary>

```json
[
  { "version": "1.0.0", "release_date": "2020-11-30T00:00:00.000Z" },
  { "version": "1.0.1", "release_date": "2020-11-30T00:00:00.000Z" },
  { "version": "1.0.2", "release_date": "2021-04-30T00:00:00.000Z" }
]
```

</details>

### License Authorization Method

There are two types of product licenses based on how the client application authorizes itself to interact with a license:

* Key-based product licenses: client interactions with the license have to be authorized using a `license_key`
* User-based product licenses: the license has a corresponding "license user" instead of a license key. Client interactions with the license have to be authorized using a `username`

### 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
}
```


---

# 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/license-api/get-product-versions.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.
