Request Aggregation

Fan out a single client request to multiple upstream APIs in parallel, then merge the results into one response. Eliminate client-side orchestration and reduce round trips.

Quickstart

Add an aggregation block to your route to specify the upstream APIs to call. Each API responds concurrently and the results are combined.

{
  "aggregation": {
    "mergeStrategy": "keyed",
    "timeoutMs": 5000,
    "calls": [
      {
        "key": "user",
        "url": "https://users-api.example.com/me",
        "method": "GET",
        "required": true
      },
      {
        "key": "orders",
        "url": "https://orders-api.example.com/recent",
        "method": "GET",
        "required": false
      }
    ]
  }
}

Reference

FieldTypeDefaultRequiredDescription
mergeStrategy"keyed" | "merge""keyed"NoHow the JSON responses from upstream are combined.
timeoutMsinteger5000NoGlobal timeout in milliseconds for all upstream calls to complete.
calls.keystring-YesThe JSON key associated with this upstream call.
calls.urlstring (URI)-YesThe full URL of the upstream to call. Private IPs are rejected.
calls.requiredbooleanfalseNoIf true, the entire aggregation request fails if this upstream fails. If false, the key returns null.

Examples

Types of Merge Strategies

keyed

Each upstream result is nested under its key. Failed optional calls return null for their key.

{ "user": {...}, "orders": [...], "notifications": null }
merge

All upstream results are shallow-merged into a single flat object. Later keys override earlier ones on conflict.

{ "id": 1, "name": "Alice", "orders": [...] }

Common Errors

502 Bad Gateway

Required Call Failed

Fix: One of your upstream calls with "required": true returned a non-2xx status code or was unreachable. Either ensure the upstream is highly available or set required to false.

504 Gateway Timeout

Aggregation Timeout Exceeded

Fix: The total parallel execution time exceeded the configured timeoutMs (or default 5s). Increase the timeout or optimize the slowest upstream.

Plan Requirements

Request Aggregation is available on higher-tier plans.