# `client.ListLicensees()`

List

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.

## Endpoint

`GET /keys/{key}/licensees`

See the [API reference](/docs/api/list-licensees.md) for this endpoint.

This operation needs a Management Key. Pass it with `addresszen.WithManagementKey(...)` when you create the client, which sends it in the `Authorization` header. See [setup](/docs/sdks/go/setup.md).

## Signature

```go
func (c *Client) ListLicensees(ctx context.Context, key string, params *ListLicenseesParams) (*LicenseesResponse, error)
```

## Arguments

| Name     | Type                   | Required | Description                                                                            |
| -------- | ---------------------- | -------- | -------------------------------------------------------------------------------------- |
| `ctx`    | `context.Context`      | yes      | Cancels the request and sets its deadline.                                             |
| `key`    | `string`               | yes      | API Key                                                                                |
| `params` | `*ListLicenseesParams` | no       | Optional query parameters, or nil. Fields under [Query Parameters](#query-parameters). |

## Query Parameters

A required parameter is a method argument. Set the rest as fields of `params`, named in Studly case (`post_town` is `PostTown`); a field left at its zero value is not sent.

| Name             | Type     | Required | Description                                                                                              |
| ---------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `starting_after` | `string` | no       | ID of the licensee after which to list results. Pass the `id` of the last licensee on the previous page. |
| `limit`          | `int`    | no       | Limit                                                                                                    |
| `query`          | `string` | no       | Filter results by licensee name. Can be shortened to `q=`                                                |

## Response

`*addresszen.LicenseesResponse`. Fields the API may leave out or send as null are pointers. `RawJSON()` returns the body as received. See [responses](/docs/sdks/go/responses.md).

## Errors

An HTTP error returns `*addresszen.APIError` with the HTTP status, the API error code and the body; match it with `errors.AsType`. A transport failure returns the `net/http` error, wrapped. See [error handling](/docs/sdks/go/errors.md).

## Example

list-licensees/main.gogo

```go
package main

import (
	"context"
	"fmt"
	"log"

	addresszen "go.addresszen.com/sdk"
)

func main() {
	client := addresszen.NewClient("ak_test", addresszen.WithManagementKey("uk_test"))
	res, err := client.ListLicensees(context.Background(), "ak_test", &addresszen.ListLicenseesParams{Limit: 10})
	if err != nil {
		log.Fatal(err)
	}
	for _, licensee := range res.Result.Licensees {
		fmt.Printf("%s: %s (%s)\n", licensee.ID, licensee.Name, licensee.Key)
	}
	fmt.Println("More pages:", res.Result.HasMore)
}
```
