Skip to content

Fan-out Routing

Fan-out flows route each message to one or more targets based on a routing key and conditions. Use them when different payloads need different destinations.

A fan-out flow uses the fan_out block instead of target or steps:

flow: payroll-distribution
version: 1
type: fan-out
source:
connector: payroll-inbound
trigger: webhook
fan_out:
routing_key: source.client_id
targets:
- name: sap-hr
instance: sap-production
endpoint: /api/hr/payroll
method: POST
when: routing_key == "acme-corp"
mapping:
employee_id: source.employee.id
gross_pay: source.amounts.gross | decimal(2)
- name: default-hr
instance: bamboohr-production
endpoint: /api/payroll
method: POST
mapping:
employeeId: source.employee.id
on_error:
retry: 3x exponential(30s)
then: dead-letter
FieldTypeRequiredDefaultDescription
namestringYesTarget name
instancestringYesConnector instance name
endpointstringYesAPI endpoint path
methodstringNoPOSTHTTP method
mappingMappingBlockNoPer-target field mapping
whenconditionNoRouting condition

The routing_key expression is evaluated against the incoming payload. Use when conditions on each target to match:

fan_out:
routing_key: source.shipping_address.country
targets:
- name: eu-warehouse
instance: warehouse-eu
endpoint: /api/orders
method: POST
when: routing_key == "FI" or routing_key == "DE" or routing_key == "FR"
- name: us-warehouse
instance: warehouse-us
endpoint: /api/orders
method: POST
when: routing_key == "US" or routing_key == "CA"
- name: intl-warehouse
instance: warehouse-international
endpoint: /api/orders
method: POST

Targets without a when condition act as the default — they receive all messages that don’t match any conditional target.


Each target can have its own mapping to transform data for that specific destination:

targets:
- name: sap-hr
instance: sap-production
endpoint: /api/hr/payroll
method: POST
when: routing_key == "acme-corp"
mapping:
employee_id: source.employee.id
gross_pay: source.amounts.gross | decimal(2)
currency: source.currency | uppercase

flow: regional-order-routing
version: 1
type: fan-out
source:
connector: order-gateway
trigger: webhook
fan_out:
routing_key: source.region
targets:
- name: eu-fulfillment
instance: warehouse-eu
endpoint: /api/fulfill
method: POST
when: routing_key == "EU"
mapping:
order_ref: source.id
items: source.line_items
ship_to: source.shipping_address
- name: us-fulfillment
instance: warehouse-us
endpoint: /api/fulfill
method: POST
when: routing_key == "US"
mapping:
orderNumber: source.id
lineItems: source.line_items
destination: source.shipping_address
- name: apac-fulfillment
instance: warehouse-apac
endpoint: /api/orders/fulfill
method: POST
mapping:
id: source.id
items: source.line_items
on_error:
retry: 3x exponential(30s)
then: dead-letter

FeatureFan-out flowSwitch step
Flow typeDedicated type: fan-outWithin multi-step flow
RoutingPer-target when conditionsPer-case when conditions
MappingPer-target mappingPer-case mapping
Other stepsNo — fan-out onlyYes — mix with call, tag, notify, etc.
Use whenSimple conditional routingComplex pipelines with routing as one step