Get query run¶
GET/
Live Discover API · Query Run
Get a query run by ID.
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
X-Tenant-ID | header | string (uuid) | Yes | Tenant ID. |
runId | path | string (uuid) | Yes | Query run ID. |
fields | query | array of string | No | The fields to return in a partial response. |
Request samples¶
curl -X GET "https://api-<data-region>.central.sophos.com/live-discover/v1/queries/runs/<runId>" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>"
import requests
response = requests.get(
"https://api-<data-region>.central.sophos.com/live-discover/v1/queries/runs/<runId>",
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/live-discover/v1/queries/runs/<runId>" -Headers $headers
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("GET", "https://api-<data-region>.central.sophos.com/live-discover/v1/queries/runs/<runId>", 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/live-discover/v1/queries/runs/<runId>", {
method: "GET",
headers: {
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
},
});
const data = await response.json();
console.log(data);
Responses¶
200 — Query run found.¶
Response fields
idstring (uuid)requiredQuery run ID.
categoryobjectReference to a query category.
Show child attributesHide child attributes
idstring (uuid)requiredCategory ID.
namestringCategory name.
codestringIdentifier for category name. This is available only for pre-defined categories.
queryobjectShow child attributesHide child attributes
idstring (uuid)requiredQuery ID.
namestringQuery name.
codestringLocalization code of the query.
namestringrequiredQuery name.
templatestringrequiredQuery SQL template.
variablesarray of objectQuery template replacement variables.
Query variable.
Show child attributesHide child attributes
namestringrequiredVariable name.
Must be 1–100 characters long.
Must be 1–100 characters long.
dataTypestringrequiredData types supported for Live Discover queries.
Must be one of:
Must be one of:
double, integer, text, dateTime, boolean.valuestringString value of the variable.
Must be 1–5000 characters long.
Must be 1–5000 characters long.
pivotTypestringMeaning of an input parameter of a query.
Must be one of:
Must be one of:
deviceId, deviceName, sophosPid, ipAddress, username, sha256, filePath, registryKey, url.statusstringrequiredStatus of a query run.
Must be one of:
Must be one of:
pending, started, finished.resultstringrequiredOverall result of a query run.
Must be one of:
Must be one of:
notAvailable, succeeded, failed, timedOut.createdAtstring (datetime)When the query run was started.
createdByobjectPrincipal reference.
Show child attributesHide child attributes
idstring (uuid)requiredPrincipal ID. This is the client ID for service principals.
typestring (enum)requiredPrincipal type.
Must be one of:
Must be one of:
user, service.namestringPrincipal name. This doesn't apply to service principals.
accountTypestringAccount type.
Must be one of:
Must be one of:
partner, tenant, organization.finishedAtstring (datetime)When the query run completed.
maxDurationInSecondsintegerrequiredMaximum query duration allowed (in seconds) after which the query is terminated.
timeRemainingInSecondsintegerrequiredRemaining time in seconds.
performanceobjectOverall query performance metrics.
Show child attributesHide child attributes
scorestringLive Discover query performance score.
Must be one of:
Must be one of:
excellent, good, fair, poor, notEvaluated.dataTransferredInBytesobjectStatistics.
Show child attributesHide child attributes
totalintegerTotal value.
minintegerMin value.
maxintegerMax value.
medianintegerMedian value.
averageintegerAverage value.
executionTimeInMillisobjectStatistics.
Show child attributesHide child attributes
totalintegerTotal value.
minintegerMin value.
maxintegerMax value.
medianintegerMedian value.
averageintegerAverage value.
resultCountintegerCount of query run results collected.
matchEndpointsobjectrequiredCriteria to select endpoints.
Show child attributesHide child attributes
allbooleanWhether to include all endpoints.
filtersarray of objectFilters to select specific endpoints. If present, must contain between one and five filter objects.
Must contain 1–5 items.
Must contain 1–5 items.
Find endpoints matching criteria.
Show child attributesHide child attributes
healthStatusarray of stringFind endpoints by health status.
Each item must be one of:
Each item must be one of:
good, suspicious, bad, unknown.typearray of stringFind endpoints by type.
Each item must be one of:
Each item must be one of:
computer, server, securityVm.tamperProtectionEnabledbooleanFind endpoints by whether Tamper Protection is turned on.
lockdownStatusarray of stringFind endpoints by lockdown status.
Each item must be one of:
Each item must be one of:
creatingWhitelist, installing, locked, notInstalled, registering, starting, stopping, unavailable, uninstalled, unlocked, locking.idsarray of string (uuid)Find endpoints with the specified IDs.
Must contain 1–1000 items.
Must contain 1–1000 items.
lastSeenBeforestringFind endpoints that were last seen before the given date and time (UTC) or a duration relative to the current date and time (exclusive).
lastSeenAfterstringFind endpoints that were last seen after the given date and time (UTC) or a duration relative to the current date and time (inclusive).
hostnameContainsstringFind endpoints where the hostname contains the given string.
associatedPersonContainsstringFind endpoints where the name of the person associated with the endpoint contains the specified string.
groupNameContainsstringFind endpoints where the name of the group the endpoint is in contains the given string. We are temporarily stopping support for
groupNameContains until further notice.osarray of objectMatches endpoints with any of the supplied operating system versions.
Matches where operating system platform, type, and version match.
Show child attributesHide child attributes
platformstringOS platform type.
Must be one of:
Must be one of:
windows, linux, macOS.typestringEndpoint type. Please note
Must be one of:
securityVm is deprecated and will be removed soon.Must be one of:
computer, server, securityVm.versionobjectSpecifies the criteria for a version match.
Show child attributesHide child attributes
matchstringExact version match. Takes precedence over 'from' and 'to' range options.
fromstringMatch versions greater than or equal to this value.
tostringMatch versions less or equal to this value.
ipAddressesarray of stringFind endpoints by IP addresses.
searchstringTerm to search for in the specified search fields.
searchFieldsarray of stringList of search fields for finding the given search term. Defaults to all applicable fields.
Each item must be one of:
Each item must be one of:
hostname, groupName, associatedPersonName, ipAddresses, osName.endpointCountsobjectrequiredCount of endpoints grouped by various attributes.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
typesobjectNumber of endpoints of each type.
platformsobjectNumber of endpoints by platform.
statusesobjectCount of endpoints grouped by the status of the query running on each endpoint.
Show child attributesHide child attributes
pendingobjectCount of endpoints grouped by whether they are online or not.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
offlineintegerNumber of endpoints that are offline.
onlineintegerNumber of endpoints that are online.
startedobjectCount of endpoints by whether they have returned any data.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
withDataintegerNumber of endpoints that have returned some data.
withoutDataintegerNumber of endpoints that have returned no data.
finishedobjectCount of endpoints grouped by the result of the query run on each endpoint.
Show child attributesHide child attributes
succeededobjectCount of endpoints by whether they have returned any data.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
withDataintegerNumber of endpoints that have returned some data.
withoutDataintegerNumber of endpoints that have returned no data.
failedobjectCount of endpoints by whether they have returned any data.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
withDataintegerNumber of endpoints that have returned some data.
withoutDataintegerNumber of endpoints that have returned no data.
timedOutobjectCount of endpoints by whether they have returned any data.
Show child attributesHide child attributes
totalintegerTotal number of endpoints.
withDataintegerNumber of endpoints that have returned some data.
withoutDataintegerNumber of endpoints that have returned no data.
Errors¶
| Status | Meaning |
|---|---|
403 | Forbidden. |
404 | Can't find query run. |
500 | Unexpected error. |
All error responses share the same shape — see the error response object.
Response examples¶
200¶
{
"id": "00000000-0000-0000-0000-000000000000",
"category": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"code": "string"
},
"query": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"code": "string"
},
"name": "string",
"template": "string",
"variables": [
{
"name": "string",
"dataType": "double",
"value": "string",
"pivotType": "deviceId"
}
],
"status": "pending",
"result": "notAvailable",
"createdAt": "string",
"createdBy": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "user",
"name": "string",
"accountType": "partner"
},
"finishedAt": "string",
"maxDurationInSeconds": 0,
"timeRemainingInSeconds": 0,
"performance": {
"score": "excellent",
"dataTransferredInBytes": {
"total": 0,
"min": 0,
"max": 0,
"median": 0,
"average": 0
},
"executionTimeInMillis": {
"total": 0,
"min": 0,
"max": 0,
"median": 0,
"average": 0
}
},
"resultCount": 0,
"matchEndpoints": {
"all": false,
"filters": [
{
"healthStatus": [
"good"
],
"type": [
"computer"
],
"tamperProtectionEnabled": true,
"lockdownStatus": [
"creatingWhitelist"
],
"ids": [
"00000000-0000-0000-0000-000000000000"
],
"lastSeenBefore": "string",
"lastSeenAfter": "string",
"hostnameContains": "string",
"associatedPersonContains": "string",
"groupNameContains": "string",
"os": [
{
"platform": "windows",
"type": "computer",
"version": {
"match": "string",
"from": "string",
"to": "string"
}
}
],
"ipAddresses": [
"string"
],
"search": "string",
"searchFields": [
"hostname"
]
}
]
},
"endpointCounts": {
"total": 0,
"types": {},
"platforms": {},
"statuses": {
"pending": {
"total": 0,
"offline": 0,
"online": 0
},
"started": {
"total": 0,
"withData": 0,
"withoutData": 0
},
"finished": {
"succeeded": {
"total": 0,
"withData": 0,
"withoutData": 0
},
"failed": {
"total": 0,
"withData": 0,
"withoutData": 0
},
"timedOut": {
"total": 0,
"withData": 0,
"withoutData": 0
}
}
}
}
}
See the guide for a narrative walkthrough of this API.