Skip to content

Get location

GET/devices/{id}/location

Mobile API · Devices

Get device location.

Required permissionmobile.device:read

Parameters

Name In Type Required Description
id path string (uuid) Yes Unique object identifier.
X-Tenant-ID header string (uuid) Yes Tenant ID.
fields query array of string No The fields to return in a partial response.
view query string No Type of view to be returned in response.
Must be one of: basic, summary, full.

Request samples

curl -X GET "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/location" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>"

import requests

response = requests.get(
    "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/location",
    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/mobile/v1/devices/<id>/location" -Headers $headers

package main

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

func main() {
    req, err := http.NewRequest("GET", "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/location", 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/mobile/v1/devices/<id>/location", {
  method: "GET",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
  },
});
const data = await response.json();
console.log(data);

Responses

200 — Device location.

Response fields

accuracystring
The accuracy of the location.
longitudenumber
The longitude.
latitudenumber
The latitude.
locatedAtstring (date-time)
The time the device was located.

Errors

Status Meaning
400 Invalid request.
401 Unauthorized.
403 Forbidden.
404 Unknown device ID or location not available.
429 Too many requests. See Retry-After header.
500 Internal server error.

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

Response examples

200

{
  "accuracy": "+- 4m",
  "longitude": 51.4925888,
  "latitude": 7.4492825,
  "locatedAt": "2024-11-14T10:11:57.183Z"
}

See the guide for a narrative walkthrough of this API.