CSV file with a header row. No metadata block is included in CSV output.
Spaces method and path for this operation:
Refer to Spaces for more information.
Export all result rows for a specific scheduled query execution as a downloadable file. The response is a streaming file attachment in the requested format.
Path parameters
-
The schedule ID of the scheduled query.
-
The execution counter for the scheduled query run whose results are exported. Must be a non-negative integer.
Minimum value is
0.
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 (includes
execution_count); 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-readprivilege required to export scheduled query results.
curl \
--request POST 'https://localhost:5601/api/osquery/scheduled_results/90f342ee-9c05-4844-849b-173993234f22/17384/_export?format=ndjson' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"kuery\": \"agent.name: \\\"prod-host-1\\\"\"\n}"'
{
"kuery": "agent.name: \"prod-host-1\""
}
{
"_meta": {
"action_id": "90f342ee-9c05-4844-849b-173993234f22",
"execution_count": 17384,
"exported_by": "elastic",
"format": "json",
"timestamp": "2026-04-30T09:12:00.000Z",
"total_results": 1
},
"results": [
{
"@timestamp": "2026-04-30T09:11:58.321Z",
"agent": {
"id": "5b1bb334-a23d-4006-80fe-bd129b979c9f",
"name": "prod-host-1"
},
"osquery": {
"uid": "1000",
"username": "ubuntu"
}
}
]
}
{"_meta":{"action_id":"90f342ee-9c05-4844-849b-173993234f22","execution_count":17384,"timestamp":"2026-04-30T09:12:00.000Z","exported_by":"elastic","format":"ndjson","total_results":32}}
{"@timestamp":"2026-04-30T09:11:58.321Z","agent":{"id":"5b1bb334-a23d-4006-80fe-bd129b979c9f","name":"prod-host-1"},"osquery":{"uid":"1000","username":"ubuntu"}}
osquery.description,agent.name,agent.id,osquery.uid,osquery.username
Ubuntu,prod-host-1,5b1bb334-a23d-4006-80fe-bd129b979c9f,1000,ubuntu
root,prod-host-1,5b1bb334-a23d-4006-80fe-bd129b979c9f,0,root
{
"message": "Export limited to 500,000 results. Found 500,001. Please add filters to narrow results."
}