SQL Queries

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.

put/sql/{sqlID}

Request

Request body

namestring
descriptionstring
querystring
cache_enabledboolean
cache_ttl_secondsinteger
rate_limit_rpminteger
activeboolean

Example request

{
  "name": "hot sensors",
  "description": "temperatures above 40",
  "query": "SELECT variable, value, time FROM device('DEVICE_ID') AS d WHERE value > $1 ORDER BY time DESC LIMIT 100",
  "params": [
    {
      "key": "$1",
      "value": "40"
    }
  ],
  "cache_enabled": true,
  "cache_ttl_seconds": 120,
  "rate_limit_rpm": 30,
  "active": true
}

Response

Saved query updated.

statusboolean

Example response

{
  "status": true,
  "result": {
    "id": "6a1b2c3d4e5f6a1b2c3d4e5f",
    "version": 2,
    "cache_version": 2
  }
}

Changes