---
title: "Add query to query history."
method: POST
path: "/query-history"
tags: ["query_history"]
---

# Add query to query history.

`POST /query-history`

Adds new query to query history.

## Request body

- CreateQueryInQueryHistoryCommand — CreateQueryInQueryHistoryCommand is the command for adding query history
  - `datasourceUid` string — UID of the data source for which are queries stored.
  - `queries` Json, required

## Response `200`

(empty)

- QueryHistoryResponse — QueryHistoryResponse is a response struct for QueryHistoryDTO
  - `result` QueryHistoryDTO
    - `comment` string
    - `createdAt` integer
    - `createdBy` integer
    - `datasourceUid` string
    - `queries` Json
    - `starred` boolean
    - `uid` string

## Other responses

- `400` — BadRequestError is returned when the request is invalid and it cannot be processed.
- `401` — UnauthorizedError is returned when the request is not authenticated.
- `500` — InternalServerError is a general error indicating something went wrong internally.

---

[API](https://skmtc.net/nforgeio/apis/grafana-http-api.md) · [All operations](https://skmtc.net/nforgeio/apis/grafana-http-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nforgeio/grafana-http-api/versions/3cb6c3f42dc7/schema)
