Skip to content

Create new admin

POST/admins

Common API · tenant-access

Create a tenant admin from a directory user.

Required permissiontenant-admin:create

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)required
User UUID.
roleAssignmentsarray of objectrequired
Role assignments.
Must contain exactly 1 item.
Request object to create new role assignment.
Show child attributesHide child attributes
roleIdstring (uuid)required
Role 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)required
Admin UUID.
tenantobjectrequired
Reference to a tenant.
Show child attributesHide child attributes
idstring (uuid)required
Tenant ID.
namestring
Tenant Name.
usersarray of objectrequired
List of directory users with which admin is associated by email.
Items must be unique.
Reference to the user.
Show child attributesHide child attributes
idstring (uuid)required
User ID.
namestring
User's full name.
profileobjectrequired
Admin profile with personal details.
Show child attributesHide child attributes
namestringrequired
Name of user.
firstNamestring
First name of user.
lastNamestring
Last name of user.
emailstring (email)required
Email ID of user.
roleAssignmentsarray of objectrequired
List of role assignments.
Items must be unique.
Role assignment.
Show child attributesHide child attributes
idstring (uuid)required
Role assignment ID.
roleIdstring (uuid)required
Role 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"
}