SQL Queries
Create SQL Query
Changed onCreate a saved TagoSQL query on your profile. The query is parsed and validated against your plan at save time and snapshotted as version 1. Enforces the saved-query count (sql_query) and parameter count (sql_query_params) plan caps. Server-owned fields (id, profile, cache_version, version, versions, created_at, updated_at) are never accepted from the request body. The request body cap is 64 KiB.
post/sql
Request
- Base URLhttps://api.us-e1.tago.io
- AuthAPI key in header Profile-Token
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"name": "hot sensors",
"description": "temperatures above a threshold",
"query": "SELECT variable, value, time FROM device('DEVICE_ID') AS d WHERE value > $1 ORDER BY time DESC LIMIT 100",
"params": [
{
"key": "$1",
"value": "30"
}
],
"cache_enabled": true,
"cache_ttl_seconds": 60,
"rate_limit_rpm": 30,
"active": true,
"tags": [
{
"key": "kind",
"value": "report"
}
]
}Response
Saved query created (snapshotted as version 1).
Example response
{
"status": true,
"result": {
"id": "6a1b2c3d4e5f6a1b2c3d4e5f",
"name": "hot sensors",
"version": 1,
"cache_version": 1
}
}Changes
- info
endpoint added
- info