> For the complete documentation index, see [llms.txt](https://docs.lenses.io/latest/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lenses.io/latest/api-reference/reference/user-context.md).

# User Context

User context domain data, like Saved SQL queries and query execution history

## GET /api/v1/users/me/sql-queries/saved

> Lists saved SQL queries for the current user.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_SavedSQLQueryList":{"type":"object","description":"Contains all saved SQL queries for the current user.","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/hq_SavedSQLQuery"}}},"required":["items"]},"hq_SavedSQLQuery":{"type":"object","description":"A SQL query saved by the current user for future execution in SQL Studio.\n","properties":{"name":{"type":"string","format":"hq-resource-name"},"display_name":{"type":"string","description":"User-facing label for the saved query.","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets. The saved query can outlive\nthe environment, so the data object may contain a name of the environment,\nthat does not exist anymore.\n"},"created_at":{"type":"string","format":"date-time","description":"When the query was first saved."},"updated_at":{"type":"string","format":"date-time","description":"When the query was last modified."}},"required":["name","display_name","sql","environment_name","created_at","updated_at"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/saved":{"get":{"description":"Lists saved SQL queries for the current user.","operationId":"listCurrentUserSavedSQLQueries","responses":{"200":{"description":"List of saved SQL queries.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_SavedSQLQueryList"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## POST /api/v1/users/me/sql-queries/saved

> Creates a saved SQL query for the current user.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_CreateSavedSQLQueryRequest":{"type":"object","description":"Creates a saved SQL query for the current user.","properties":{"name":{"type":"string","format":"hq-resource-name","description":"Sets the name of the new saved SQL query. It must be a valid HQ resource\nname: it can only contain lowercase alphanumeric characters or\nhyphens; hyphens cannot appear at the end or start; the length is 63\ncharacters at most.\n","minLength":1,"maxLength":63},"display_name":{"type":"string","description":"Sets the display name of the saved query. If not provided, the value of\n\"name\" will be used.\n","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets."}},"required":["name","sql","environment_name"]},"hq_SavedSQLQuery":{"type":"object","description":"A SQL query saved by the current user for future execution in SQL Studio.\n","properties":{"name":{"type":"string","format":"hq-resource-name"},"display_name":{"type":"string","description":"User-facing label for the saved query.","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets. The saved query can outlive\nthe environment, so the data object may contain a name of the environment,\nthat does not exist anymore.\n"},"created_at":{"type":"string","format":"date-time","description":"When the query was first saved."},"updated_at":{"type":"string","format":"date-time","description":"When the query was last modified."}},"required":["name","display_name","sql","environment_name","created_at","updated_at"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/saved":{"post":{"description":"Creates a saved SQL query for the current user.","operationId":"createCurrentUserSavedSQLQuery","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_CreateSavedSQLQueryRequest"}}}},"responses":{"201":{"description":"SQL query saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_SavedSQLQuery"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## GET /api/v1/users/me/sql-queries/saved/{name}

> Retrieves a saved SQL query by name.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_SavedSQLQuery":{"type":"object","description":"A SQL query saved by the current user for future execution in SQL Studio.\n","properties":{"name":{"type":"string","format":"hq-resource-name"},"display_name":{"type":"string","description":"User-facing label for the saved query.","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets. The saved query can outlive\nthe environment, so the data object may contain a name of the environment,\nthat does not exist anymore.\n"},"created_at":{"type":"string","format":"date-time","description":"When the query was first saved."},"updated_at":{"type":"string","format":"date-time","description":"When the query was last modified."}},"required":["name","display_name","sql","environment_name","created_at","updated_at"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/saved/{name}":{"get":{"description":"Retrieves a saved SQL query by name.","operationId":"getCurrentUserSavedSQLQuery","parameters":[{"in":"path","name":"name","description":"Name of the saved SQL query (HQ resource name).","required":true,"schema":{"type":"string","format":"hq-resource-name"}}],"responses":{"200":{"description":"Saved SQL query.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_SavedSQLQuery"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## DELETE /api/v1/users/me/sql-queries/saved/{name}

> Deletes a saved SQL query.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/saved/{name}":{"delete":{"description":"Deletes a saved SQL query.","operationId":"deleteCurrentUserSavedSQLQuery","parameters":[{"in":"path","name":"name","description":"Name of the saved SQL query (HQ resource name).","required":true,"schema":{"type":"string","format":"hq-resource-name"}}],"responses":{"204":{"description":"Successful deletion."},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## PATCH /api/v1/users/me/sql-queries/saved/{name}

> Updates a saved SQL query.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_UpdateSavedSQLQueryRequest":{"type":"object","description":"Updates a saved SQL query. Absent fields are left unchanged.\n","properties":{"display_name":{"type":"string","description":"User-facing label for the saved query.","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets."}}},"hq_SavedSQLQuery":{"type":"object","description":"A SQL query saved by the current user for future execution in SQL Studio.\n","properties":{"name":{"type":"string","format":"hq-resource-name"},"display_name":{"type":"string","description":"User-facing label for the saved query.","minLength":1,"maxLength":150},"sql":{"type":"string","description":"The saved SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query targets. The saved query can outlive\nthe environment, so the data object may contain a name of the environment,\nthat does not exist anymore.\n"},"created_at":{"type":"string","format":"date-time","description":"When the query was first saved."},"updated_at":{"type":"string","format":"date-time","description":"When the query was last modified."}},"required":["name","display_name","sql","environment_name","created_at","updated_at"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/saved/{name}":{"patch":{"description":"Updates a saved SQL query.","operationId":"updateCurrentUserSavedSQLQuery","parameters":[{"in":"path","name":"name","description":"Name of the saved SQL query (HQ resource name).","required":true,"schema":{"type":"string","format":"hq-resource-name"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_UpdateSavedSQLQueryRequest"}}}},"responses":{"200":{"description":"Updated saved SQL query.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_SavedSQLQuery"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## GET /api/v1/users/me/sql-queries/executed

> Lists executed SQL queries for the current user.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_ExecutedSQLQueryList":{"type":"object","description":"List of executed SQL queries for the current user.\n","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/hq_ExecutedSQLQuery"}}},"required":["items"]},"hq_ExecutedSQLQuery":{"type":"object","description":"A record of a SQL query execution.","properties":{"executed_at":{"type":"string","format":"date-time","description":"When the query was submitted for execution."},"sql":{"type":"string","description":"The executed SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query was executed against.\nThe executed query can outlive the environment, so the data object may\ncontain a name of the environment, that does not exist anymore.\n"}},"required":["executed_at","sql","environment_name"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/executed":{"get":{"description":"Lists executed SQL queries for the current user.","operationId":"listCurrentUserExecutedSQLQueries","responses":{"200":{"description":"List of executed SQL query records.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_ExecutedSQLQueryList"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```

## POST /api/v1/users/me/sql-queries/executed

> Records a SQL Studio query before execution for the current user.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.2"},"tags":[{"name":"hq_user-context","description":"User context domain data, like Saved SQL queries and query execution history"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"hq_CreateExecutedSQLQueryRequest":{"type":"object","description":"Records a SQL query before execution for the current user.","properties":{"sql":{"type":"string","description":"The SQL statement to execute."},"environment_name":{"type":"string","description":"Name of the environment the query will be executed against."}},"required":["sql","environment_name"]},"hq_ExecutedSQLQuery":{"type":"object","description":"A record of a SQL query execution.","properties":{"executed_at":{"type":"string","format":"date-time","description":"When the query was submitted for execution."},"sql":{"type":"string","description":"The executed SQL statement."},"environment_name":{"type":"string","description":"Name of the environment the query was executed against.\nThe executed query can outlive the environment, so the data object may\ncontain a name of the environment, that does not exist anymore.\n"}},"required":["executed_at","sql","environment_name"]},"hq_Error":{"type":"object","description":"Implements the RFC7807 \"Problem Details\", see https://www.rfc-editor.org/rfc/rfc7807.","properties":{"type":{"$ref":"#/components/schemas/hq_ErrorType"},"title":{"description":"Describes the problem in a human readable fashion.","type":"string"},"status":{"description":"Is a copy of the http status code.","type":"integer"},"invalid_fields":{"description":"Lists for validation errors the fields that failed validation.","type":"array","items":{"$ref":"#/components/schemas/hq_InvalidField"}},"sso_url":{"description":"Contains in case of an \"unauthorised\" type of error, the url of the SSO provider, if any.","type":"string"},"request_id":{"description":"Is set to the id of this request. Can be used to correlate backend logs.","type":"string"}},"required":["status","title"]},"hq_ErrorType":{"type":"string","description":"Enumerates possible error types.","enum":["not_found","unauthorised","forbidden","internal_server_error","agent_rpc_error","missing_agent_capabilities","agent_not_connected","validation_error","invalid_metadata","missing_parameter","invalid_parameter","licence_limitation","conflict","unspecified"]},"hq_InvalidField":{"type":"object","properties":{"name":{"type":"string"},"error":{"$ref":"#/components/schemas/hq_FieldErrorType"},"title":{"type":"string"},"pointer":{"description":"Holds a RFC-6901 JSON Pointer.","type":"string"}},"required":["name","error","title"]},"hq_FieldErrorType":{"type":"string","description":"Enumerates field validation error types.","enum":["reference_not_found","not_unique","invalid_value","other_error"]}}},"paths":{"/api/v1/users/me/sql-queries/executed":{"post":{"description":"Records a SQL Studio query before execution for the current user.","operationId":"createCurrentUserExecutedSQLQuery","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_CreateExecutedSQLQueryRequest"}}}},"responses":{"201":{"description":"Executed SQL query recorded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_ExecutedSQLQuery"}}}},"default":{"description":"Error object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/hq_Error"}}}}},"tags":["hq_user-context"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lenses.io/latest/api-reference/reference/user-context.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
