Skip to main content

Get a tenant with the Node.js SDK

permit.api.tenants.get() fetches one tenant, identified by key or ID, from the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who read tenant data from code.

Prerequisites​

Method signature​

MethodSignatureStatus
permit.api.tenants.getget(tenantKey: string): Promise<TenantRead>Recommended
permit.api.getTenantgetTenant(tenantId: string): Promise<TenantRead>Deprecated alias with the same argument

Parameters​

NameTypeRequiredDescription
tenantKeystringYesKey or ID of the tenant to fetch.

Example​

const tenant = await permit.api.tenants.get(tenantKey);

Return value​

The method resolves to a TenantRead object with these fields: key, id, name, description, attributes, organization_id, project_id, environment_id, created_at, updated_at, and last_action_at. The last_action_at field holds the time of the last permission check on a resource in the tenant.

If the tenant doesn't exist or the Permit API returns another error status code, permit.api.tenants.get() throws a PermitApiError. The deprecated permit.api.getTenant() rethrows the underlying Axios error.