Skip to content

Access Control

Access roles and privileges enable you to manage and specify the level of access that different users have within your application.

To effectively control user access, you must first create a set of Privileges and associate them with a Role. Then you can assign these roles to individual Tenant users and ensure that their privileges are evaluated for various actions within the application.


List all roles configured for your app.

GET https://api.thebridge.dev/account/role

HTTP 200 — Array of Role model.

Request example

curl --request GET 'https://api.thebridge.dev/account/role' \
--header 'x-api-key: YOUR_APP_API_KEY'

Response example:

[
{
"id": "650cd8510ccba777cc9623de",
"name": "OWNER",
"key": "OWNER",
"privileges": [
{
"id": "650cd8510ccba777cc9623d4",
"key": "AUTHENTICATED",
"description": "Privilege for all authenticated users"
}
],
"isDefault": false
}
]
GET Try it out
GET https://api.thebridge.dev/account/role
Stored in session memory only. Never persisted.

POST https://api.thebridge.dev/account/role

Body Parameters

ParameterTypeRequiredDescription
namestringRequiredA presentable label for this role
keystringRequiredA unique key for this role
descriptionstringOptionalOptional description
privilegesstring[]RequiredA list of privilege IDs. Cannot be empty
isDefaultbooleanOptionalIf true, will be applied to new tenant users. Only one role can be default

Returns the created Role model.

Request example

curl --request POST 'https://api.thebridge.dev/account/role' \
--header 'x-api-key: YOUR_APP_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "Admin",
  "key": "ADMIN",
  "description": "Admin with user read privileges",
  "privileges": ["650cd8510ccba777cc9623d4", "650cd8510ccba777cc9623d5"],
  "isDefault": false
}'
POST Try it out
POST https://api.thebridge.dev/account/role
Stored in session memory only. Never persisted.

PUT https://api.thebridge.dev/account/role/:ROLE_ID

Body Parameters

ParameterTypeRequiredDescription
namestringOptionalA presentable label for this role
keystringOptionalA unique key. The OWNER key cannot be changed
descriptionstringOptionalOptional description
privilegesstring[]OptionalA list of privilege IDs
isDefaultbooleanOptionalCannot change from true to false

Returns the updated Role model.

PUT Try it out
PUT https://api.thebridge.dev/account/role/:ROLE_ID
Stored in session memory only. Never persisted.
The ID of the role

Delete an existing role. Default roles and the OWNER role cannot be deleted. Deleting a role will not remove related privileges.

DELETE https://api.thebridge.dev/account/role/:ROLE_ID

DELETE Try it out
DELETE https://api.thebridge.dev/account/role/:ROLE_ID
Stored in session memory only. Never persisted.
The ID of the role

GET https://api.thebridge.dev/account/role/privilege

HTTP 200 — Array of privilege objects.

Request example

curl --request GET 'https://api.thebridge.dev/account/role/privilege' \
--header 'x-api-key: YOUR_APP_API_KEY'

Response example:

[
{ "id": "650cd8510ccba777cc9623d4", "key": "AUTHENTICATED", "description": "Privilege for all authenticated users" },
{ "id": "650cd8510ccba777cc9623d5", "key": "USER_READ" },
{ "id": "650cd8510ccba777cc9623d6", "key": "USER_WRITE" },
{ "id": "650cd8510ccba777cc9623d7", "key": "TENANT_READ" },
{ "id": "650cd8510ccba777cc9623d8", "key": "TENANT_WRITE" }
]
GET Try it out
GET https://api.thebridge.dev/account/role/privilege
Stored in session memory only. Never persisted.

POST https://api.thebridge.dev/account/role/privilege

Body Parameters

ParameterTypeRequiredDescription
keystringRequiredA unique key for this privilege
descriptionstringOptionalOptional description

HTTP 200 — Returns the created privilege object.

Response example:

{
"id": "6516b9cb492d28b55cca8daf",
"key": "SENSITIVE_DATA",
"description": "Access to sensitive data"
}
POST Try it out
POST https://api.thebridge.dev/account/role/privilege
Stored in session memory only. Never persisted.

PUT https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID

PUT Try it out
PUT https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID
Stored in session memory only. Never persisted.
The ID of the privilege

DELETE https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID

DELETE Try it out
DELETE https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID
Stored in session memory only. Never persisted.
The ID of the privilege