createLicensee

Create

Creates a licensee on a key and returns it with its generated sl_ key. The key must be enabled for sublicensing.

Endpoint​

POST /keys/{key}/licensees

See the API reference for this endpoint.

This operation needs a Management Key. Set it as userToken on the client, which sends it in the Authorization header. See setup.

Import​

import { createLicensee } from "@ideal-postcodes/sdk";

Path Parameters​

NameTypeRequiredDescription
keystringyesAPI Key The API Key. Begins ak_.

Query Parameters​

None.

Request Body​

import type { LicenseeEditable } from "@ideal-postcodes/sdk";

Response Type​

import type { CreateLicenseeResponse } from "@ideal-postcodes/sdk";

The result property has the type Licensee.

import type { Licensee } from "@ideal-postcodes/sdk";

Errors​

HTTP errors throw an ApiError with the HTTP status and the API error code and message. Network failures and aborts reject with the runtime's native error. Pass throwOnError: false to get { data, error } instead. See error handling.

Example​

create-licensee.tsts
import { createIdpcClient, createLicensee } from "@ideal-postcodes/sdk";

export const example = async () => {
  const client = createIdpcClient({ userToken: "uk_example" });
  const { data } = await createLicensee({
    client,
    path: { key: "ak_test" },
    body: { name: "Example Company" },
  });
  return data;
};