curl --request POST \
--url https://api.privy.io/v1/aggregations \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"name": "Daily ETH transfer limit on Base",
"method": "eth_signTransaction",
"metric": {
"field": "value",
"field_source": "ethereum_transaction",
"function": "sum"
},
"window": {
"type": "rolling",
"seconds": 86400
},
"conditions": [
{
"field_source": "ethereum_transaction",
"field": "chain_id",
"operator": "eq",
"value": "84532"
}
],
"group_by": [
{
"field": "to",
"field_source": "ethereum_transaction"
}
]
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/aggregations")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Daily ETH transfer limit on Base\",\n \"method\": \"eth_signTransaction\",\n \"metric\": {\n \"field\": \"value\",\n \"field_source\": \"ethereum_transaction\",\n \"function\": \"sum\"\n },\n \"window\": {\n \"type\": \"rolling\",\n \"seconds\": 86400\n },\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"field\": \"chain_id\",\n \"operator\": \"eq\",\n \"value\": \"84532\"\n }\n ],\n \"group_by\": [\n {\n \"field\": \"to\",\n \"field_source\": \"ethereum_transaction\"\n }\n ]\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Daily ETH transfer limit on Base',
method: 'eth_signTransaction',
metric: {field: 'value', field_source: 'ethereum_transaction', function: 'sum'},
window: {type: 'rolling', seconds: 86400},
conditions: [
{
field_source: 'ethereum_transaction',
field: 'chain_id',
operator: 'eq',
value: '84532'
}
],
group_by: [{field: 'to', field_source: 'ethereum_transaction'}]
})
};
fetch('https://api.privy.io/v1/aggregations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/aggregations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Daily ETH transfer limit on Base',
'method' => 'eth_signTransaction',
'metric' => [
'field' => 'value',
'field_source' => 'ethereum_transaction',
'function' => 'sum'
],
'window' => [
'type' => 'rolling',
'seconds' => 86400
],
'conditions' => [
[
'field_source' => 'ethereum_transaction',
'field' => 'chain_id',
'operator' => 'eq',
'value' => '84532'
]
],
'group_by' => [
[
'field' => 'to',
'field_source' => 'ethereum_transaction'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/aggregations"
payload := strings.NewReader("{\n \"name\": \"Daily ETH transfer limit on Base\",\n \"method\": \"eth_signTransaction\",\n \"metric\": {\n \"field\": \"value\",\n \"field_source\": \"ethereum_transaction\",\n \"function\": \"sum\"\n },\n \"window\": {\n \"type\": \"rolling\",\n \"seconds\": 86400\n },\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"field\": \"chain_id\",\n \"operator\": \"eq\",\n \"value\": \"84532\"\n }\n ],\n \"group_by\": [\n {\n \"field\": \"to\",\n \"field_source\": \"ethereum_transaction\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"name": "<string>",
"method": "eth_signTransaction",
"metric": {
"field": "<string>",
"field_source": "<string>",
"function": "sum",
"abi": [
{
"type": "function",
"name": "<string>",
"inputs": [
{
"type": "<string>",
"name": "<string>",
"components": [
{}
],
"indexed": true,
"internalType": "<string>"
}
],
"outputs": [
{
"type": "<string>",
"name": "<string>",
"components": [
{}
],
"indexed": true,
"internalType": "<string>"
}
],
"stateMutability": "pure",
"anonymous": true
}
]
},
"window": {
"type": "rolling",
"seconds": 131400
},
"id": "<string>",
"created_at": 123,
"owner_id": "<string>",
"conditions": [],
"group_by": []
}Create aggregation
Create a new aggregation to track and measure metrics over a time window.
curl --request POST \
--url https://api.privy.io/v1/aggregations \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"name": "Daily ETH transfer limit on Base",
"method": "eth_signTransaction",
"metric": {
"field": "value",
"field_source": "ethereum_transaction",
"function": "sum"
},
"window": {
"type": "rolling",
"seconds": 86400
},
"conditions": [
{
"field_source": "ethereum_transaction",
"field": "chain_id",
"operator": "eq",
"value": "84532"
}
],
"group_by": [
{
"field": "to",
"field_source": "ethereum_transaction"
}
]
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/aggregations")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Daily ETH transfer limit on Base\",\n \"method\": \"eth_signTransaction\",\n \"metric\": {\n \"field\": \"value\",\n \"field_source\": \"ethereum_transaction\",\n \"function\": \"sum\"\n },\n \"window\": {\n \"type\": \"rolling\",\n \"seconds\": 86400\n },\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"field\": \"chain_id\",\n \"operator\": \"eq\",\n \"value\": \"84532\"\n }\n ],\n \"group_by\": [\n {\n \"field\": \"to\",\n \"field_source\": \"ethereum_transaction\"\n }\n ]\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Daily ETH transfer limit on Base',
method: 'eth_signTransaction',
metric: {field: 'value', field_source: 'ethereum_transaction', function: 'sum'},
window: {type: 'rolling', seconds: 86400},
conditions: [
{
field_source: 'ethereum_transaction',
field: 'chain_id',
operator: 'eq',
value: '84532'
}
],
group_by: [{field: 'to', field_source: 'ethereum_transaction'}]
})
};
fetch('https://api.privy.io/v1/aggregations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/aggregations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Daily ETH transfer limit on Base',
'method' => 'eth_signTransaction',
'metric' => [
'field' => 'value',
'field_source' => 'ethereum_transaction',
'function' => 'sum'
],
'window' => [
'type' => 'rolling',
'seconds' => 86400
],
'conditions' => [
[
'field_source' => 'ethereum_transaction',
'field' => 'chain_id',
'operator' => 'eq',
'value' => '84532'
]
],
'group_by' => [
[
'field' => 'to',
'field_source' => 'ethereum_transaction'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/aggregations"
payload := strings.NewReader("{\n \"name\": \"Daily ETH transfer limit on Base\",\n \"method\": \"eth_signTransaction\",\n \"metric\": {\n \"field\": \"value\",\n \"field_source\": \"ethereum_transaction\",\n \"function\": \"sum\"\n },\n \"window\": {\n \"type\": \"rolling\",\n \"seconds\": 86400\n },\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"field\": \"chain_id\",\n \"operator\": \"eq\",\n \"value\": \"84532\"\n }\n ],\n \"group_by\": [\n {\n \"field\": \"to\",\n \"field_source\": \"ethereum_transaction\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"name": "<string>",
"method": "eth_signTransaction",
"metric": {
"field": "<string>",
"field_source": "<string>",
"function": "sum",
"abi": [
{
"type": "function",
"name": "<string>",
"inputs": [
{
"type": "<string>",
"name": "<string>",
"components": [
{}
],
"indexed": true,
"internalType": "<string>"
}
],
"outputs": [
{
"type": "<string>",
"name": "<string>",
"components": [
{}
],
"indexed": true,
"internalType": "<string>"
}
],
"stateMutability": "pure",
"anonymous": true
}
]
},
"window": {
"type": "rolling",
"seconds": 131400
},
"id": "<string>",
"created_at": 123,
"owner_id": "<string>",
"conditions": [],
"group_by": []
}SDK methods
Learn more about creating aggregations and using them in policies here.Authorizations
Basic Auth header with your app ID as the username and your app secret as the password.
Headers
ID of your Privy app.
Idempotency keys ensure API requests are executed only once within a 24-hour window.
Body
Input for creating an aggregation.
The name of the aggregation.
1 - 255The RPC method this aggregation applies to.
eth_signTransaction, eth_signUserOperation The metric configuration for an aggregation, defining what field/field_source to measure and the aggregation function to apply.
Show child attributes
Show child attributes
The time window configuration for an aggregation.
Show child attributes
Show child attributes
Optional conditions to filter events before aggregation.
100The verbatim Ethereum transaction object in an eth_signTransaction or eth_sendTransaction request.
- EthereumTransactionCondition
- EthereumCalldataCondition
- EthereumTypedDataDomainCondition
- EthereumTypedDataMessageCondition
- Ethereum7702AuthorizationCondition
- TempoTransactionCondition
- SolanaProgramInstructionCondition
- SolanaSystemProgramInstructionCondition
- SolanaTokenProgramInstructionCondition
- SystemCondition
- TronTransactionCondition
- TronCalldataCondition
- XrplTransactionCondition
- SuiTransactionCommandCondition
- SuiTransferObjectsCommandCondition
- ActionRequestBodyCondition
- AggregationCondition
- MessageSigningCondition
Show child attributes
Show child attributes
Optional grouping configuration for bucketing metrics.
2Show child attributes
Show child attributes
Owner input specifying a Privy user ID.
- OwnerInputUser
- OwnerInputPublicKey
Show child attributes
Show child attributes
The key quorum ID to set as the owner of the resource. If you provide this, do not specify an owner.
Response
Created aggregation object.
An aggregation that measures and tracks metrics over a period of time.
The name of the aggregation.
1 - 255The RPC method this aggregation applies to.
eth_signTransaction, eth_signUserOperation The metric configuration for an aggregation, defining what field/field_source to measure and the aggregation function to apply.
Show child attributes
Show child attributes
The time window configuration for an aggregation.
Show child attributes
Show child attributes
Unique ID of the aggregation.
Unix timestamp of when the aggregation was created in milliseconds.
The key quorum ID of the owner of the aggregation.
Optional conditions to filter events before aggregation.
100The verbatim Ethereum transaction object in an eth_signTransaction or eth_sendTransaction request.
- EthereumTransactionCondition
- EthereumCalldataCondition
- EthereumTypedDataDomainCondition
- EthereumTypedDataMessageCondition
- Ethereum7702AuthorizationCondition
- TempoTransactionCondition
- SolanaProgramInstructionCondition
- SolanaSystemProgramInstructionCondition
- SolanaTokenProgramInstructionCondition
- SystemCondition
- TronTransactionCondition
- TronCalldataCondition
- XrplTransactionCondition
- SuiTransactionCommandCondition
- SuiTransferObjectsCommandCondition
- ActionRequestBodyCondition
- AggregationCondition
- MessageSigningCondition
Show child attributes
Show child attributes
Optional grouping configuration for bucketing metrics.
2Show child attributes
Show child attributes
Was this page helpful?

