Documents
Base: https://insights-service.<domain>/api/v2/source/{sourceId}. Sources of type store and push.
Write rules: the body is a flat object (objects only for list and geo-point), without id or _id. Values are converted to the field types, unknown fields are dropped.
Get
/doc/{docId}insights-serviceResponse { "id": "…", "doc": { … } }. 404 doc/not-found.
Create
/docinsights-service- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source/$SOURCE_ID/doc \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"data": {
"orderId": "ORD-2001", "orderedAt": "2026-09-01T10:15:00Z", "quantity": 2,
"unitPrice": 24.9, "total": 49.8, "status": "paid", "newCustomer": true
},
"return": false
}'
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/source/${sourceId}/doc`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
data: {
orderId: 'ORD-2001',
orderedAt: '2026-09-01T10:15:00Z',
quantity: 2,
unitPrice: 24.9,
total: 49.8,
status: 'paid',
newCustomer: true
},
return: false
})
})
console.log(response.status, await response.json())
import requests
response = requests.post(
f"https://insights-service.scenid.cloud/api/v2/source/{source_id}/doc",
headers={"Authorization": f"Bearer {token}"},
json={
"data": {
"orderId": "ORD-2001",
"orderedAt": "2026-09-01T10:15:00Z",
"quantity": 2,
"unitPrice": 24.9,
"total": 49.8,
"status": "paid",
"newCustomer": True,
},
"return": False,
},
)
print(response.status_code, response.json())
library(httr2)
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/source/", source_id, "/doc")) |>
req_auth_bearer_token(token) |>
req_body_json(list(
data = list(
orderId = "ORD-2001",
orderedAt = "2026-09-01T10:15:00Z",
quantity = 2,
unitPrice = 24.9,
total = 49.8,
status = "paid",
newCustomer = TRUE
),
return = FALSE
)) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
Response { "id": "…", "result": "created" }, or { "id", "doc" } with return: true.
The id is the value of the duplicate-control field if the source uses one (the same key updates that document). Otherwise it is generated, and the same payload sent twice creates two documents.
Errors: doc/invalid-body, doc/body-not-flat, doc/reserved-field:<name>, doc/source-type-not-supported, doc/field-type-mismatch, validation { "errors": [...] }.
Update
/doc/{docId}insights-serviceBody { "data": { … }, "update": true, "return": false }. Without update the document is replaced. With update: true the fields are merged into the raw document. Response { "result": "ok" }. 404 doc/not-found.
Delete
/doc/{docId}insights-service204. With ?return=true: { "id", "doc" }. Removes the document from the raw and main index.
Batch insert
/batchinsights-service- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source/$SOURCE_ID/batch \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{ "data": [ { "orderId": "ORD-2002", "total": 10 }, { "orderId": "ORD-2003", "total": 12.5 } ] }'
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/source/${sourceId}/batch`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
data: [
{ orderId: 'ORD-2002', total: 10 },
{ orderId: 'ORD-2003', total: 12.5 }
]
})
})
console.log(response.status, await response.json())
import requests
response = requests.post(
f"https://insights-service.scenid.cloud/api/v2/source/{source_id}/batch",
headers={"Authorization": f"Bearer {token}"},
json={
"data": [
{"orderId": "ORD-2002", "total": 10},
{"orderId": "ORD-2003", "total": 12.5},
],
},
)
print(response.status_code, response.json())
library(httr2)
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/source/", source_id, "/batch")) |>
req_auth_bearer_token(token) |>
req_body_json(list(
data = list(
list(orderId = "ORD-2002", total = 10),
list(orderId = "ORD-2003", total = 12.5)
)
)) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
{ "created": 2, "updated": 0, "failed": 0, "total": 2, "errors": [] }
Partial success: invalid documents are listed in errors ({ code, message, path?, id? }), the rest is written. A document may carry _id. With return: true the response also has ids.
NDJSON: send Content-Type: application/x-ndjson with one JSON document per line, useful for tools like Vector.
- curl
- JavaScript
- Python
- R
curl -s https://insights-service.scenid.cloud/api/v2/source/$SOURCE_ID/batch \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/x-ndjson' \
--data-binary $'{"orderId":"ORD-2004","total":9}\n{"orderId":"ORD-2005","total":11}\n'
const lines = [
{ orderId: 'ORD-2004', total: 9 },
{ orderId: 'ORD-2005', total: 11 }
].map(doc => JSON.stringify(doc)).join('\n')
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/source/${sourceId}/batch`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/x-ndjson' },
body: `${lines}\n`
})
console.log(response.status, await response.json())
import json
import requests
docs = [{"orderId": "ORD-2004", "total": 9}, {"orderId": "ORD-2005", "total": 11}]
body = "\n".join(json.dumps(doc) for doc in docs) + "\n"
response = requests.post(
f"https://insights-service.scenid.cloud/api/v2/source/{source_id}/batch",
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/x-ndjson"},
data=body,
)
print(response.status_code, response.json())
library(httr2)
library(jsonlite)
docs <- list(
list(orderId = "ORD-2004", total = 9),
list(orderId = "ORD-2005", total = 11)
)
body <- paste0(paste(sapply(docs, toJSON, auto_unbox = TRUE), collapse = "\n"), "\n")
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/source/", source_id, "/batch")) |>
req_auth_bearer_token(token) |>
req_body_raw(body, type = "application/x-ndjson") |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
Errors: batch/invalid-body, batch/invalid-jsonl.
Find across sources
/api/v2/sources/{sourceId1,sourceId2}/docsinsights-service| Query | Description |
|---|---|
size | Default 10, max 1000 |
filter | JSON array [{ "field", "operator", "value" }] |
Operators: eq, neq, gt, gte, lt, lte, in, exists, contains.
- curl
- JavaScript
- Python
- R
curl -s -G "https://insights-service.scenid.cloud/api/v2/sources/$ID1,$ID2/docs" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode 'size=20' \
--data-urlencode 'filter=[{"field":"status","operator":"eq","value":"paid"}]'
const query = new URLSearchParams({
size: '20',
filter: '[{"field":"status","operator":"eq","value":"paid"}]'
})
const response = await fetch(`https://insights-service.scenid.cloud/api/v2/sources/${id1},${id2}/docs?${query}`, {
headers: { Authorization: `Bearer ${token}` }
})
console.log(response.status, await response.json())
import json
import requests
response = requests.get(
f"https://insights-service.scenid.cloud/api/v2/sources/{id1},{id2}/docs",
headers={"Authorization": f"Bearer {token}"},
params={
"size": 20,
"filter": json.dumps([{"field": "status", "operator": "eq", "value": "paid"}]),
},
)
print(response.status_code, response.json())
library(httr2)
library(jsonlite)
filter <- toJSON(
list(list(field = "status", operator = "eq", value = "paid")),
auto_unbox = TRUE
)
response <- request(paste0("https://insights-service.scenid.cloud/api/v2/sources/", id1, ",", id2, "/docs")) |>
req_auth_bearer_token(token) |>
req_url_query(size = 20, filter = filter) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
Response { "total": 12, "<sourceName>": [ … ] }. Errors: sources/customers-source-not-supported, source/not-found, filter/unknown-operator.