Skip to main content
PUT
Update an aggregate
Only the description of an aggregate can change. The body is the whole aggregate, not a patch: send every other field with its stored value. A field that differs is refused:
Read the aggregate first, and send it back with the new description. To count in a different way, create a new aggregate and update your rules to read it. The new aggregate starts from zero.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

aggregate_id
string
required

The aggregate identifier.

Example:

"agg_01jc0t6fwwfgfsq1md24mhyztj"

Body

application/json
name
string
required

The name a rule reads the aggregate by, as aggregate.custom.<name>. It starts with a lowercase letter and contains only lowercase letters, digits and underscores. It must be unique among your aggregates.

Maximum string length: 64
Pattern: ^[a-z][a-z0-9_]*$
Example:

"fraud_reports"

measure
enum<string>
required

What the aggregate counts for each value of key.

  • COUNT - The number of matching events.
  • COUNT_DISTINCT - The number of different values of distinct in the matching events. A counter keeps at most 10,000 values: past this, the values seen least recently are dropped, so the count stops at 10,000.
Available options:
COUNT,
COUNT_DISTINCT
Example:

"COUNT"

key
enum<string>[]
required

The event values that select a counter: there is one counter for each combination of their values. At least one, and each one only once.

  • target.phone_number - The phone number of the event target.
  • target.email_address - The email address of the event target.
  • target.phone_prefix_7 and target.phone_prefix_9 - The first 6 or 8 digits of the phone number of the event target: its first 7 or 9 characters, without the leading +. For +33612345678, they are 336123 and 33612345.

An event has one target, so key and distinct together read either the email address or the phone number fields, not both. An event that has no value for one of them is not counted.

Available options:
target.phone_number,
target.email_address,
target.phone_prefix_7,
target.phone_prefix_9
Example:
window
enum<string>
required

How far back the aggregate counts. The window slides, so an event stops being counted when it is older than the window.

Available options:
10m,
1h,
3h,
24h,
14d
Example:

"14d"

source
object
required

What feeds the aggregate.

description
string

A free-text explanation of the aggregate, for the people who maintain it. Optional. Omitting it on an update clears it. It is the only field you can change after creation.

Maximum string length: 1024
Example:

"Confirmed fraud reports per phone number."

distinct
enum<string>

The event value a COUNT_DISTINCT aggregate counts the different values of. Required for COUNT_DISTINCT, refused for COUNT. It takes the same values as key.

Available options:
target.phone_number,
target.email_address,
target.phone_prefix_7,
target.phone_prefix_9
Example:

"target.phone_number"

Response

OK

id
string
required

The aggregate identifier.

Example:

"agg_01jc0t6fwwfgfsq1md24mhyztj"

name
string
required
Example:

"fraud_reports"

description
string
required
Example:

"Confirmed fraud reports per phone number."

type
enum<string>
required

Always CUSTOM. An aggregate you define is your own, and only your rules can read it.

Available options:
CUSTOM
measure
enum<string>
required
Available options:
COUNT,
COUNT_DISTINCT
key
string[]
required
Example:
window
enum<string>
required
Available options:
10m,
1h,
3h,
24h,
14d
Example:

"14d"

source
object
required
distinct
string

Only on a COUNT_DISTINCT aggregate.

Example:

"target.phone_number"