Get a tenant with the .NET SDK
permitClient.Api.GetTenant() fetches one tenant and its details from the environment that your API key belongs to. This reference is for .NET developers who read tenant data from backend code.
GetTenant signature
public async Task<TenantRead> GetTenant(string tenantKey)
GetTenant parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenantKey | string | Yes | The key of the tenant. The tenant ID also works. |
Example: get a tenant with GetTenant
The example uses a client named permitClient, created with new Permit(...) as shown in Check permissions with the .NET SDK. tenantId holds the key or ID of the tenant:
var tenant = await permitClient.Api.GetTenant(tenantId);
GetTenant return value and errors
On success, GetTenant returns a TenantRead with the tenant's Key, Id, Name, Description, Attributes, Created_at, and Updated_at.
If the Permit API returns an error, GetTenant throws a PermitApiException. The exception's StatusCode property has the HTTP status, such as 404 when no tenant with that key or ID exists, and its Response property has the response body.