What Problems Do Sub-accounts Solve?
1. Organizational Structure Management
- ✅ Create isolated account spaces for different departments or business units
- ✅ Maintain separate administrative control for each sub-account
- ✅ Enable independent data management per sub-account
- ✅ Support hierarchical organizational structures
2. Multi-tenant SaaS Applications
- ✅ Provide isolated data storage for each customer
- ✅ Enable customer-specific administrative access
- ✅ Maintain complete data separation between accounts
- ✅ Support white-label or reseller scenarios
3. Compliance and Data Isolation
- ✅ Ensure complete data isolation between sub-accounts
- ✅ Meet regulatory requirements for data separation
- ✅ Enable independent audit trails per sub-account
- ✅ Support compliance with data residency requirements
Implementation Approaches
Databunker Pro provides two primary approaches for implementing sub-accounts:- Multi-tenancy Support - Creates isolated tenants with dedicated admin tokens
- Groups with Roles and Policies - Uses Databunker Pro’s CRBAC system for group-based management
Approach 1: Multi-tenancy Support
Multi-tenancy is the recommended approach when you need complete data isolation and independent administrative control for each sub-account. After creating a tenant, you receive a tenant admin token that allows full management of all records within that tenant.How It Works
When you create a new tenant using the multi-tenancy feature:- A new isolated tenant is created with its own data namespace
- A tenant admin token is generated that provides full administrative access
- All records created within this tenant are completely isolated from other tenants at the database level. Note: Multi-tenancy is supported on PostgreSQL, MySQL, and Oracle; on PostgreSQL it is enforced with native row-level security (RLS).
- The tenant admin token can manage all user records, application data, and configurations within the tenant
Creating a Sub-account with Multi-tenancy
Using the Tenant Admin Token
The tenant admin token is one of several credential types — see the Authentication reference for the full hierarchy. Once you have the tenant admin token, you can use it to manage all records within that tenant:JavaScript/TypeScript Example
Python Example
Benefits of Multi-tenancy Approach
- Complete Data Isolation: Each tenant has its own isolated data namespace
- Independent Administration: Tenant admin tokens provide full control within the tenant
- Scalability: Supports unlimited tenants with database-level isolation
- Security: Built-in tenant separation at the database level
- Compliance: Meets data residency and isolation requirements
Approach 2: Groups with Roles and Policies
The groups approach leverages Databunker Pro’s Conditional Role-Based Access Control (CRBAC) system. Each group can store sub-accounts, and a group admin user manages all users within that group. This approach is implemented using roles and policies.How It Works
With the groups approach:- Create a group to represent the sub-account
- Assign a group admin role to a user who will manage the sub-account
- Create policies that grant the group admin access to manage users within the group
- Add users to the group as needed
- The group admin can manage all users within their assigned group
Creating a Sub-account with Groups
Creating Policies for Group Admin
Two policies let the group admin read, create, delete and list the users of their own group. Create them and link them to the role:- The condition
${user_group_id}=${target_group_id}holds only when the target user, or the group named in the request, is in the admin’s group. Users of other groups and users without a group are refused. ${target_group_id}.*gives full access once the condition matched through that group.BulkListUnlockhas no target user or group, so a policy with a condition never allows it. The second policy allows it without one. An unlock UUID returns no data by itself;BulkListGroupUsersstill checks the group.
Using the Group Admin Token
Create an access token for the group admin. The admin uses it to create users in the group:JavaScript/TypeScript Example
Benefits of Groups Approach
- Flexible Access Control: Fine-grained permissions using CRBAC policies
- Role-Based Management: Different roles can be assigned within groups
- Conditional Access: Policies can include complex conditions for access control
- Compliance Support: Supports FERPA, GDPR, and DPDPA compliance scenarios
- Hierarchical Structures: Supports parent-child relationships within groups
Choosing the Right Approach
Use Multi-tenancy When:
- You need complete data isolation between sub-accounts
- Each sub-account requires independent administrative control
- You’re building a multi-tenant SaaS application
- You need to meet strict data residency requirements
- You want database-level isolation for security
Use Groups Approach When:
- You need flexible, role-based access control within sub-accounts
- You want to implement hierarchical organizational structures
- You need conditional access policies (e.g., parent-child relationships)
- You’re building compliance-focused applications (FERPA, GDPR, DPDPA)
- You want fine-grained permissions for different user roles
Real-World Use Cases
1. SaaS Multi-tenant Application
Create isolated sub-accounts for each customer:2. Departmental Sub-accounts
Organize departments within an organization:3. Reseller/Partner Program
Enable partners to manage their own customer data:Security Considerations
Multi-tenancy Security
- Database-level isolation: Tenant data isolation is supported on PostgreSQL, MySQL, and Oracle; on PostgreSQL it is enforced with native row-level security (RLS)
- Token-Based Access: Tenant admin tokens are scoped to their tenant
- Audit Logging: All tenant operations are logged separately
- Encryption: Each tenant’s data is encrypted independently
Groups Security
- Policy Enforcement: CRBAC policies control all access
- Role Validation: Roles are verified before granting access
- Condition Checks: Policies include conditions for additional security
- Audit Trail: All group operations are logged with role information
Best Practices
- Token Management: Securely store and rotate tenant admin tokens
- Policy Design: Design policies carefully to ensure proper access control
- Regular Audits: Review sub-account access and permissions regularly
- Monitoring: Monitor sub-account activity for security and compliance
- Documentation: Document which approach is used for each sub-account
Choosing between them
The two combine: multi-tenancy for the database-level boundary, groups for fine-grained permissions within it.
Next steps
- Multi-tenancy — tenant API and database-level isolation
- Access control — policies, roles, and field masking
- Multi-jurisdiction deployment — when a separate instance beats a separate tenant