Skip to content
Browse API reference

Group Events

Aggregate on events

Request

POST https://api.castle.io/v1/events/group

Request body

filters
required
object[] or object

Either a list of filters or a filter tree ({ "$and" | "$or": [...] }). A tree can nest $and and $or groups, for example (A OR B) AND (C OR D), which the list form cannot express.

query_type
stringDefault: $records_with_count

The type of query to perform.

  • $count returns the number of records matching the query (total_count will be present and data will be empty)
  • $records returns the records matching the query (total_count will be 0)
  • $records_with_count returns the number of records matching the query and the records matching the query
$count$records$records_with_count
page
integer
aggregations
object[]

EXPERIMENTAL! Array of aggregations to include in the response. For each aggregation, you can reference its name in the columns, sort, and having fields.

formulas
object[]

EXPERIMENTAL! Array of formulas to include in the response. For each formula, you can reference its name in the columns, sort, and having fields.

group_by
required
object
columns
required
object[]

Array of columns to return. Each column references a field and an aggregation function. Consult the Events Schema API for the list of available fields.

having
object[]

field should contain the "name" value from your columns

sort
object
results_size
integer

Response

200
object

Returns the aggregation filtered by the filtered query

401
No body

You are missing the Authorization header, or the API secret is missing or incorrect.

403
No body

The request is rejected because the service is not enabled for this account.

422
object

The request body is unprocessable by the API. Make sure it conforms to the specified format for the endpoint.

500
No body

There’s an issue on our end.