Security Osquery API
Create a saved query
Spaces method and path for this operation:
<div><span class="operation-verb post">post</span> <span class="operation-path">/s/{space_id}/api/osquery/saved_queries</span></div>Refer to Spaces for more information.
Create and save a query for later use.
post/api/osquery/saved_queries
Request body
Example request
{
"description": "Saved query description",
"ecs_mapping": {
"host.uptime": {
"field": "total_seconds"
}
},
"id": "saved_query_id",
"interval": "60",
"platform": "linux,darwin",
"query": "select * from uptime;",
"timeout": 120,
"version": "2.8.0"
}Response
Indicates a successful call.
Example response
{
"data": {
"created_at": "2025-02-26T13:37:30.452Z",
"created_by": "elastic",
"description": "Saved query description",
"ecs_mapping": {
"host.uptime": {
"field": "total_seconds"
}
},
"id": "saved_query_id",
"interval": "60",
"platform": "linux,darwin",
"prebuilt": false,
"query": "select * from uptime;",
"saved_object_id": "42ba1280-2172-11ee-8523-5765fca79a3c",
"timeout": 120,
"updated_at": "2025-02-26T13:37:30.452Z",
"updated_by": "elastic",
"version": "2.8.0"
}
}