Roles
TheX-External-Roles header specifies which roles a user has, controlling which documents they can access. This is the foundation of DocBit AI’s role-based access control (RBAC).
What are Roles?
Roles are strings that represent permission groups. When a user queries the AI, they only see answers from documents that match their roles.How Roles Work
1. You Assign Roles to Documents
When uploading documents, specify which roles can access them:2. You Pass User’s Roles in Requests
When a user queries, include their roles:3. DocBit AI Filters Results
The AI only sees documents the user has access to:| Document | ACL Roles | User has hr, all-staff | Visible? |
|---|---|---|---|
| HR Policy | hr | ✅ Has hr | Yes |
| Handbook | all-staff | ✅ Has all-staff | Yes |
| Financials | finance | ❌ No match | No |
Role Format
Pass roles as a JSON array in the header:Requirements
- At least one role required - Empty arrays are rejected
- Case-sensitive -
HRandhrare different roles - No special characters needed - Use simple strings
Common Role Patterns
Department-Based
Hierarchy-Based
Project-Based
Access Levels
Roles vs Document ACLs
| Concept | What it is | Who sets it |
|---|---|---|
| User Roles | Permissions the user has | You, via X-External-Roles |
| Document ACL | Roles required to access | You, when uploading (aclRoles) |
Dynamic Role Assignment
You control roles at request time, enabling dynamic access:Wildcard Access
Documents uploaded withoutaclRoles are accessible to everyone in the organization:
aclRoles when uploading.
Best Practices
Keep roles simple
Keep roles simple
Start with a small set of roles. You can always add more later.
Use consistent naming
Use consistent naming
Stick to lowercase, hyphenated names:
project-alpha, not Project Alpha.Map to your existing groups
Map to your existing groups
If you have user groups in your system, use the same names as roles.
Don't over-grant roles
Don't over-grant roles
Only pass roles the user actually has. Don’t give everyone admin access.
Include a base role
Include a base role
Consider an
all-staff or employee role for company-wide documents.