$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 as the second argument to IdealPostcodes::client(), which sends it in the Authorization header. See setup.
Signature
public function listLicensees(string $key, array $params = []): LicenseesResponse
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
$key | string | yes | API Key |
$params | array | no | Query parameters. Keys under Query Parameters. |
Query Parameters
Pass these as keys of $params.
| Name | Type | Required | Description |
|---|---|---|---|
starting_after | int | no | ID of the licensee after which to list results |
limit | int | no | Limit |
query | string | no | Filter results by licensee name. Can be shortened to q= |
Response
IdealPostcodes\Responses\LicenseesResponse. Read fields as properties, such as $response->result, or as an array with the API's field names. toArray() returns the decoded body.
Errors
An HTTP error throws ApiException with the HTTP status, the API error code from getCode() and the decoded body. A transport failure throws TransporterException. See error handling.
Example
list-licensees.phpphp
<?php
declare(strict_types=1);
use IdealPostcodes\IdealPostcodes;
require 'vendor/autoload.php';
$client = IdealPostcodes::client('ak_test', 'uk_test');
$response = $client->listLicensees('ak_test', ['limit' => 10]);
foreach ($response->result->licensees as $licensee) {
echo $licensee->id, ': ', $licensee->name, ' (', $licensee->key, ')', PHP_EOL;
}
echo 'More pages: ', var_export($response->result->hasMore, true), PHP_EOL;