KeyInteractive.Common.Api.Tenants 2.5.2

dotnet add package KeyInteractive.Common.Api.Tenants --version 2.5.2
                    
NuGet\Install-Package KeyInteractive.Common.Api.Tenants -Version 2.5.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KeyInteractive.Common.Api.Tenants" Version="2.5.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KeyInteractive.Common.Api.Tenants" Version="2.5.2" />
                    
Directory.Packages.props
<PackageReference Include="KeyInteractive.Common.Api.Tenants" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KeyInteractive.Common.Api.Tenants --version 2.5.2
                    
#r "nuget: KeyInteractive.Common.Api.Tenants, 2.5.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KeyInteractive.Common.Api.Tenants@2.5.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KeyInteractive.Common.Api.Tenants&version=2.5.2
                    
Install as a Cake Addin
#tool nuget:?package=KeyInteractive.Common.Api.Tenants&version=2.5.2
                    
Install as a Cake Tool

Key Interactive.Common.Api.Tenants

KeyInteractive.Common.Api.Tenants is the .NET client for platforms integrating Key Interactive tenant (business) accounts — first use case: MessagingService, the WhatsApp multitenant platform where reseller software houses need to log their own tenant in and manage their team from their own backend.

It gives you a ready-to-use ITenantsApiConsumer/TenantsApiConsumer service wrapping tenant login, tenant identity/profile (including PartnerCode), and team management (invite/list/remove members, change roles) behind simple method calls.

This is NOT the full tenant dashboard client — that stays private in the Key Interactive solution and covers the whole tenant.keyinteractive.it experience (billing, fiscal data, etc.). This package only exposes what a first-party/trusted platform needs after a tenant has connected: identity and team.

It's built on KeyInteractive.Common.Api, which provides the generic API-consuming plumbing (response envelope, retry, JWT handling) that TenantsApiConsumer inherits. It has no dependency on KeyInteractive.Common.Api.Users — the two packages are used by different kinds of callers (end-user platforms vs. tenant-integrating platforms) and don't need to know about each other, so a few small types (e.g. the login DTO, ETenantMemberRole) are duplicated locally rather than shared.

Requirements

Targets .NET 8.0 or later (net8.0, net10.0).

Installation

dotnet add package KeyInteractive.Common.Api.Tenants

Configuration and dependency injection (ASP.NET Core backend)

Unlike KeyInteractive.Common.Api.Users, this package has no static configuration facade — it targets backends, so you pass KiApiConsumerOptions directly when registering the typed client:

// Program.cs
builder.Services.AddScoped<ITokenProvider, TokenProvider>();
builder.Services.AddHttpClient<ITenantsApiConsumer, TenantsApiConsumer>();
builder.Services.AddSingleton(new KiApiConsumerOptions
{
    BaseUri = "https://accounts.keyinteractive.it/",
    ApiKey = "your-api-key",                 // your Application's KI credentials
    ApplicationKey = "your-application-id",
    ApiVersion = "v1",
    StorageKeyPrefix = "kitenant",            // unique per consumer if your process also uses another KI client
});

ITokenProvider must be registered Scoped: it holds the current tenant's JWT for one request/circuit. Requires an Application registered with Key Interactive with its own ApiKey/ApplicationKey — tenant login through this package is meant for first-party/trusted platforms, not arbitrary third parties.

Usage examples

Log a tenant in

using KeyInteractive.Common.Api.Tenants.DTO.TenantsApi;

var login = await tenantsApiConsumer.LoginTenant(new TenantLoginDto(
    loginCredentials: "acme@example.com",
    password: "Sup3rSecret!",
    deviceName: Environment.MachineName,
    deviceIp: "127.0.0.1"));

if (login.Success)
{
    // tenantsApiConsumer is now authenticated (SetAuthTokens was applied automatically)
    var profile = await tenantsApiConsumer.GetTenantProfile();

    Console.WriteLine($"{profile.Profile.Email} — PartnerCode: {profile.Profile.PartnerCode}");
}

profile.Profile.TenantId carries the exact same value as PartnerCode, just under a neutral name — use it if your platform doesn't otherwise relate to Partner Visibility and only needs a stable, opaque key for the logged-in tenant.

Manage the team

using KeyInteractive.Common.Api.Tenants.Enums;

// Comportamento di sempre: KI manda la propria email
await tenantsApiConsumer.InviteTeamMember("collega@azienda.it", ETenantMemberRole.Member);

// Notifica gestita da voi: nessuna email da KI, usate il token per la vostra
var invite = await tenantsApiConsumer.InviteTeamMember("collega@azienda.it", ETenantMemberRole.Member, sendInvitationEmail: false);
if (invite.Success)
{
    // costruite e spedite la vostra email/notifica con invite.Token
}

// Oppure: email la manda ancora KI, ma il link punta al vostro dominio
tenantsApiConsumer.SetSiteBaseUrl("https://app.vostro-dominio.it");
await tenantsApiConsumer.InviteTeamMember("collega@azienda.it", ETenantMemberRole.Member);

var members = await tenantsApiConsumer.GetTeamMembers();
if (members.Success)
{
    foreach (var m in members.Members)
        Console.WriteLine($"{m.Name} {m.Surname} ({m.Role}) — member since {m.MemberSince:d}");
}

var invitations = await tenantsApiConsumer.GetTeamInvitations();
// await tenantsApiConsumer.RevokeTeamInvitation(invitations.Invitations[0].Id);

await tenantsApiConsumer.UpdateTeamMemberRole(userId: 42, role: ETenantMemberRole.Admin);
await tenantsApiConsumer.RemoveTeamMember(userId: 42);

See ITenantsApiConsumer for the full list of available operations (login, profile, logout/forgot/reset password, and team management).

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.5.2 93 9/3/2026
2.5.1 100 8/26/2026
2.5.0 94 8/26/2026
2.4.0 99 8/24/2026
2.3.0 97 8/24/2026