Skip to content

Assign a role

POST/admins/{adminId}/role-assignments

Common API · tenant-access

Assign a role of principal type "user" to a tenant admin. Any existing assignment is overridden.

Required permissionassignment:create

Parameters

Name In Type Required Description
X-Tenant-ID header string (uuid) Yes Tenant ID.
adminId path string (uuid) Yes Admin ID.

Request body

Content type: application/json

Request body fields

roleIdstring (uuid)required
Role UUID.

Request samples

curl -X POST "https://api-<data-region>.central.sophos.com/common/v1/admins/<adminId>/role-assignments" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
  \"roleId\": \"c83c9481-f63c-4eb8-8793-e81eb9d66ef4\"
}"

import requests

response = requests.post(
    "https://api-<data-region>.central.sophos.com/common/v1/admins/<adminId>/role-assignments",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
        "Content-Type": "application/json",
    },
    json={'roleId': 'c83c9481-f63c-4eb8-8793-e81eb9d66ef4'},
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
    "Content-Type" = "application/json"
}
$body = '{
  "roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}'
Invoke-RestMethod -Method POST -Uri "https://api-<data-region>.central.sophos.com/common/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-<data-region>.central.sophos.com/common/v1/admins/<adminId>/role-assignments", strings.NewReader(`{
  "roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}`))
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer <access-token>")
    req.Header.Set("X-Tenant-ID", "<tenant-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-<data-region>.central.sophos.com/common/v1/admins/<adminId>/role-assignments", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}),
});
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 UUID.

Errors

Status Meaning
404 Can't find admin or role.
500 Internal server error.

All error responses share the same shape — see the error response object.

Response examples

201

{
  "id": "4bcb8ee6-720b-40c7-b748-716a3c47c185",
  "roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}