Skip to main content

Update a tenant with the .NET SDK

permitClient.Api.UpdateTenant() changes the name, description, or attributes of an existing tenant in the environment that your API key belongs to. This reference is for .NET developers who manage tenants from backend code.

UpdateTenant signature

public async Task<TenantRead> UpdateTenant(string tenantKey, TenantUpdate tenantUpdate)

UpdateTenant parameters

ParameterTypeRequiredDescription
tenantKeystringYesThe key of the tenant to update. The tenant ID also works.
tenantUpdateTenantUpdateYesThe properties to change. The TenantUpdate class is in the PermitSDK.OpenAPI.Models namespace.

TenantUpdate properties

UpdateTenant is a partial update. The Permit API changes only the properties you set, and each property you set replaces the stored value completely. For example, setting Attributes replaces all the tenant's attributes, not only the keys you pass.

PropertyTypeRequiredDescription
Namestring?NoA descriptive name for the tenant.
Descriptionstring?NoA longer description of the tenant.
Attributesobject?NoTenant attributes that attribute-based access control (ABAC) policies evaluate, as key-value pairs.

Build a TenantUpdate object named tenant with the properties to change. Replace the placeholder values name and description with the new values:

var tenant = new TenantUpdate
{
Name = "name",
Description = "description"
};

Example: update a tenant with UpdateTenant

The example uses a client named permitClient, created with new Permit(...) as shown in Check permissions with the .NET SDK. tenantId holds the key of the tenant, and tenant is a TenantUpdate object:

var response = await permitClient.Api.UpdateTenant(tenantId, tenant);

UpdateTenant return value and errors

On success, UpdateTenant returns a TenantRead with the updated tenant.

If the Permit API returns an error, UpdateTenant throws a PermitApiException. The exception's StatusCode property has the HTTP status, such as 404 when no tenant with that key exists, and its Response property has the response body.