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 Roles
Section titled “List Roles”List all roles configured for your app.
HTTP Request
Section titled “HTTP Request”GET https://api.thebridge.dev/account/role
Response HTTP 200
Section titled “Response HTTP 200”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
https://api.thebridge.dev/account/roleCreate a Role
Section titled “Create a Role”HTTP Request
Section titled “HTTP Request”POST https://api.thebridge.dev/account/role
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Required | A presentable label for this role |
key | string | Required | A unique key for this role |
description | string | Optional | Optional description |
privileges | string[] | Required | A list of privilege IDs. Cannot be empty |
isDefault | boolean | Optional | If true, will be applied to new tenant users. Only one role can be default |
Response HTTP 200
Section titled “Response HTTP 200”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
https://api.thebridge.dev/account/roleUpdate a Role
Section titled “Update a Role”HTTP Request
Section titled “HTTP Request”PUT https://api.thebridge.dev/account/role/:ROLE_ID
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Optional | A presentable label for this role |
key | string | Optional | A unique key. The OWNER key cannot be changed |
description | string | Optional | Optional description |
privileges | string[] | Optional | A list of privilege IDs |
isDefault | boolean | Optional | Cannot change from true to false |
Response HTTP 200
Section titled “Response HTTP 200”Returns the updated Role model.
PUT Try it out
https://api.thebridge.dev/account/role/:ROLE_IDDelete a Role
Section titled “Delete a Role”Delete an existing role. Default roles and the OWNER role cannot be deleted. Deleting a role will not remove related privileges.
HTTP Request
Section titled “HTTP Request”DELETE https://api.thebridge.dev/account/role/:ROLE_ID
Response HTTP 200
Section titled “Response HTTP 200”DELETE Try it out
https://api.thebridge.dev/account/role/:ROLE_IDList Privileges
Section titled “List Privileges”HTTP Request
Section titled “HTTP Request”GET https://api.thebridge.dev/account/role/privilege
Response HTTP 200
Section titled “Response HTTP 200”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
https://api.thebridge.dev/account/role/privilegeCreate a Privilege
Section titled “Create a Privilege”HTTP Request
Section titled “HTTP Request”POST https://api.thebridge.dev/account/role/privilege
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Required | A unique key for this privilege |
description | string | Optional | Optional description |
Response HTTP 200
Section titled “Response HTTP 200”HTTP 200 — Returns the created privilege object.
Response example:
{ "id": "6516b9cb492d28b55cca8daf", "key": "SENSITIVE_DATA", "description": "Access to sensitive data"}POST Try it out
https://api.thebridge.dev/account/role/privilegeUpdate a Privilege
Section titled “Update a Privilege”HTTP Request
Section titled “HTTP Request”PUT https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID
Response HTTP 200
Section titled “Response HTTP 200”PUT Try it out
https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_IDDelete a Privilege
Section titled “Delete a Privilege”HTTP Request
Section titled “HTTP Request”DELETE https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID
Response HTTP 200
Section titled “Response HTTP 200”DELETE Try it out
https://api.thebridge.dev/account/role/privilege/:PRIVILEGE_ID