Create new admin¶
POST/
Common API · tenant-access
Create a tenant admin from a directory user.
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
X-Tenant-ID | header | string (uuid) | Yes | Tenant ID. |
fields | query | array of string | No | The fields to return in a partial response. |
Request body¶
Content type: application/json
Request body fields
userIdstring (uuid)requiredUser UUID.
roleAssignmentsarray of objectrequiredRole assignments.
Must contain exactly 1 item.
Must contain exactly 1 item.
Request object to create new role assignment.
Show child attributesHide child attributes
roleIdstring (uuid)requiredRole UUID.
Request samples¶
curl -X POST "https://api-<data-region>.central.sophos.com/common/v1/admins" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
\"userId\": \"17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15\",
\"roleAssignments\": [
{
\"roleId\": \"c83c9481-f63c-4eb8-8793-e81eb9d66ef4\"
}
]
}"
import requests
response = requests.post(
"https://api-<data-region>.central.sophos.com/common/v1/admins",
headers={
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
json={ 'userId': '17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15',
'roleAssignments': [{'roleId': 'c83c9481-f63c-4eb8-8793-e81eb9d66ef4'}]},
)
print(response.json())
$headers = @{
"Authorization" = "Bearer <access-token>"
"X-Tenant-ID" = "<tenant-id>"
"Content-Type" = "application/json"
}
$body = '{
"userId": "17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15",
"roleAssignments": [
{
"roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}
]
}'
Invoke-RestMethod -Method POST -Uri "https://api-<data-region>.central.sophos.com/common/v1/admins" -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", strings.NewReader(`{
"userId": "17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15",
"roleAssignments": [
{
"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", {
method: "POST",
headers: {
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"userId": "17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15",
"roleAssignments": [
{
"roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}
]
}),
});
const data = await response.json();
console.log(data);
Responses¶
201 — Requested admin created.¶
Response fields
idstring (uuid)requiredAdmin UUID.
tenantobjectrequiredReference to a tenant.
Show child attributesHide child attributes
idstring (uuid)requiredTenant ID.
namestringTenant Name.
usersarray of objectrequiredList of directory users with which admin is associated by email.
Items must be unique.
Items must be unique.
Reference to the user.
Show child attributesHide child attributes
idstring (uuid)requiredUser ID.
namestringUser's full name.
profileobjectrequiredAdmin profile with personal details.
Show child attributesHide child attributes
namestringrequiredName of user.
firstNamestringFirst name of user.
lastNamestringLast name of user.
emailstring (email)requiredEmail ID of user.
roleAssignmentsarray of objectrequiredList of role assignments.
Items must be unique.
Items must be unique.
Role assignment.
Show child attributesHide child attributes
idstring (uuid)requiredRole assignment ID.
roleIdstring (uuid)requiredRole UUID.
createdAtstring (datetime)Date and time the tenant admin was created.
updatedAtstring (datetime)Date and time the tenant admin was last updated.
Errors¶
| Status | Meaning |
|---|---|
404 | Can't find user ID or role ID passed as part of admin creation. |
409 | An administrator with the same details already exists in this or another tenant. |
500 | Internal server error. |
All error responses share the same shape — see the error response object.
Response examples¶
201¶
{
"id": "e1c7aa85-7863-4561-a50e-2b345b0e16e5",
"tenant": {
"id": "79067fa3-e4d0-4769-a5f7-8d6550b3b68b"
},
"users": [
{
"id": "17dd896f-ee9f-4f7d-a2a2-6a8c0b48ff15",
"name": "John Smith"
},
{
"id": "95685fcb-8ee1-4fad-96e6-966dd5588025",
"name": "Johnny Smith"
}
],
"profile": {
"name": "John Smith",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com"
},
"roleAssignments": [
{
"id": "4bcb8ee6-720b-40c7-b748-716a3c47c185",
"roleId": "c83c9481-f63c-4eb8-8793-e81eb9d66ef4"
}
],
"createdAt": "2021-01-02T15:32:59.789Z",
"updatedAt": "2021-02-12T20:00:01.329Z"
}