Skip to content

Assign a role

POST/admins/{adminId}/role-assignments

Partner API · Partner Admins

Assign a role to a partner administrator.

Required permissionaccount_management:write

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)required
Role ID.
scopeobjectrequired
Role assignment scope.
Show child attributesHide child attributes
typestringrequired
Role assignment scope type.
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)required
Role assignment ID.
roleIdstring (uuid)required
Role ID.
roleNamestring
Role name.
scopeobjectrequired
Role assignment scope.
Show child attributesHide child attributes
typestringrequired
Role assignment scope type.
Must be one of: tenant, allManagedTenants, self, tenantGroup.
idstring (uuid)
Tenant ID. Optional or not present when type is allManagedTenants or self.
namestring
Tenant 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.

Response examples

201

{
  "id": "00000000-0000-0000-0000-000000000000",
  "roleId": "00000000-0000-0000-0000-000000000000",
  "roleName": "string",
  "scope": {
    "type": "tenant",
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "string"
  }
}

See the guide for a narrative walkthrough of this API.