Skip to content

Roles Module

SDK reference for role CRUD and user/form assignments

The roles module provides CRUD over roles plus user and form assignment helpers. Mutations require platform-admin or organization-admin privileges; reads (list, get, list_users, list_forms) work for any authenticated caller in scope.

from bifrost import roles
MethodReturnsDescription
roles.create()RoleCreate a role
roles.get()RoleLook up by ID
roles.list()list[Role]List roles in the current org
roles.update()RolePatch fields
roles.delete()NoneDelete (cascades assignments)
roles.list_users()list[str]List user IDs assigned to a role
roles.list_forms()list[str]List form IDs assigned to a role
roles.assign_users()NoneAssign users to a role
roles.assign_forms()NoneAssign forms to a role
async def create(name: str, description: str = "") -> Role
role = await roles.create("Customer Manager", description="Can manage customers")
async def get(role_id: str) -> Role

Raises ValueError if not found.

async def list() -> list[Role]

Lists every role visible to the caller in the current organization.

for role in await roles.list():
print(role.name)
async def update(role_id: str, **updates: Any) -> Role

Accepts patchable fields (e.g. name, description) as keyword arguments. Raises ValueError if not found.

await roles.update("role-123", description="Updated description")
async def delete(role_id: str) -> None

Deletes the role. Cascade removes all role assignments (user-role and form-role rows). Raises ValueError if not found.

async def list_users(role_id: str) -> list[str]

Returns the user IDs assigned to the role.

ids = await roles.list_users("role-123")
async def list_forms(role_id: str) -> list[str]

Returns the form IDs assigned to the role.

async def assign_users(role_id: str, user_ids: list[str]) -> None

Assign a batch of users to the role. Raises ValueError if the role or any referenced user is missing.

await roles.assign_users("role-123", ["user-1", "user-2"])
async def assign_forms(role_id: str, form_ids: list[str]) -> None

Assign a batch of forms to the role.

await roles.assign_forms("role-123", ["form-1", "form-2"])

Defined in bifrost.models. Fields include id, name, description, organization_id, is_active, and timestamps. See bifrost.models for the canonical definition.