Upsert many roles
Insert or update many roles in one call. update is required: it lists the columns to overwrite when a row with a conflicting unique key already exists.
curl --request PUT \
--url https://{instance}/api/v2/role/bulk \
--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: 'PUT',
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/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/role/bulk"
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.put(url, json=payload, headers=headers)
print(response.text){
"values": [
{
"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.
Query Parameters
Columns to overwrite when the row already exists. Repeat the parameter for each column: a single comma-separated value is read as one column name and fails at the database. Without the parameter the request is rejected with 400.
Body
Role name. At least one character.
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 upserted roles.
Show child attributes
Show child attributes
curl --request PUT \
--url https://{instance}/api/v2/role/bulk \
--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: 'PUT',
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/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/role/bulk"
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.put(url, json=payload, headers=headers)
print(response.text){
"values": [
{
"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": {}
}