Run aggregations
curl --request POST \
--url https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"steps": [
{
"type": "sum",
"input_field": "amount",
"output_field": "total"
},
{
"type": "avg",
"input_field": "amount",
"output_field": "avg_amount"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
steps: [
{type: 'sum', input_field: 'amount', output_field: 'total'},
{type: 'avg', input_field: 'amount', output_field: 'avg_amount'}
]
})
};
fetch('https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate"
payload = { "steps": [
{
"type": "sum",
"input_field": "amount",
"output_field": "total"
},
{
"type": "avg",
"input_field": "amount",
"output_field": "avg_amount"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"results": [
{}
]
}{
"error": "InvalidArguments",
"message": "<string>"
}Analytics
Run aggregations
Computes sums, averages, and counts over matching records, with optional grouping. Maximum 10 aggregation steps per call.
POST
/
v1
/
collections
/
{collection_id}
/
data
/
aggregate
Run aggregations
curl --request POST \
--url https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"steps": [
{
"type": "sum",
"input_field": "amount",
"output_field": "total"
},
{
"type": "avg",
"input_field": "amount",
"output_field": "avg_amount"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
steps: [
{type: 'sum', input_field: 'amount', output_field: 'total'},
{type: 'avg', input_field: 'amount', output_field: 'avg_amount'}
]
})
};
fetch('https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/data/aggregate"
payload = { "steps": [
{
"type": "sum",
"input_field": "amount",
"output_field": "total"
},
{
"type": "avg",
"input_field": "amount",
"output_field": "avg_amount"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"results": [
{}
]
}{
"error": "InvalidArguments",
"message": "<string>"
}Authorizations
BearerAuthOrgApiKeyAuth
User session JWT. Send as Authorization: Bearer <token>.
Path Parameters
Collection identifier returned at creation.
Body
application/json
MongoDB-style filter applied before aggregating.
Field to group results by.
Example:
"category"
Response
Aggregation results (one row per group).
Was this page helpful?