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
- A
permitclient created with an API key for the environment. See Create a Permit client.
Method signature
| Method | Signature | Status |
|---|---|---|
permit.api.tenants.get | get(tenantKey: string): Promise<TenantRead> | Recommended |
permit.api.getTenant | getTenant(tenantId: string): Promise<TenantRead> | Deprecated alias with the same argument |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tenantKey | string | Yes | Key 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.