Skip to main content

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

Method signature

MethodSignatureStatus
permit.api.tenants.updateupdate(tenantKey: string, tenantData: TenantUpdate): Promise<TenantRead>Recommended
permit.api.updateTenantupdateTenant(tenantId: string, tenant: TenantUpdate): Promise<TenantRead>Deprecated alias with the same arguments

Parameters

NameTypeRequiredDescription
tenantKeystringYesKey or ID of the tenant to update.
tenantDataTenantUpdateYesObject 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.

FieldTypeRequiredDescription
namestringNoDisplay name of the tenant.
descriptionstringNoLonger description of the tenant.
attributesobjectNoTenant 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.