Query history API

This API can be used to add queries to Query history. It requires that the user is logged in and that Query history feature is enabled in config file.

Add query to Query history

POST /api/query-history

Adds query to query history.

Example request:

  1. POST /api/query-history HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "dataSourceUid": "PE1C5CBDA0504A6A3",
  7. "queries": [
  8. {
  9. "refId": "A",
  10. "key": "Q-87fed8e3-62ba-4eb2-8d2a-4129979bb4de-0",
  11. "scenarioId": "csv_content",
  12. "datasource": {
  13. "type": "testdata",
  14. "uid": "PD8C576611E62080A"
  15. }
  16. }
  17. ]
  18. }

JSON body schema:

  • datasourceUid – Data source uid.
  • queries – JSON of query or queries.

Example response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "Query successfully added to query history",
  5. }

Status codes:

  • 200 – OK
  • 500 – Errors (invalid JSON, missing or invalid fields)