Create a new role
1 min
POST
https://api.upstartcommerce.com/profile-permissions/roles
Body Parameters
- bodyCreateRoleRequestrequiredDescription
- namestringrequiredExampleDescriptionMin Length1Max Length100
- scopestring<GLOBAL | TENANT | SITE>requiredDescriptionAllowedGLOBALTENANTSITE
- tenantIdstringDescription
- siteIdstringDescription
- roleDescriptionstringDescriptionMax Length500
- roleTypestring<Management | Consumer>requiredDescriptionAllowedManagementConsumer
- permissionsstring[]Example
[ "inventory.read", "inventory.write" ]
Description
Responses
201
- RoleDescription
- idstringrequiredDescription
- namestringrequiredExampleDescription
- scopestring<GLOBAL | TENANT | SITE>requiredDescriptionAllowedGLOBALTENANTSITE
- tenantIdstringDescription
- siteIdstringDescription
- roleDescriptionstringDescription
- roleTypestring<Management | Consumer>requiredDescriptionAllowedManagementConsumer
- createdAtstring<date-time>requiredFormatdate-time
- updatedAtstring<date-time>requiredFormatdate-time
400
- ErrorResponseDescription
- errorstring<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>requiredExampleDescriptionAllowedbad_requestunauthorizedforbiddennot_foundconflictinternal_error
- messagestringrequiredExampleDescription
- detailsmap<string, string>Description
401
- ErrorResponseDescription
- errorstring<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>requiredExampleDescriptionAllowedbad_requestunauthorizedforbiddennot_foundconflictinternal_error
- messagestringrequiredExampleDescription
- detailsmap<string, string>Description
409
- ErrorResponseDescription
- errorstring<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>requiredExampleDescriptionAllowedbad_requestunauthorizedforbiddennot_foundconflictinternal_error
- messagestringrequiredExampleDescription
- detailsmap<string, string>Description
500
- ErrorResponseDescription
- errorstring<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>requiredExampleDescriptionAllowedbad_requestunauthorizedforbiddennot_foundconflictinternal_error
- messagestringrequiredExampleDescription
- detailsmap<string, string>Description
curl
curl --request POST \
--url https://api.upstartcommerce.com/profile-permissions/roles \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"name": "warehouse-manager",
"scope": "",
"roleType": ""
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"name": "warehouse-manager",
"scope": "",
"roleType": ""
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.upstartcommerce.com/profile-permissions/roles", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.upstartcommerce.com/profile-permissions/roles")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"name": "warehouse-manager",
"scope": "",
"roleType": ""
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.upstartcommerce.com/profile-permissions/roles"
payload = json.dumps({
"name": "warehouse-manager",
"scope": "",
"roleType": ""
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Role created successfully
{
"id": "",
"name": "operator",
"scope": "",
"tenantId": "",
"siteId": "",
"roleDescription": "",
"roleType": "",
"createdAt": "",
"updatedAt": ""
}400
// Invalid request parameters
{
"error": "not_found",
"message": "Role not found",
"details": ""
}401
// Missing or invalid authentication token
{
"error": "not_found",
"message": "Role not found",
"details": ""
}409
// Role with this name already exists
{
"error": "not_found",
"message": "Role not found",
"details": ""
}500
// Internal server error
{
"error": "not_found",
"message": "Role not found",
"details": ""
}