MATIH Platform is in active MVP development. Documentation reflects current implementation status.
7. Tenant Lifecycle
Tenant Management
Overview

Tenant Management

Tenant management covers the full CRUD lifecycle of tenant organizations within the MATIH platform. The TenantController at /api/v1/tenants provides paginated listing, search, creation, update, suspension, activation, and soft deletion of tenants.


Key Concepts

ConceptDescription
TenantAn organization on the platform with isolated resources, users, and data
SlugA unique, URL-safe identifier (3-63 chars, lowercase alphanumeric with hyphens)
TierSubscription level: FREE, STARTER, PROFESSIONAL, ENTERPRISE
StatusLifecycle state: PENDING, PROVISIONING, ACTIVE, UPGRADING, SUSPENDED, FAILED, DELETED
Soft DeleteTenants are never physically removed; they are marked deleted=true with a timestamp

Controller Overview

The TenantController is mapped to /api/v1/tenants and provides the following operations:

@RestController
@RequestMapping("/api/v1/tenants")
@Tag(name = "Tenants", description = "Tenant management APIs")
public class TenantController {
    private final TenantService tenantService;
    private final ProvisioningService provisioningService;
    private final TenantResourceRepository resourceRepository;
    private final TenantMapper tenantMapper;
}

Endpoints Summary

MethodPathDescription
POST/api/v1/tenantsCreate a new tenant
GET/api/v1/tenantsList tenants (paginated)
GET/api/v1/tenants/{id}Get tenant by ID
GET/api/v1/tenants/slug/{slug}Get tenant by slug
PUT/api/v1/tenants/{id}Update tenant
POST/api/v1/tenants/{id}/upgradeUpgrade tenant tier
POST/api/v1/tenants/{id}/suspendSuspend tenant
POST/api/v1/tenants/{id}/activateActivate suspended tenant
DELETE/api/v1/tenants/{id}Soft delete tenant
GET/api/v1/tenants/{id}/resourcesGet provisioned resources
GET/api/v1/tenants/statsGet tenant statistics

Service Layer

The TenantService handles business logic with caching and transactional support:

  • Caching: Tenant lookups are cached using @Cacheable(value = "tenants") and evicted on mutations with @CacheEvict
  • Validation: TenantValidationService validates create and update requests
  • Duplicate Detection: Checks for duplicate slugs and admin emails before creation
  • Tier Defaults: Automatically applies resource limits based on the selected tier

Sections

PageDescription
Creating TenantsTenant creation flow, validation rules, and tier defaults
Updating TenantsUpdating properties and changing subscription plans
Tenant Status LifecycleSuspend, activate, and deletion workflows
Tenant StatisticsPlatform-wide statistics and usage metrics
Self-Service PortalTenant settings, team invitations, and self-service features