Skip to content

Get user

GET/directory/users/{userId}

Common API · Directory Management

Get a user by ID.

Required permissiontenant-directory.user:read

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 samples

curl -X GET "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>"

import requests

response = requests.get(
    "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
    },
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
}
Invoke-RestMethod -Method GET -Uri "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>" -Headers $headers

package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, err := http.NewRequest("GET", "https://api-<data-region>.central.sophos.com/common/v1/directory/users/<userId>", nil)
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer <access-token>")
    req.Header.Set("X-Tenant-ID", "<tenant-id>")

    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: "GET",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
  },
});
const data = await response.json();
console.log(data);

Responses

200 — User.

Response fields

idstring (uuid)required
User ID.
namestringrequired
User's name.
firstNamestring
User's first name or given name.
lastNamestring
User's last name or surname.
emailstring
User's email address.
domainstring
Domain name.
exchangeLoginstring
User's Exchange login.
groupsobject
Associated groups.
Show child attributesHide child attributes
totalinteger
itemsCountinteger
itemsarray of object
Items must be unique.
Group reference.
Show child attributesHide child attributes
idstring (uuid)required
Group ID.
namestring
Group name.
displayNamestring
Display name.
tenantobjectrequired
Reference to a tenant.
Show child attributesHide child attributes
idstring (uuid)required
Tenant ID.
namestring
Tenant Name.
sourceobjectrequired
Source of directory information.
Show child attributesHide child attributes
typestring (enum)required
Types of sources of directory information. All users and groups created using this API have the source type 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.
managerobject
Manager in the directory.
Show child attributesHide child attributes
idstring (uuid)
Manager ID.
namestring
Manager name.

Errors

Status Meaning
404 Can't find user.
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"
  }
}