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
- Find the tenant by ID (throws
ResourceNotFoundExceptionif not found or soft-deleted) - Validate the update request against the current tenant state
- Apply updates via
TenantMapper.updateEntity() - Save to the database
- Evict all tenant cache entries (
@CacheEvict(value = "tenants", allEntries = true)) - 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
| File | Path |
|---|---|
| Controller | control-plane/tenant-service/src/main/java/com/matih/tenant/controller/TenantController.java |
| Update DTO | control-plane/tenant-service/src/main/java/com/matih/tenant/dto/request/UpdateTenantRequest.java |
| Service | control-plane/tenant-service/src/main/java/com/matih/tenant/service/TenantService.java |