Roles
Create a role
Create one role, or several at once by sending an array.
POST
/
role
Create a role
curl --request POST \
--url https://{instance}/api/v2/role \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"permissions": [
"<string>"
],
"permissionsV2": [
{
"subject": "<string>",
"actions": [],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
description: '<string>',
permissions: ['<string>'],
permissionsV2: [
{
subject: '<string>',
actions: [],
tableName: '<string>',
filters: {},
fields: {}
}
],
isApiKey: false,
createdAt: '2023-11-07T05:31:56Z',
updatedAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://{instance}/api/v2/role', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/role"
payload = {
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"permissions": ["<string>"],
"permissionsV2": [
{
"subject": "<string>",
"actions": [],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": False,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"value": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"permissions": [
"<string>"
],
"permissionsV2": [
{
"subject": "<string>",
"actions": [
"read"
],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}Authorizations
Organization-scoped API key. Create one in the BuildingSwell app under Organization settings, API keys.
Body
application/json
- object
- object[]
Role name. At least one character.
Minimum string length:
1Unique id. Generated on create unless you supply one.
What the role is for.
Legacy flat permission strings. Defaults to empty.
Legacy permission string.
Fine-grained permission statements. This is the form the app writes today.
Show child attributes
Show child attributes
true for the synthetic role behind an API key. Leave it alone on roles you create.
When the record was created.
When the record last changed.
Response
The created role. An array request returns values instead of value.
- Option 1
- Option 2
A named set of permissions you can assign to users.
Show child attributes
Show child attributes
⌘I
Create a role
curl --request POST \
--url https://{instance}/api/v2/role \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"permissions": [
"<string>"
],
"permissionsV2": [
{
"subject": "<string>",
"actions": [],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
description: '<string>',
permissions: ['<string>'],
permissionsV2: [
{
subject: '<string>',
actions: [],
tableName: '<string>',
filters: {},
fields: {}
}
],
isApiKey: false,
createdAt: '2023-11-07T05:31:56Z',
updatedAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://{instance}/api/v2/role', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/role"
payload = {
"name": "<string>",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"permissions": ["<string>"],
"permissionsV2": [
{
"subject": "<string>",
"actions": [],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": False,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"value": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"permissions": [
"<string>"
],
"permissionsV2": [
{
"subject": "<string>",
"actions": [
"read"
],
"tableName": "<string>",
"filters": {},
"fields": {}
}
],
"isApiKey": false,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}