Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trellis.sh/llms.txt

Use this file to discover all available pages before exploring further.

Partially update a saved query. Only include the fields you want to change. When sql is updated, parameters is automatically re-extracted from the new SQL.
Authorization
string
required
Bearer token obtained from the authenticate endpoint.
query_id
string
required
Unique identifier of the saved query to update.
title
string
New display title for the query.
prompt
string
New natural language instruction for the query.
sql
string
New SQL to associate with the query. Use {{param_name}} placeholders for values that should be supplied at runtime. Updating this field automatically re-extracts parameters.
description
string
New description for the query.
keywords
string[]
New list of keywords for semantic matching. Pass an empty array to remove all keywords.

Response

Returns the updated saved query object.
id
string
required
Unique identifier for the query.
organization_id
string
required
Organization the query belongs to.
title
string
required
Updated display title.
description
string
Updated description.
prompt
string
required
Updated natural language instruction.
sql
string
The current SQL for this query, or null for prompt-only queries.
keywords
string[]
Updated keywords list.
parameters
string[]
Re-extracted {{param_name}} placeholder names from the current sql. Updated automatically whenever sql changes.
last_updated_by
string
required
Member ID of the user who made this update.
last_updated_by_name
string
Display name of the user who made this update.
created_at
string
required
ISO 8601 timestamp when the query was originally created.
updated_at
string
required
ISO 8601 timestamp of this update.
curl -X PATCH https://api.trellis.sh/v1/queries/b2c3d4e5-f6a7-8901-bcde-f12345678901 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Top Customers by Region",
    "prompt": "Who are our top customers by total spend in {{region}}?",
    "sql": "SELECT customer_id, SUM(amount) AS total_spend FROM orders WHERE region = {{region}} GROUP BY customer_id ORDER BY total_spend DESC LIMIT {{limit}}"
  }'
{
  "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "organization_id": "org_abc123",
  "title": "Top Customers by Region",
  "description": "Returns the top N customers ranked by total spend",
  "prompt": "Who are our top customers by total spend in {{region}}?",
  "sql": "SELECT customer_id, SUM(amount) AS total_spend FROM orders WHERE region = {{region}} GROUP BY customer_id ORDER BY total_spend DESC LIMIT {{limit}}",
  "keywords": ["customers", "spend", "top"],
  "parameters": ["region", "limit"],
  "last_updated_by": "member_xyz789",
  "last_updated_by_name": "Jane Smith",
  "created_at": "2025-01-11T10:00:00Z",
  "updated_at": "2025-01-11T11:00:00Z"
}