---
title: "Edit SQL Query"
method: PUT
path: "/sql/{sqlID}"
tags: ["SQL Queries"]
---

# Edit SQL Query

`PUT /sql/{sqlID}`

## Request

- Base URL: `https://api.us-e1.tago.io`
- URL: `https://api.us-e1.tago.io/sql/{sqlID}`
- Auth: API key in header `Profile-Token`
- TypeScript: <https://skmtc.dev/tago/apis/tagoio-api/docs/sql/:sqlID/put.ts> (a function with typed inputs; its response is checked against the schema)

Replace a saved query. The query is re-validated and `cache_version` is bumped (invalidating cached results). `version` is bumped only when the versioned content (`query` or `params`) changes; a metadata-only edit leaves `version` unchanged. Enforces the same plan caps as create.

## Request body

- object
  - `name` string
  - `description` string
  - `query` string
  - `params` object[]
    - `key` string
    - `value` string
  - `cache_enabled` boolean
  - `cache_ttl_seconds` integer
  - `rate_limit_rpm` integer
  - `active` boolean
  - `tags` object[]
    - `key` string
    - `value` string

## Response `200`

Saved query updated.

- object
  - `status` boolean
  - `result` object
    - `id` string
    - `version` integer
    - `cache_version` integer
    - `session_context` boolean: True when the query uses a session function; derived from the query text.

## Other responses

- `400`: SQL syntax or validation error, invalid params, or object-map params.
- `402`: Plan limit exceeded (parameter count).
- `404`: Saved query not found (or not owned by your profile).

## Changes

- **2026-11-07** `1a281f04cdab`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/tago/apis/tagoio-api/changes/sql/:sqlID/put.md)

---

[API](https://skmtc.dev/tago/apis/tagoio-api.md) - [All operations](https://skmtc.dev/tago/apis/tagoio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tago/apis/tagoio-api/revisions/1a281f04cdab?raw)
