> For the complete documentation index, see [llms.txt](https://docs.sola.security/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sola.security/workspace/projects/queries.md).

# Queries

Queries help you analyze security risks by retrieving relevant data from your connected sources. Querying your data allows you to explore your security posture across different environments, detect potential threats, and uncover critical security insights.

Queries are one of the building blocks that make up a [project](/workspace/projects.md), alongside [canvases](/workspace/projects/canvases.md), [alerts](/workspace/projects/alerts.md), and [workflows](/workspace/projects/workflows.md).

<figure><img src="/files/aj3BM13VZntQpYlvm3Pg" alt="Query real-time collaboration"><figcaption><p>Query real-time collaboration</p></figcaption></figure>

## Creating queries

There are two ways to create queries:

* **Use Sola AI** to ask security-related questions in natural language and generate queries automatically.
* **Write your queries** from scratch using the SQL query editor.

{% hint style="info" %}
**Pro tip: Enhance your SQL queries with** ![](/files/DESMoC6l1Gr9uaynao5N) **Sola AI**

Sola AI can help you identify the right tables and columns that contain the data you need or refine SQL syntax for more accurate results.
{% endhint %}

Once created, queries can be **saved**, **published**, and **modified** to refine your insights over time.

## Publishing queries

A query extracts a specific dataset from your connected data sources. Publishing a query saves the retrieved dataset as a table in your project. This makes the data set available across your project for:

* [Canvases](/workspace/projects/canvases.md) - Turn query results into charts, graphs, and tables.
* [Alerts](/workspace/projects/alerts.md) - Set up alerts based on query results.&#x20;
* [Workflows](/workspace/projects/workflows.md) (*coming soon*) - Automate security actions.

## Managing queries

The **Query Library** is where you can access all queries in your project.

Queries can be:

* **Published** - Available for use across the project building blocks and accessible to all project members.
* **Private drafts** - Visible only to you until shared.

<figure><img src="/files/ouGRYFwQQvZ4A8Mu5y7L" alt="Public and private queries in query library"><figcaption><p>Public and private queries in query library</p></figcaption></figure>

Queries have two modes:

* **View mode** - Displays the last published version of the query.
* **Edit mode** - A real-time shared draft, where multiple users can collaborate, edit together, and see changes live before publishing.

{% hint style="info" %}
Edits are only applied and visible to all project members once published. When you publish, all changes you and others have made are published together.
{% endhint %}

In the query library, depending on your role permission, you can:

* **View** all available queries in your project.
* **Create** and **modify** queries.
* **Duplicate** a query to modify it without changing the original.
* **Delete** a query.\
  \&#xNAN;*Note*: This action cannot be undone. Assets using the query, such as canvases or alert rules, will break or stop working.

{% hint style="info" %}
To manage your **project role permissions**, go to *Workspace Settings* > [*Project Permissions*](/system-management/settings.md#app-permissions).
{% endhint %}

{% hint style="success" %}
**Pro tip: Refine your SQL queries with Sola AI**

![](/files/DESMoC6l1Gr9uaynao5N) Access Sola AI from the query sidebar, or use the AI icon next to Run Query for quick actions:

* **Optimize** - Improve query efficiency.
* **Explain** - Understand what the query does.
* **Debug** - Identify syntax issues and get suggested fixes.
  {% endhint %}


---

# 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.sola.security/workspace/projects/queries.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.
