Supabase Aggregation RPC
API Contract
REST
/api/v1/aggregation-rpc
6 endpoints
GET
/api/v1/aggregation-rpc/api/v1/aggregation-rpc
List available RPC function invocation logs/results
Public
Response Example
{
"data": [
{
"id": "rpc-log-001",
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_participant_counts",
"period_start": "2024-10-01",
"period_end": "2024-12-31",
"result_count": 1842,
"invoked_at": "2025-01-05T08:01:00Z",
"duration_ms": 340
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 12
}
}
GET
/api/v1/aggregation-rpc/api/v1/aggregation-rpc/:id
Get the result of a specific RPC invocation log
Public
Response Example
{
"id": "rpc-log-001",
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_participant_counts",
"period_start": "2024-10-01",
"period_end": "2024-12-31",
"result": {
"total_participants": 1842,
"direct": 1102,
"bulk": 740
},
"invoked_at": "2025-01-05T08:01:00Z",
"duration_ms": 340
}
POST
/api/v1/aggregation-rpc/api/v1/aggregation-rpc
Invoke a Supabase aggregation RPC function
Public
Request Example
{
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_participant_counts",
"period_start": "2025-01-01",
"period_end": "2025-03-31"
}
Response Example
{
"id": "rpc-log-029",
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_participant_counts",
"period_start": "2025-01-01",
"period_end": "2025-03-31",
"result": {
"total_participants": 920,
"direct": 600,
"bulk": 320
},
"invoked_at": "2025-03-26T09:00:00Z",
"duration_ms": 290
}
PUT
/api/v1/aggregation-rpc/api/v1/aggregation-rpc/:id
Re-invoke an RPC function with updated parameters and overwrite result
Public
Request Example
{
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_hours_delivered",
"period_start": "2025-01-01",
"period_end": "2025-03-31"
}
Response Example
{
"id": "rpc-log-029",
"org_id": "org-bufdir-42",
"rpc_function": "get_bufdir_hours_delivered",
"result": {
"total_hours": 4820.5
},
"invoked_at": "2025-03-26T09:45:00Z",
"duration_ms": 310
}
DELETE
/api/v1/aggregation-rpc/api/v1/aggregation-rpc/:id
Delete an RPC invocation log entry
Public
Response Example
{
"deleted": true,
"id": "rpc-log-001"
}
GET
/api/v1/aggregation-rpc/api/v1/aggregation-rpc/geographic-distribution
Invoke get_bufdir_geographic_distribution RPC and return results
Public
Response Example
{
"org_id": "org-bufdir-42",
"period_start": "2025-01-01",
"period_end": "2025-03-31",
"distribution": [
{
"region_code": "NO-03",
"region_name": "Oslo",
"participant_count": 420
},
{
"region_code": "NO-30",
"region_name": "Viken",
"participant_count": 540
}
]
}