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

Updating Tenants

Tenants can be updated through the PUT /api/v1/tenants/{id} endpoint and the tier upgrade endpoint at POST /api/v1/tenants/{id}/upgrade. Updates are validated, cache entries are evicted, and changes are persisted transactionally.


Update Tenant Request

public class UpdateTenantRequest {
    private String name;
    private String description;
    private String contactEmail;
    private String billingEmail;
    private String billingAddress;
    private String taxId;
    private String logoUrl;
    private String domain;
    private String identityProvider;
    private Integer maxUsers;
    private Integer maxPipelines;
    private Integer maxQueriesPerDay;
    private Integer storageLimitGb;
    private Integer dataRetentionDays;
}

Update Flow

  1. Find the tenant by ID (throws ResourceNotFoundException if not found or soft-deleted)
  2. Validate the update request against the current tenant state
  3. Apply updates via TenantMapper.updateEntity()
  4. Save to the database
  5. Evict all tenant cache entries (@CacheEvict(value = "tenants", allEntries = true))
  6. Return updated TenantResponse

Example: Update Tenant

curl -X PUT http://localhost:8082/api/v1/tenants/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "name": "Acme Corporation (Updated)",
    "description": "Updated description",
    "contactEmail": "contact@acme.com",
    "maxUsers": 100
  }'

Tier Upgrade

The POST /api/v1/tenants/{id}/upgrade endpoint changes the tenant's subscription tier:

@PostMapping("/{id}/upgrade")
public ResponseEntity<TenantResponse> upgradeTier(
        @PathVariable UUID id,
        @Valid @RequestBody UpgradeTierRequest request) {
    TenantResponse response = tenantService.updateTenantTier(id, request.getNewTier());
    return ResponseEntity.ok(response);
}

When the tier changes, applyTierDefaults() recalculates resource limits. For complex tier migrations involving infrastructure changes, use the Tier Migration system instead.

curl -X POST http://localhost:8082/api/v1/tenants/a1b2c3d4-.../upgrade \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{ "newTier": "ENTERPRISE" }'

Source Files

FilePath
Controllercontrol-plane/tenant-service/src/main/java/com/matih/tenant/controller/TenantController.java
Update DTOcontrol-plane/tenant-service/src/main/java/com/matih/tenant/dto/request/UpdateTenantRequest.java
Servicecontrol-plane/tenant-service/src/main/java/com/matih/tenant/service/TenantService.java