CSV file with a header row derived from the ECS mapping of the originating query (when available). No metadata block is included in CSV output.
Spaces method and path for this operation:
Refer to Spaces for more information.
Export the results of a live query action as a downloadable file. The response is a streaming file attachment in the requested format.
Path parameters
-
The ID of the live query (parent action ID).
-
The query action ID whose results are exported. Filters the export to rows for this specific per-agent action.
Body
-
An optional allowlist of Elastic Agent IDs. When provided, only rows reported by the listed agents are included in the export.
-
An optional array of Elasticsearch / Kibana SearchBar filter objects (the same
esFilterspayload used by the Discover UI). Each filter is applied as an additional AND clause. An invalid filter object causes a 400 response rather than silently returning unfiltered data.Additional properties are allowed.
-
An optional KQL filter appended (with AND) to the base action/schedule filter. The filter is wrapped in parentheses so it cannot override or escape the built-in action_id / schedule_id gate.
Responses
-
A downloadable file in the requested format. The
Content-Dispositionheader contains the suggested filename.Newline-delimited JSON stream. The first line is a metadata object; each subsequent line is a result row.
-
Bad request. Possible causes: invalid or missing
formatquery parameter, malformed KQL in the request body, invalidesFilters, or the result count exceeds the 500,000-row limit. -
The authenticated user does not have the
osquery-readLiveQueriesprivilege required to export live query results. -
The parent live query action
{id}was found but does not contain a query whoseaction_idmatches{actionId}. This typically means theidandactionIdURL parameters refer to different queries.
curl \
--request POST 'https://localhost:5601/api/osquery/live_queries/3c42c847-eb30-4452-80e0-728584042334/results/609c4c66-ba3d-43fa-afdd-53e244577aa0/_export?format=ndjson' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"kuery\": \"user.name: \\\"root\\\"\"\n}"'
{
"kuery": "user.name: \"root\""
}
{
"_meta": {
"action_id": "609c4c66-ba3d-43fa-afdd-53e244577aa0",
"exported_by": "elastic",
"format": "json",
"query": "SELECT * FROM users;",
"timestamp": "2026-04-30T09:12:00.000Z",
"total_results": 2
},
"results": [
{
"@timestamp": "2026-04-30T09:11:58.321Z",
"agent": {
"id": "980a6b73-0b03-4d1e-8915-67c202e4a980",
"name": "prod-host-1"
},
"user": {
"id": "1000",
"name": "ubuntu"
}
}
]
}
{"_meta":{"action_id":"609c4c66-ba3d-43fa-afdd-53e244577aa0","query":"SELECT * FROM users;","timestamp":"2026-04-30T09:12:00.000Z","exported_by":"elastic","format":"ndjson","total_results":2}}
{"@timestamp":"2026-04-30T09:11:58.321Z","agent":{"id":"980a6b73-0b03-4d1e-8915-67c202e4a980","name":"prod-host-1"},"user":{"id":"1000","name":"ubuntu"}}
{"@timestamp":"2026-04-30T09:11:58.456Z","agent":{"id":"980a6b73-0b03-4d1e-8915-67c202e4a980","name":"prod-host-1"},"user":{"id":"0","name":"root"}}
agent.name,agent.id,user.id,user.name
prod-host-1,980a6b73-0b03-4d1e-8915-67c202e4a980,1000,ubuntu
prod-host-1,980a6b73-0b03-4d1e-8915-67c202e4a980,0,root
{
"message": "Export limited to 500,000 results. Found 500,001. Please add filters to narrow results."
}
{
"message": "Live query action not found"
}