# List Licensees

**GET** `/v1/keys/{key}/licensees`

Returns a key's licensees, oldest first, up to 100 per request. The list omits canceled licensees. The key must be enabled for sub-licensing.

## Example request

**URL**

```http
https://api.addresszen.com/v1/keys/ak_test/licensees?user_token=uk_secret
```

**curl**

```bash
curl -G 'https://api.addresszen.com/v1/keys/ak_test/licensees' \
  -d 'user_token=uk_secret'
```

**JavaScript**

```javascript
import { createZenClient, listLicensees } from '@addresszen/sdk';

const client = createZenClient({ apiKey: 'ak_test', userToken: 'uk_secret' });

const { data } = await listLicensees({
  client,
  path: { key: 'ak_test' },
});
```

**Python**

```python
# pip install addresszen
from addresszen import AddressZen

with AddressZen("ak_test") as client:
    result = client.list_licensees("ak_test", user_token="uk_secret")
```

**Ruby**

```ruby
require "net/http"
require "json"

uri = URI("https://api.addresszen.com/v1/keys/ak_test/licensees")
uri.query = URI.encode_www_form(user_token: "uk_secret")
result = JSON.parse(Net::HTTP.get(uri))["result"]
```

**PHP**

```php
<?php
$response = file_get_contents(
  "https://api.addresszen.com/v1/keys/ak_test/licensees?" .
  http_build_query([
    "user_token" => "uk_secret",
  ])
);
$result = json_decode($response, true)["result"];
```

## Example response

**200 OK**

```json
{
  "result": {
    "licensees": [
      {
        "id": "56a11209ebe230380bf104c3",
        "key": "sl_ijoiqsxeQgXW2gkiE0X94",
        "createdAt": "2016-01-21T17:14:49.971Z",
        "name": "Qwerty Widgets Limited",
        "address": "12 High Street, Manchester",
        "postcode": "BR8 7RE",
        "whitelist": [
          "https://www.example.com"
        ],
        "daily": {
          "limit": 10000,
          "count": 232,
          "updatedAt": "2016-08-05T16:43:28.865Z"
        }
      }
    ],
    "hasMore": true
  },
  "message": "Success",
  "code": 2000
}
```

## Path parameters

* `key` string

  **API Key**

  The API Key. Begins `ak_`.

  Example: `ak_test`

## Query parameters

* `starting_after` integer optional

  ID of the licensee after which to list results

  Format: `int32`

* `user_token` string optional

  **Management Key**

  A secret key used to manage your account and API Keys. It was previously called the user token.

  Your management key can be retrieved and managed from your [accounts page](https://addresszen.com/account).

  Typically begins `uk_`. Prefer sending it in the `Authorization` header as `Bearer uk_...` instead of this query parameter. The `Authorization: user_token="uk_..."` header also works.

  Example: `uk_B59ScW1p1HHouf1VqclEPZUx`

* `limit` integer optional

  **Limit**

  Specifies the maximum number of records to retrieve.

  By default the limit is 10. Requesting a larger result set adds latency.

  Format: `int32`

  Default: `10`

  Example: `5`

* `query` string optional

  Filter results by licensee name. Can be shortened to `q=`

## Response

`result` is an object containing a paginated list of licensees and a flag indicating whether more results are available.

* `result` object

  List of licensees

  * `licensees` Licensee\[]

  * `hasMore` boolean

    Returns true if there are more licensees listed after the maximum number of results as implied by `limit`

The `result` sits inside the standard `{ result, code, message }` envelope. See the [API reference](/docs/api/api-reference.md) for the wrapper format.
