Update user¶
PATCH/
Common API · Directory Management
Update an existing 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. |
userId | path | string (uuid) | Yes | User ID. |
Request body¶
Content type: application/json
Request body fields
namestringUser's full name.
Must be 1–250 characters long.
Must be 1–250 characters long.
firstNamestringUser's first name or given name. This must not contain a space.
Must be at most 250 characters long.
Must be at most 250 characters long.
lastNamestringUser's last name or surname.
Must be at most 250 characters long.
Must be at most 250 characters long.
emailstringUser's email address. WARNING: Any Sophos Central administrator using the previous email address as their username won't be able to sign in after this change.
exchangeLoginstringUser's Exchange login (max 350 characters).
managerIdstring (uuid)Manager in the directory to whom the current user reports. A user can be the manager of themselves.
Request samples¶
curl -X PATCH "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
\"name\": \"John Doe\",
\"firstName\": \"John\",
\"lastName\": \"Doe\",
\"email\": \"jonhdoe@example.com\",
\"exchangeLogin\": \"exchangeLogin\",
\"managerId\": \"77899dfe-38ed-417d-bc9d-2ef832e6ae4f\"
}"
import requests
response = requests.patch(
"https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>",
headers={
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
json={ 'name': 'John Doe',
'firstName': 'John',
'lastName': 'Doe',
'email': 'jonhdoe@example.com',
'exchangeLogin': 'exchangeLogin',
'managerId': '77899dfe-38ed-417d-bc9d-2ef832e6ae4f'},
)
print(response.json())
$headers = @{
"Authorization" = "Bearer <access-token>"
"X-Tenant-ID" = "<tenant-id>"
"Content-Type" = "application/json"
}
$body = '{
"name": "John Doe",
"firstName": "John",
"lastName": "Doe",
"email": "jonhdoe@example.com",
"exchangeLogin": "exchangeLogin",
"managerId": "77899dfe-38ed-417d-bc9d-2ef832e6ae4f"
}'
Invoke-RestMethod -Method PATCH -Uri "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>" -Headers $headers -Body $body -ContentType "application/json"
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, err := http.NewRequest("PATCH", "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>", strings.NewReader(`{
"name": "John Doe",
"firstName": "John",
"lastName": "Doe",
"email": "jonhdoe@example.com",
"exchangeLogin": "exchangeLogin",
"managerId": "77899dfe-38ed-417d-bc9d-2ef832e6ae4f"
}`))
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/directory/users/<userId>", {
method: "PATCH",
headers: {
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "John Doe",
"firstName": "John",
"lastName": "Doe",
"email": "jonhdoe@example.com",
"exchangeLogin": "exchangeLogin",
"managerId": "77899dfe-38ed-417d-bc9d-2ef832e6ae4f"
}),
});
const data = await response.json();
console.log(data);
Responses¶
200 — Updated user.¶
Response fields
idstring (uuid)requiredUser ID.
namestringrequiredUser's name.
firstNamestringUser's first name or given name.
lastNamestringUser's last name or surname.
emailstringUser's email address.
domainstringDomain name.
exchangeLoginstringUser's Exchange login.
groupsobjectAssociated groups.
Show child attributesHide child attributes
totalintegeritemsCountintegeritemsarray of objectItems must be unique.
Group reference.
Show child attributesHide child attributes
idstring (uuid)requiredGroup ID.
namestringGroup name.
displayNamestringDisplay name.
tenantobjectrequiredReference to a tenant.
Show child attributesHide child attributes
idstring (uuid)requiredTenant ID.
namestringTenant Name.
sourceobjectrequiredSource of directory information.
Show child attributesHide child attributes
typestring (enum)requiredTypes of sources of directory information. All users and groups created using this API have the source type
Must be one of:
custom. All users and groups synchronized from Active Directory, Azure Active Directory or Google Directory have the source type activeDirectory, azureActiveDirectory or googleDirectory respectively.Must be one of:
custom, activeDirectory, azureActiveDirectory, googleDirectory.createdAtstring (datetime)When the user was created.
updatedAtstring (datetime)When the user was last updated.
managerobjectManager in the directory.
Show child attributesHide child attributes
idstring (uuid)Manager ID.
namestringManager name.
Errors¶
| Status | Meaning |
|---|---|
404 | User or Manager not found with given ID. |
409 | Email address must not already be in use. You can't remove the email address from an admin who uses it to login to Sophos Central Admin. Additionally, you can't use this API to update a user synced from Active Directory or add a user to a group synced from Active Directory. |
500 | Internal server error. |
All error responses share the same shape — see the error response object.
Response examples¶
200¶
{
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"domain": "string",
"exchangeLogin": "string",
"groups": {
"total": 0,
"itemsCount": 0,
"items": [
{
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"displayName": "string"
}
]
},
"tenant": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string"
},
"source": {
"type": "custom"
},
"createdAt": "string",
"updatedAt": "string",
"manager": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string"
}
}