Sources
Host: https://insights-service.<domain>. Allowed: service tokens and users with the insights.use claim.
List sources
/api/v2/sourceinsights-service- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source -H "Authorization: Bearer $TOKEN"
const response = await fetch('https://insights-service.scenid.cloud/api/v2/source', {
headers: { Authorization: `Bearer ${token}` }
})
console.log(response.status, await response.json())
import requests
response = requests.get(
"https://insights-service.scenid.cloud/api/v2/source",
headers={"Authorization": f"Bearer {token}"},
)
print(response.status_code, response.json())
library(httr2)
response <- request("https://insights-service.scenid.cloud/api/v2/source") |>
req_auth_bearer_token(token) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
Returns an array with sourceId, name, fieldTypes, queue statistics and transformErrorCount. Service tokens and admins see all sources, users their own.
REST calls address sources by sourceId. To work with names, list once and map name → sourceId.
const sources = await (await fetch(`${insights}/api/v2/source`, { headers })).json()
const sourceId = sources.find(source => source.name === 'Orders').sourceId
Get a source
/api/v2/source/{sourceId}insights-service| Query | Description |
|---|---|
schema=true | Adds schema: { validation, render, translations } |
fieldTypes, config, events, queue, fields, numExamples | Optional detail flags of the Insights app |
Response includes config, fieldTypes, rawDocCount, totalDocCount. Secrets of functions are redacted.
Query and aggregate
/api/v2/source/{sourceId}/aggregateinsights-service- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source/$SOURCE_ID/aggregate \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"size": 10,
"fields": ["orderId", "total", "status"],
"filter": [{ "term": { "status.keyword": "paid" } }],
"sort": [{ "total": "desc" }]
}'
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/source/${sourceId}/aggregate`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
size: 10,
fields: ['orderId', 'total', 'status'],
filter: [{ term: { 'status.keyword': 'paid' } }],
sort: [{ total: 'desc' }]
})
})
console.log(response.status, await response.json())
import requests
response = requests.post(
f"https://insights-service.scenid.cloud/api/v2/source/{source_id}/aggregate",
headers={"Authorization": f"Bearer {token}"},
json={
"size": 10,
"fields": ["orderId", "total", "status"],
"filter": [{"term": {"status.keyword": "paid"}}],
"sort": [{"total": "desc"}],
},
)
print(response.status_code, response.json())
library(httr2)
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/source/", source_id, "/aggregate")) |>
req_auth_bearer_token(token) |>
req_body_json(list(
size = 10,
fields = list("orderId", "total", "status"),
filter = list(list(term = list(status.keyword = "paid"))),
sort = list(list(total = "desc"))
)) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
| Body | Type | Description |
|---|---|---|
size, from | number | Page size, offset |
fields | string[] | Returned fields |
filter | array | Elasticsearch clauses (all must match) |
sort | array | Elasticsearch sort clauses |
pageKey | array or object | nextPageKey of the previous page |
aggs, aggMode | array, string | Grouping and metric stages, and the mode (aggregation or composite). aggMode is required with aggs |
includeFieldTypes | boolean | |
raw | boolean | Read the raw index |
{
"rows": [{ "_id": "…", "orderId": "ORD-1042", "total": 119.6, "status": "paid" }],
"nextPageKey": [119.6, 4211],
"totalDocCount": { "value": 60, "relation": "eq" },
"filteredDocCount": { "value": 41, "relation": "eq" }
}
See the Query reference for every filter, grouping, metric and response shape, and Recipes for ready-made requests.
Push
/api/v2/source/{sourceId}/pushinsights-serviceQueues one document or an array. Only service tokens, only sources of type push.
- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source/$SOURCE_ID/push \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '[{ "timestamp": "2026-09-01T10:00:00Z", "deviceId": "SENS-HH-01", "temperature": 20.4 }]'
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/source/${sourceId}/push`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify([
{
timestamp: '2026-09-01T10:00:00Z',
deviceId: 'SENS-HH-01',
temperature: 20.4
}
])
})
console.log(response.status, await response.json())
import requests
response = requests.post(
f"https://insights-service.scenid.cloud/api/v2/source/{source_id}/push",
headers={"Authorization": f"Bearer {token}"},
json=[
{
"timestamp": "2026-09-01T10:00:00Z",
"deviceId": "SENS-HH-01",
"temperature": 20.4,
},
],
)
print(response.status_code, response.json())
library(httr2)
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/source/", source_id, "/push")) |>
req_auth_bearer_token(token) |>
req_body_json(list(
list(
timestamp = "2026-09-01T10:00:00Z",
deviceId = "SENS-HH-01",
temperature = 20.4
)
)) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
Response { "ok": true, "queued": 1 }. Errors: push/invalid-source-type, push/source-not-ready, push/empty-body.
Other source endpoints
Used by the Insights app, not by the SDK: GET /{id}/transform-errors, PUT /{id}/transform-error-handling, POST /{id}/reset, GET /{id}/export.csv (streams the full table as CSV), function management.