Add site roles to a user
1 min
PUT
https://api.upstartcommerce.com/profile-permissions/users/{userId}/sites/{siteId}/roles
Path Parameters
- userIdstring<uuid>requiredDescriptionFormatuuid
- siteIdstringrequiredDescription
Body Parameters
- bodyAddUserSiteRolesRequestrequiredDescription
- roleIdsstring[]requiredExample
[ "role-site-manager", "role-site-viewer" ]
Description
Responses
200
- UserSiteRoleAssignmentsResponseDescription
- assignmentsUserSiteRoleAssignment[]requiredDescription
- roleIdstringrequiredDescription
- roleNamestringrequiredExampleDescription
- siteIdstringrequiredDescription
- siteNamestringrequiredExampleDescription
- assignedAtstring<date-time>requiredDescriptionFormatdate-time
- assignedBystringDescription
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
404
- 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 PUT \
--url https://api.upstartcommerce.com/profile-permissions/users/{userId}/sites/{siteId}/roles \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"roleIds": []
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"roleIds": []
});
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.upstartcommerce.com/profile-permissions/users/{userId}/sites/{siteId}/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/users/{userId}/sites/{siteId}/roles")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"roleIds": []
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.upstartcommerce.com/profile-permissions/users/{userId}/sites/{siteId}/roles"
payload = json.dumps({
"roleIds": []
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
200
// Site roles added successfully
{
"assignments": [
{
"roleId": "",
"roleName": "site-manager",
"siteId": "",
"siteName": "East Coast Store",
"assignedAt": "",
"assignedBy": ""
}
]
}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": ""
}404
// User, site, or role not found
{
"error": "not_found",
"message": "Role not found",
"details": ""
}500
// Internal server error
{
"error": "not_found",
"message": "Role not found",
"details": ""
}