Get Query History

Returns the unique query strings that the current session's account has run in the last 30 days, ordered by the most recent execution time first.

Required Permissions

A logged-in user can only retrieve their own history.

HTTP Request

GET /api/sonar/query-history
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
     "https://HOSTNAME/api/sonar/query-history?offset=0&limit=50"
Request Parameters
KeyRequiredTypeDescriptionNote
offsetXIntegerItems to skipDefault: 0
limitXIntegerMaximum items

Success Response

{
  "total_count": 2,
  "queries": [
    {
      "query": "table sys_cpu_logs | stats avg(usage) by host",
      "created_at": "2026-04-29 09:15:32+0900"
    },
    {
      "query": "table secure | search action == \"failed\"",
      "created_at": "2026-04-28 18:42:11+0900"
    }
  ]
}
  • total_count (Integer): Number of distinct query strings the user has run in the last 30 days
  • queries (Array): Query history entries. Duplicate queries appear once with their most recent execution time
    • query (String): Query string that was executed
    • created_at (Date): Most recent execution time (yyyy-MM-dd HH:mm:ssZ format)

Error Responses

Session user not found

HTTP status code 500

{
  "error_code": "user not found",
  "error_msg": "user not found: 6c0e81d4-3a8b-4c91-9eb3-4f5a82d0a1b2"
}