Configure secure multi-tenant architecture for enterprise organizations
Manage multiple organizations with complete data isolation and custom branding
Single database with tenant_id columns
Separate database per tenant
// Configuration
{
"multiTenancy": {
"enabled": true,
"mode": "shared_database", // or "isolated_database"
"tenantIdentifier": "subdomain" // or "header" or "path"
}
}POST https://api.cognexiaai.com/v1/tenants
{
"name": "Acme Corporation",
"subdomain": "acme",
"settings": {
"timezone": "America/New_York",
"currency": "USD",
"dateFormat": "MM/DD/YYYY"
},
"branding": {
"logo": "https://cdn.acme.com/logo.png",
"primaryColor": "#0066CC",
"customDomain": "erp.acme.com"
}
}Set up tenant-specific authentication and authorization.
// Middleware for tenant resolution
function resolveTenant(req, res, next) {
const subdomain = req.hostname.split('.')[0];
// Load tenant from database
const tenant = await getTenantBySubdomain(subdomain);
if (!tenant) {
return res.status(404).send('Tenant not found');
}
req.tenant = tenant;
next();
}Row-Level Security
All queries automatically filtered by tenant_id
User Segregation
Users can only access their tenant's data
Cross-Tenant Prevention
API validates tenant context on every request
// Tenant branding configuration
{
"tenantId": "acme",
"branding": {
"logo": {
"light": "https://cdn.acme.com/logo-light.png",
"dark": "https://cdn.acme.com/logo-dark.png"
},
"colors": {
"primary": "#0066CC",
"secondary": "#FF6B35",
"accent": "#4ECDC4"
},
"fonts": {
"heading": "Inter",
"body": "Inter"
},
"customDomain": "erp.acme.com",
"customCSS": ".custom-header { ... }"
}
}Automated tenant creation with default settings and sample data
Per-tenant usage tracking and subscription management
Tenant-specific backup policies and point-in-time recovery
Tools to move tenants between regions or architectures