Skip to main content
POST
/
v1
/
aggregations
Create aggregation
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"
    }
  ]
}
'
{
  "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

Authorization
string
header
required

Basic Auth header with your app ID as the username and your app secret as the password.

Headers

privy-app-id
string
required

ID of your Privy app.

privy-idempotency-key
string

Idempotency keys ensure API requests are executed only once within a 24-hour window.

Body

application/json

Input for creating an aggregation.

name
string
required

The name of the aggregation.

Required string length: 1 - 255
method
enum<string>
required

The RPC method this aggregation applies to.

Available options:
eth_signTransaction,
eth_signUserOperation
metric
AggregationMetric · object
required

The metric configuration for an aggregation, defining what field/field_source to measure and the aggregation function to apply.

window
AggregationWindow · object
required

The time window configuration for an aggregation.

conditions
(EthereumTransactionCondition · object | EthereumCalldataCondition · object | EthereumTypedDataDomainCondition · object | EthereumTypedDataMessageCondition · object | Ethereum7702AuthorizationCondition · object | SolanaProgramInstructionCondition · object | SolanaSystemProgramInstructionCondition · object | SolanaTokenProgramInstructionCondition · object | SystemCondition · object | TronTransactionCondition · object | TronCalldataCondition · object | SuiTransactionCommandCondition · object | SuiTransferObjectsCommandCondition · object | AggregationCondition · object)[]

Optional conditions to filter events before aggregation.

Maximum array length: 100

The verbatim Ethereum transaction object in an eth_signTransaction or eth_sendTransaction request.

group_by
AggregationGroupBy · object[]

Optional grouping configuration for bucketing metrics.

Maximum array length: 2
owner
OwnerInputUser · object

Owner input specifying a Privy user ID.

owner_id
string<cuid2> | null

The key quorum ID to set as the owner of the resource. If you provide this, do not specify an owner.

Response

200 - application/json

Created aggregation object.

An aggregation that measures and tracks metrics over a period of time.

name
string
required

The name of the aggregation.

Required string length: 1 - 255
method
enum<string>
required

The RPC method this aggregation applies to.

Available options:
eth_signTransaction,
eth_signUserOperation
metric
AggregationMetric · object
required

The metric configuration for an aggregation, defining what field/field_source to measure and the aggregation function to apply.

window
AggregationWindow · object
required

The time window configuration for an aggregation.

id
string
required

Unique ID of the aggregation.

created_at
number
required

Unix timestamp of when the aggregation was created in milliseconds.

owner_id
string | null
required

The key quorum ID of the owner of the aggregation.

conditions
(EthereumTransactionCondition · object | EthereumCalldataCondition · object | EthereumTypedDataDomainCondition · object | EthereumTypedDataMessageCondition · object | Ethereum7702AuthorizationCondition · object | SolanaProgramInstructionCondition · object | SolanaSystemProgramInstructionCondition · object | SolanaTokenProgramInstructionCondition · object | SystemCondition · object | TronTransactionCondition · object | TronCalldataCondition · object | SuiTransactionCommandCondition · object | SuiTransferObjectsCommandCondition · object | AggregationCondition · object)[]

Optional conditions to filter events before aggregation.

Maximum array length: 100

The verbatim Ethereum transaction object in an eth_signTransaction or eth_sendTransaction request.

group_by
AggregationGroupBy · object[]

Optional grouping configuration for bucketing metrics.

Maximum array length: 2