Roles and permissions
Model your organisation's own roles, decide what each may do, require confirmations and keep every user inside their own records.
BotBaseX has no built-in roles. Every organisation is different: a school has head teachers and teachers, a pharmacy has pharmacists and cashiers, an office has managers and HR. You define the roles; BotBaseX enforces them.
#How access is decided
For each message, the server works out what the signed-in user may do:
- The connection decides which operations exist at all: configured, tested with the current settings, and allowed.
- The user's roles decide which of those this person may use. A user with several roles gets the combination of all their roles.
- Bindings fix some inputs to the user's own identity.
- Confirmation rules decide which operations wait for the user's "yes".
The AI is shown only the result. If it still asks for anything else, for example because a message tried to trick it, the server refuses and records denied in the audit log.
#Creating roles
In Management system → Roles and permissions:
- Type a role name and click Add role. The key is generated from the name:
Head teacherbecomeshead_teacher. - Tick the operations the role may use.
- Click Save roles.
Your backend must send the same keys when it creates a session:
{ "user": { "id": "T-17", "name": "Neema Mushi", "roles": ["teacher"] } }- Role keys are case-insensitive (
Teacherandteachermatch). - Keys your configuration does not know are ignored. The session response lists them in
ignored_rolesso you can spot typos. - A user with no known role can still chat, but only about your general knowledge. They have no system access.
- You can have up to 30 roles, and a user can carry up to 20.
#Confirmations
| Operation | Behaviour |
|---|---|
| Lookup (GET) | Runs straight away, unless a role marks it confirm |
| Change (POST, PUT, PATCH) | Always prepared first; runs only after the user confirms in a later message |
Tick confirm under a lookup for sensitive reads, for example salary or medical records, so the user must explicitly ask to open them.
A confirmation:
- belongs to the user who prepared it. Another user, even with the same role, cannot confirm it;
- expires after 30 minutes;
- is re-authorised when confirmed. If you remove the permission in between, it is cancelled;
- runs once, even if the user says "yes" twice. Each write carries an
Idempotency-Keyheader your API can use to de-duplicate.
#Keeping users inside their own records
Permissions decide which operation a user may call. Bindings decide whose data it returns. Bind an input to the session and the AI can no longer choose it:
| Operation input | Bound to | Effect |
|---|---|---|
my_classes.teacher_id | user.id | A teacher only sees their own classes |
list_students.school_id | attr.school_id | Staff of a multi-school group only see their school |
branch_sales.branch | attr.branch | A pharmacy cashier only sees their branch |
Attributes come from your server in the session ("attributes": {"school_id": "S-1"}). If a bound value is missing, the operation is refused rather than run without the limit.
#Changing and revoking access
| Change | When it applies |
|---|---|
| Untick an operation for a role | Immediately, from the user's next message |
| A user's roles change in your system | At their next session (sessions last 5–60 minutes). To apply at once, revoke their sessions: POST /management/v1/users/{id}/revoke |
| A staff member leaves or logs out | Revoke their sessions the same way |
| Pause the agent | Immediately, for everyone |
| End one session | Active sessions → End in the dashboard |
#Good practice
- Start with read-only roles, test them, then add actions.
- Prefer several narrow operations (
get_attendance,get_fee_balance) over one powerful one. - Use confirm for anything personal or financial.
- Test each role with Test as a role, including what it must not be able to do.