client.ListLicensees()
List
Returns a key's licensees, oldest first, up to 100 per request. The list omits cancelled licensees. The key must be enabled for sublicensing.
Endpoint
GET /keys/{key}/licensees
See the API reference for this endpoint.
This operation needs a Management Key. Pass it with idealpostcodes.WithManagementKey(...) when you create the client, which sends it in the Authorization header. See setup.
Signature
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
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
*idealpostcodes.LicenseesResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.
Errors
An HTTP error returns *idealpostcodes.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.
Example
package main
import (
"context"
"fmt"
"log"
idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)
func main() {
client := idealpostcodes.NewClient("ak_test", idealpostcodes.WithManagementKey("uk_test"))
res, err := client.ListLicensees(context.Background(), "ak_test", &idealpostcodes.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)
}