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
object[]

Optional conditions to filter events before aggregation.

Maximum array length: 100
group_by
AggregationGroupBy · object[]

Optional grouping configuration for bucketing metrics.

Maximum array length: 2
owner
Public key owner · object

The owner of the resource. If you provide this, do not specify an owner_id as it will be generated automatically. When updating a wallet, you can set the owner to null to remove the owner.

owner_id
string

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
object[]

Optional conditions to filter events before aggregation.

Maximum array length: 100
group_by
AggregationGroupBy · object[]

Optional grouping configuration for bucketing metrics.

Maximum array length: 2