Update a tenant with the Node.js SDK
permit.api.tenants.update() changes the fields of an existing tenant in the Permit.io environment that your Node.js SDK client is connected to. This reference is for backend developers who keep tenant data in Permit in step with their application.
Prerequisites
- A
permitclient created with an API key for the environment. See Create a Permit client. - An existing tenant. See Create a tenant with the Node.js SDK.
Method signature
| Method | Signature | Status |
|---|---|---|
permit.api.tenants.update | update(tenantKey: string, tenantData: TenantUpdate): Promise<TenantRead> | Recommended |
permit.api.updateTenant | updateTenant(tenantId: string, tenant: TenantUpdate): Promise<TenantRead> | Deprecated alias with the same arguments |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tenantKey | string | Yes | Key or ID of the tenant to update. |
tenantData | TenantUpdate | Yes | Object with the fields to change. Pass the object itself, not a JSON string. |
The TenantUpdate object accepts these fields. The tenant key can't be changed.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Display name of the tenant. |
description | string | No | Longer description of the tenant. |
attributes | object | No | Tenant attributes that attribute-based access control (ABAC) policies can evaluate. |
Example TenantUpdate object:
{
name: "name",
description: "description",
attributes: {}
}
Example
const response = await permit.api.tenants.update(tenantKey, tenant);
Return value
The method resolves to the updated TenantRead object, including key, id, name, description, attributes, and updated_at.
If the tenant doesn't exist or the Permit API returns another error status code, permit.api.tenants.update() throws a PermitApiError. The deprecated permit.api.updateTenant() rethrows the underlying Axios error.