Decide Gateway
Core routing decision API. Given a payment context and a list of eligible gateways, returns the optimal gateway to route to.
Decide Gateway
Use case
Runs the core gateway decision flow for a payment. The same endpoint supports auth-rate routing, priority-list routing, debit/network routing, and network+SR hybrid routing.Authentication
Protected. Send eitherAuthorization: Bearer <jwt_token> or x-api-key: <api_key>. In sandbox, also send x-feature: decision-engine.
For local development, start with:
export BASE_URL=http://localhost:8080
export AUTH_HEADER="Authorization: Bearer <jwt_token>"
# Sandbox only:
# export BASE_URL=https://sandbox.hyperswitch.io
# export FEATURE_HEADER="x-feature: decision-engine"
Request
- Method and path:
POST /decide-gateway - Parameters: none.
- Body: JSON body with
merchantId,paymentInfo,eligibleGatewayList, andrankingAlgorithm.rankingAlgorithmmust be one ofSR_BASED_ROUTING,PL_BASED_ROUTING,NTW_BASED_ROUTING, orNTW_SR_HYBRID_ROUTING.
Example
SR based routing
curl --location "$BASE_URL/decide-gateway" \
--header "$AUTH_HEADER" \
--header "Content-Type: application/json" \
--data '{
"merchantId": "merchant_demo",
"eligibleGatewayList": ["stripe", "adyen", "checkout"],
"rankingAlgorithm": "SR_BASED_ROUTING",
"eliminationEnabled": true,
"paymentInfo": {
"paymentId": "pay_sr_001",
"amount": 1000,
"currency": "USD",
"country": "US",
"paymentType": "ORDER_PAYMENT",
"paymentMethodType": "CARD",
"paymentMethod": "CREDIT",
"authType": "THREE_DS",
"cardIsin": "424242"
}
}'
Priority-list routing
curl --location "$BASE_URL/decide-gateway" \
--header "$AUTH_HEADER" \
--header "Content-Type: application/json" \
--data '{
"merchantId": "merchant_demo",
"eligibleGatewayList": ["stripe", "adyen", "checkout"],
"rankingAlgorithm": "PL_BASED_ROUTING",
"eliminationEnabled": true,
"paymentInfo": {
"paymentId": "pay_pl_001",
"amount": 1000,
"currency": "USD",
"country": "US",
"paymentType": "ORDER_PAYMENT",
"paymentMethodType": "CARD",
"paymentMethod": "CREDIT",
"authType": "THREE_DS",
"cardIsin": "424242"
}
}'
Debit/network routing
curl --location "$BASE_URL/decide-gateway" \
--header "$AUTH_HEADER" \
--header "Content-Type: application/json" \
--data '{
"merchantId": "merchant_demo",
"eligibleGatewayList": ["stripe", "adyen"],
"rankingAlgorithm": "NTW_BASED_ROUTING",
"paymentInfo": {
"paymentId": "pay_debit_001",
"amount": 1000,
"currency": "USD",
"country": "US",
"paymentType": "ORDER_PAYMENT",
"paymentMethodType": "CARD",
"paymentMethod": "DEBIT",
"authType": "THREE_DS",
"metadata": "{\"merchant_category_code\":\"merchant_category_code_0001\",\"acquirer_country\":\"US\",\"co_badged_card_data\":{\"card_type\":\"debit\",\"issuer_country\":\"US\",\"is_regulated\":false,\"regulated_name\":null,\"card_networks\":[\"VISA\",\"NYCE\",\"PULSE\",\"STAR\"]}}"
}
}'
Multi-objective routing
curl --location "$BASE_URL/decide-gateway" \
--header "$AUTH_HEADER" \
--header "Content-Type: application/json" \
--data '{
"merchantId": "merchant_demo",
"eligibleGatewayList": ["stripe", "adyen", "checkout"],
"rankingAlgorithm": "SR_BASED_ROUTING",
"eliminationEnabled": true,
"enableMultiObjective": true,
"paymentInfo": {
"paymentId": "pay_mo_001",
"amount": 1000,
"currency": "USD",
"country": "US",
"paymentType": "ORDER_PAYMENT",
"paymentMethodType": "CARD",
"paymentMethod": "CREDIT",
"authType": "THREE_DS",
"cardIsin": "424242"
}
}'
Network + SR hybrid routing
curl --location "$BASE_URL/decide-gateway" \
--header "$AUTH_HEADER" \
--header "Content-Type: application/json" \
--data '{
"merchantId": "merchant_demo",
"eligibleGatewayList": ["stripe", "adyen"],
"rankingAlgorithm": "NTW_SR_HYBRID_ROUTING",
"paymentInfo": {
"paymentId": "pay_hybrid_001",
"amount": 1000,
"currency": "USD",
"country": "US",
"paymentType": "ORDER_PAYMENT",
"paymentMethodType": "CARD",
"paymentMethod": "DEBIT",
"authType": "THREE_DS",
"metadata": "{\"merchant_category_code\":\"merchant_category_code_0001\",\"acquirer_country\":\"US\",\"co_badged_card_data\":{\"card_type\":\"debit\",\"issuer_country\":\"US\",\"is_regulated\":false,\"regulated_name\":null,\"card_networks\":[\"VISA\",\"NYCE\",\"PULSE\",\"STAR\"]}}"
}
}'
Response
{
"decided_gateway": "stripe",
"gateway_priority_map": {
"stripe": 0.94,
"adyen": 0.91
},
"routing_approach": "SR_SELECTION_V3_ROUTING",
"gateway_before_evaluation": "stripe",
"debit_routing_output": {
"co_badged_card_networks_info": [
{
"network": "NYCE",
"saving_percentage": 1.2
}
],
"issuer_country": "US",
"is_regulated": false,
"card_type": "debit"
},
"is_rust_based_decider": true
}
Notes
- Use backend enum strings exactly; camelCase values such as
NtwBasedRoutingare invalid. - Debit routing requires the merchant debit-routing flag to be enabled and debit metadata encoded as a JSON string in
paymentInfo.metadata. - Multi-objective routing is not a
rankingAlgorithmvalue: it is a cost-aware post-step on SR-based scoring, toggled per request withenableMultiObjectiveor per merchant with themulti_objective_routing_enabledfeature flag. When it runs, the response carries amulti_objective_infoblock, androuting_approachbecomesSR_SELECTION_MULTI_OBJECTIVEwhen a cheaper gateway wins on expected value. - A successful call emits analytics/audit events asynchronously.
Related
- Decide Gateway: SR Based Routing
- Decide Gateway: PL Based Routing
- Decide Gateway: Debit Routing
- Decide Gateway: Hybrid Routing
- Decide Gateway: Multi-Objective Routing
- Update Gateway Score
Authorizations
JWT token obtained from /auth/login
Body
"test_merchant"
Show child attributes
Show child attributes
["stripe", "paypal", "adyen"]
SR_BASED_ROUTING, PL_BASED_ROUTING, NTW_BASED_ROUTING, NTW_SR_HYBRID_ROUTING "SR_BASED_ROUTING"
Per-request override for the multi-objective (cost-aware) post-step. true forces it on, false forces it off; omitted falls back to the merchant's multi_objective_routing_enabled feature flag.
Response
Gateway decision result
"stripe"
Routing approach used. SR_SELECTION_MULTI_OBJECTIVE indicates the multi-objective post-step promoted a cheaper gateway over the SR head.
"SR_SELECTION_V3_ROUTING"
Show child attributes
Show child attributes
{ "stripe": 0.94, "adyen": 0.87, "paypal": 0.72 }
Show child attributes
Show child attributes
Populated when the multi-objective post-step ran (multi_objective_routing_enabled feature flag or enableMultiObjective request field, outside hedging). Null otherwise.
Show child attributes
Show child attributes
["adyen"]
Gateway the SR head selected before the multi-objective / debit-routing post-step replaced it.
Was this page helpful?