Assign a role¶
POST/
Partner API · Partner Admins
Assign a role to a partner administrator.
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
X-Partner-ID | header | string (uuid) | Yes | Partner ID. |
adminId | path | string (uuid) | Yes | Partner administrator ID. |
Request body¶
Content type: application/json
Request body fields
roleIdstring (uuid)requiredRole ID.
scopeobjectrequiredRole assignment scope.
Show child attributesHide child attributes
typestringrequiredRole assignment scope type.
Must be one of:
Must be one of:
tenant, allManagedTenants, self, tenantGroup.idstring (uuid)Tenant ID. Optional or not present when
type is allManagedTenants or self.Request samples¶
curl -X POST "https://api.central.sophos.com/partner/v1/admins/<adminId>/role-assignments" -H "Authorization: Bearer <access-token>" -H "X-Partner-ID: <partner-id>" -H "Content-Type: application/json" -d "{
\"roleId\": \"2b8f2624-b054-45e0-923e-6527d9054342\",
\"scope\": {
\"type\": \"self\"
}
}"
import requests
response = requests.post(
"https://api.central.sophos.com/partner/v1/admins/<adminId>/role-assignments",
headers={
"Authorization": "Bearer <access-token>",
"X-Partner-ID": "<partner-id>",
"Content-Type": "application/json",
},
json={'roleId': '2b8f2624-b054-45e0-923e-6527d9054342', 'scope': {'type': 'self'}},
)
print(response.json())
$headers = @{
"Authorization" = "Bearer <access-token>"
"X-Partner-ID" = "<partner-id>"
"Content-Type" = "application/json"
}
$body = '{
"roleId": "2b8f2624-b054-45e0-923e-6527d9054342",
"scope": {
"type": "self"
}
}'
Invoke-RestMethod -Method POST -Uri "https://api.central.sophos.com/partner/v1/admins/<adminId>/role-assignments" -Headers $headers -Body $body -ContentType "application/json"
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, err := http.NewRequest("POST", "https://api.central.sophos.com/partner/v1/admins/<adminId>/role-assignments", strings.NewReader(`{
"roleId": "2b8f2624-b054-45e0-923e-6527d9054342",
"scope": {
"type": "self"
}
}`))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer <access-token>")
req.Header.Set("X-Partner-ID", "<partner-id>")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
const response = await fetch("https://api.central.sophos.com/partner/v1/admins/<adminId>/role-assignments", {
method: "POST",
headers: {
"Authorization": "Bearer <access-token>",
"X-Partner-ID": "<partner-id>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"roleId": "2b8f2624-b054-45e0-923e-6527d9054342",
"scope": {
"type": "self"
}
}),
});
const data = await response.json();
console.log(data);
Responses¶
201 — Requested assignment created.¶
Response fields
idstring (uuid)requiredRole assignment ID.
roleIdstring (uuid)requiredRole ID.
roleNamestringRole name.
scopeobjectrequiredRole assignment scope.
Show child attributesHide child attributes
typestringrequiredRole assignment scope type.
Must be one of:
Must be one of:
tenant, allManagedTenants, self, tenantGroup.idstring (uuid)Tenant ID. Optional or not present when
type is allManagedTenants or self.namestringTenant name. Optional or not present when
type is allManagedTenants or self.Errors¶
| Status | Meaning |
|---|---|
400 | Bad request. |
404 | Can't find admin or role. |
500 | Unexpected error. |
All error responses share the same shape — see the error response object.
See the guide for a narrative walkthrough of this API.