Named Queries
A named query is a SQL query you save under a name so it can be run again, and called as an API endpoint. Agents and automations can use it to get exactly the data you intend them to see, without writing SQL themselves.
The subtitle reads "Saved SQL queries callable as API endpoints by agents and automations". Without an open project the page says "No project selected — choose one from the sidebar".
The list
With none, the page says "No named queries yet" and "Click "New Named Query" to create a reusable SQL endpoint". Otherwise a line counts them, such as 3 queries, and each is a card:
| Part | What it shows |
|---|---|
| Name | The query's name |
| Namespace tag | The namespace it is meant for, such as landing, when you set one |
| Runs | How many times it has been run, such as 12 runs |
| last | The date of its last run |
| Description | A line about what it does, if you wrote one |
Create a named query
Click New Named Query
The button is at the top right. A New Named Query panel opens.
Fill in the form
- Name (required), such as
daily_sales. - Namespace, optional, such as
landing. - Description, optional.
- SQL (required), in a code editor. It starts with
SELECT 1 AS testfor you to replace.
- Name (required), such as
Save
Click Save Query. It reads Saving… while it works. If it fails, the reason is shown above the buttons. Cancel, or the ✕, closes the panel without saving.
Test the SQL in the Query Editor first, so you know it works before you save it.
Work with a saved query
Each card has these controls.
| Control | What it does |
|---|---|
| Run | Runs the query now. It reads Running… while it works. The card opens to show the result |
| Copy API path (clipboard icon) | Copies the query's endpoint address, which looks like /api/v1/data/named-queries/<id>/execute |
| Bin icon | Deletes the query |
| show SQL / collapse | Opens the card to read the SQL, and closes it again |
Read a result
Run fetches a small sample. The result shows the first 5 rows in a table, and a footer such as 1,200 rows · 340ms · showing 5, so you can check the query without loading everything. Empty values show as null. If the query fails, the error appears in red instead.
Using a named query
A named query is meant to be called, not just read:
- By an agent. Agents find your named queries and can use each one as a tool. Give each a clear name and description, because that is how an agent decides when to use it.
- By an automation. Call the endpoint address from a workflow or script.
Because a named query can only run the SQL you saved, it is a safe way to give an agent access to a specific slice of data without handing it the whole warehouse.
Tips
- Name it for what it returns, not how it works:
overdue_invoices, notquery_3. - Write a description. Agents read it.
- Keep queries narrow. Return only the columns and rows a caller needs.
- Plan for changes. The page has no edit button. To change a query, create a new one, point your callers at it, then delete the old one.