Skip to main content

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 create_licensee 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.

create.rbruby
require "ideal_postcodes"

client = IdealPostcodes::Client.new(api_key: "ak_test", management_key: ENV.fetch("IDPC_MANAGEMENT_KEY"))
licensee = client.create_licensee(
"ak_test",
name: "Example Ltd",
address: "9 Malyons Road, Swanley",
postcode: "BR8 7RE",
whitelist: ["https://www.example.com"]
).result

puts "#{licensee.id} #{licensee.key}"

Your licensees must accept Royal Mail's terms of use. Including them in your own terms is enough.

List licensees​

list_licensees returns 10 per call by default and up to 100 with limit:, oldest first, without cancelled ones. To fetch the next page, pass the last licensee's id as starting_after:. has_more says whether another page exists.

list.rbruby
starting_after = nil

loop do
page = client.list_licensees("ak_test", limit: 100, starting_after: starting_after).result
page.licensees.each { |licensee| puts "#{licensee.name}: #{licensee.daily.count} lookups today" }
break unless page.has_more

starting_after = page.licensees.last.id
end

Update or cancel​

Pass the key and the licensee's id:

  • update_licensee changes the name:, address:, postcode:, allowed URLs (whitelist:) or daily: limit
  • regenerate_licensee_key issues a new sl_ key. The old one stops working at once
  • delete_licensee cancels the licensee. Its key stops working. Contact us to reverse it

retrieve_licensee 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 passing licensee: to key_usage or key_logs. See API keys.

To make requests on a licensee's behalf, create a client with its sl_ key as api_key:.

See create_licensee and list_licensees for every keyword.