Skip to main content

List tenants with the Node.js SDK

permit.api.tenants.list() lists the tenants in the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who read or search tenants from code.

Prerequisites

Method signature

MethodSignature
permit.api.tenants.listlist(params?: IListTenantsParams): Promise<TenantRead[]>

Parameters

permit.api.tenants.list() takes one optional object with these fields:

FieldTypeRequiredDescription
searchstringNoText to match against the tenant name or key.
pagenumberNoPage number of the results, starting at 1.
perPagenumberNoNumber of results per page, up to 100. If you omit perPage, the Permit API applies its default page size.

Example

The example fetches the first 20 tenants whose name or key matches example.

await permit.api.tenants.list({
search: "example",
page: 1,
perPage: 20,
});

Return value

The method resolves to an array of TenantRead objects, one per tenant on the requested page. Each object has key, id, name, description, attributes, created_at, updated_at, and last_action_at. To read every tenant, request the next page until the array has fewer items than perPage.

If the Permit API returns an error status code, the method throws a PermitApiError.