Add a permission of your own and check it
Define a permission your app checks, such as exporting reports, give it to workspace roles in the console, and check it in your app and on your server.
BuildBase enforces its own permissions, such as who may invite a member or
manage billing. Your app has its own: may this member export a report, publish
a document, see the audit page. You define those in the console beside
BuildBase's, give them to workspace roles, and your app and your server ask the
same question. This guide adds app:reports:export for Acme Analytics and
gives it to editors.
Before you start
Workspaces in Platform mode (permissions are not used in Personal mode; see mode and limits), a console role that can update workspace settings, and room in your plan for one more permission.
1. Open Permissions
Open Workspace configuration in the console
(opens the console in a new tab)In the left rail choose Users, then Settings under Workspaces, and scroll to Permissions. Under Your app's permissions, press Add permission.

2. Name it
Fill the three fields of the new row:
- The key, what your code checks: lowercase letters, digits and
. : _ -, up to 64 characters, such asapp:reports:export. Keys starting withworkspace:,buildbase:,system:ororg:are BuildBase's. - The label, what your team reads, such as
Export reports. - A group, optional, such as
Reports, to file it under in the matrix.

3. Give it to roles
The permission appears in the matrix below, under its group. Switch it on for each role that may use it. Admin holds every permission, yours included, so its switch is locked on.

4. Save
Press Save permissions. It saves the new permission and who has it in one go.

5. See it in the change history
Change history, at the bottom of the page, shows the permission added and the role given it.

6. Check it in your app and on your server
In your app, usePermissions() answers for the person in their current
workspace:
import { usePermissions } from '@buildbase/sdk/react';
export function ReportActions() {
const { can } = usePermissions();
return can('app:reports:export') ? <ExportButton /> : null;
}On your server, ask BuildBase rather than trusting the browser:
const res = await fetch(
`${serverUrl}/api/v1/public/workspaces/${workspaceId}/permissions/me`,
{ headers: { 'x-session-id': sessionId } }
);
const { data } = await res.json(); // { role, isOwner, permissions: string[] }
if (!data.permissions.includes('app:reports:export')) return forbidden();A workspace can change what each role may do for itself. On the permissions
screen of the SDK's settings dialog (openWorkspaceSettings('permissions')),
the workspace's creator ticks a permission for a role and presses Save
Permissions; over the API, PATCH /api/v1/public/workspaces/:workspaceId/permissions
takes the same change from any member with workspace:settings:edit. That
workspace's answer then comes from its own choice; every other workspace keeps
yours. The screen appears only once your organization has a permission of its
own, such as the one this guide adds.

Check it works
Sign in to your app as an editor: the export button shows. Sign in as a viewer:
it does not. permissions/me gives each of them the same answer.
Things to watch out for
- A key cannot be renamed. Every grant points at it by name. Remove the permission and add the new key.
- Removing a permission removes its grants everywhere, workspace overrides included.
- At most 100 permissions, whatever the plan, and your plan may allow fewer: the counter beside Add permission shows where you are.
- Nobody below admin grants more than they hold. A workspace member cannot change their own role's permissions or give a role something they lack.
Next Steps
- Permissions and roles - the roles, the matrix and how a workspace overrides it.
- Checking permissions - every constant and check.
- Mode and limits - the roles a member can hold.