Licensees
A licensee is a client of yours that uses Ideal Postcodes data under your key. Sublicensing lets a platform serve many clients from one account and one bill, with each client's usage kept separate. The licensee methods create, list, update and cancel them.
Your key must be a sublicensing key; contact us to convert one. Every method needs a Management Key.
Add a licensee
Call CreateLicenseeAsync() with the client's legal name and address. The result carries the licensee's own key, beginning sl_, in Key, and its Id for the other methods.
using IdealPostcodes;
using var client = new IdealPostcodesClient("ak_test", Environment.GetEnvironmentVariable("IDPC_MANAGEMENT_KEY"));
var licensee = (await client.CreateLicenseeAsync("ak_test", new CreateLicenseeBody
{
Name = "Example Ltd",
Address = "9 Malyons Road, Swanley",
Postcode = "BR8 7RE",
Whitelist = ["https://www.example.com"],
})).Result;
Console.WriteLine($"{licensee.Id} {licensee.Key}");
Your licensees must accept Royal Mail's terms of use. Including them in your own terms is enough.
List licensees
ListLicenseesAsync() returns 10 per call by default and up to 100 with Limit, oldest first, without cancelled ones. To fetch the next page, set StartingAfter to the last licensee's Id. HasMore says whether another page exists.
using IdealPostcodes;
using var client = new IdealPostcodesClient("ak_test", Environment.GetEnvironmentVariable("IDPC_MANAGEMENT_KEY"));
var query = new ListLicenseesParams { Limit = 100 };
LicenseesResult page;
do
{
page = (await client.ListLicenseesAsync("ak_test", query)).Result;
foreach (var licensee in page.Licensees)
{
Console.WriteLine($"{licensee.Name}: {licensee.Daily.Count} lookups today");
query.StartingAfter = licensee.Id;
}
} while (page.HasMore);
Change or cancel
Pass the key and the licensee's Id:
UpdateLicenseeAsync()changes theName,Address,Postcode, allowed URLs (Whitelist) orDailylimitRegenerateLicenseeKeyAsync()issues a newsl_key. The old one stops working at onceDeleteLicenseeAsync()cancels the licensee. Its key stops working. Contact us to reverse it
RetrieveLicenseeAsync() returns one licensee by Id.
Billing
Each licensee buys lookups in blocks of 100, so a client who uses 60 lookups is billed for 100 and the next 40 cost nothing. Report one licensee's usage by setting Licensee on the parameters of KeyUsageAsync() or KeyLogsAsync(). See API keys.
See CreateLicenseeAsync() and ListLicenseesAsync() for the body and parameters.