Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

docs(api-reference): add decide endpoint to decision engine API reference (#15048)

Ankit Kumar Gupta8d5243b37036
diff --git a/api-reference/decision-engine-api-reference/api-reference/endpoint/gateway-decision/decideGateway.mdx b/api-reference/decision-engine-api-reference/api-reference/endpoint/gateway-decision/decideGateway.mdx
index bea7088a8d..99d29ba9c9 100644
--- a/api-reference/decision-engine-api-reference/api-reference/endpoint/gateway-decision/decideGateway.mdx
+++ b/api-reference/decision-engine-api-reference/api-reference/endpoint/gateway-decision/decideGateway.mdx
@@ -1,5 +1,5 @@
---
-title: "Decide Gateway"
+title: "Decide Gateway (Auth Rate)"
description: "Core routing decision API. Given a payment context and a list of eligible gateways, returns the optimal gateway to route to."
openapi: "decision_engine_openapi-specs.json POST /decide-gateway"
---
diff --git a/api-reference/decision-engine-api-reference/api-reference/endpoint/routing-rules/decide.mdx b/api-reference/decision-engine-api-reference/api-reference/endpoint/routing-rules/decide.mdx
new file mode 100644
index 0000000000..31049ec46c
--- /dev/null
+++ b/api-reference/decision-engine-api-reference/api-reference/endpoint/routing-rules/decide.mdx
@@ -0,0 +1,5 @@
+---
+title: "Decide (MultiObjective)"
+description: "Evaluate routing with the unified payment payload."
+openapi: "decision_engine_openapi-specs.json POST /decide"
+---
diff --git a/api-reference/decision-engine-api-reference/api-reference/guides/configure-routing/routing-decide.mdx b/api-reference/decision-engine-api-reference/api-reference/guides/configure-routing/routing-decide.mdx
new file mode 100644
index 0000000000..bd181ca27b
--- /dev/null
+++ b/api-reference/decision-engine-api-reference/api-reference/guides/configure-routing/routing-decide.mdx
@@ -0,0 +1,90 @@
+---
+title: "Decide (Unified Contract)"
+description: "Curl example for /decide, the unified payment payload for hybrid routing."
+---
+
+# Decide
+
+`POST /decide` accepts a flat payment payload with nested `card` and `routing_config` objects. It runs the same hybrid evaluator as [`/routing/hybrid`](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-hybrid) — rule selection, Auth Rate routing, A/B experiments, scoring, and fallback handling.
+
+Send the same authentication and tenant headers used for `/routing/hybrid` (`Authorization: Bearer <token>` or `x-api-key: <key>`). Merchant sessions and API keys may only name their own `merchant_id`. A cross-merchant request returns `403`. Service callers can use the existing `x-admin-secret` header to act for the named routing scope. `/routing/hybrid` continues to accept its existing request and return its existing response.
+
+## Full request
+
+```bash
+curl --location "$BASE_URL/decide" \
+ --header "$AUTH_HEADER" \
+ --header "Content-Type: application/json" \
+ --data '{
+ "payment_id": "pay_demo",
+ "merchant_id": "pro_demo",
+ "amount": 1000,
+ "currency": "USD",
+ "payment_method_type": "card",
+ "payment_method_sub_type": "credit",
+ "billing_country": "US",
+ "card": {
+ "card_isin": "001234",
+ "card_extended_bin": "00123456",
+ "card_network": "Visa",
+ "card_type": "credit",
+ "card_issuing_country_code": "US"
+ },
+ "metadata": {
+ "segment": "premium"
+ },
+ "routing_config": {
+ "algorithm_for": "payment",
+ "eligible_connectors": [
+ { "gateway_name": "worldpay", "payment_merchant_connector_id": "mca_wp" },
+ { "gateway_name": "checkout", "payment_merchant_connector_id": "mca_cko" }
+ ]
+ }
+ }'
+```
+
+The required fields are `payment_id`, `merchant_id`, `amount`, `currency`, `routing_config.algorithm_for`, and `routing_config.eligible_connectors`. Every input connector requires a nonempty `gateway_name` and `payment_merchant_connector_id`. Other fields may be omitted or null. Amounts are unsigned integers in minor units. BINs are strings and preserve leading zeros.
+
+## Field mapping
+
+| `/decide` field | Existing internal field |
+| --- | --- |
+| `amount` | static `amount` and `payment_amount`, plus dynamic payment amount |
+| `payment_method_type` | static `payment_method` |
+| `payment_method_sub_type` | static `payment_method_type` |
+| `card.card_isin` | `card_bin` |
+| `card.card_extended_bin` | `extended_card_bin` |
+| `card.card_issuer` | `issuer_name` |
+| `card.card_issuing_country_code` | `issuer_country` |
+| Root `merchant_id` | static `created_by` / dynamic merchant ID |
+| `routing_config.eligible_connectors` | hybrid candidate/fallback input |
+| `payment_merchant_connector_id` | `gateway_id` / account-qualified dynamic connector |
+
+Country codes use ISO alpha-2 values. The adapter translates them to the configured country names for rule matching. Other configured enum values retain an exact match when available, otherwise a case-insensitive match. Existing rule schemas and stored configurations keep their current names.
+
+`merchant_id` is the routing scope formerly called `created_by`. Integrations must continue sending the same identifier (the Hyperswitch profile ID where applicable). `routing_config.algorithm_for` remains explicit and required. It is not inferred from `payment_id`.
+
+`amount` is the single payment amount in this contract. It supplies both existing rule parameters, `amount` and `payment_amount`, without changing stored rule definitions. `metadata` supplies custom rule parameters without overwriting configured or reserved fields. `authentication_type` supplies both rule and dynamic authentication data. Preferred accounts and ranking/elimination options are forwarded to the existing decider. Feature and experiment gates still control whether it runs. `country` takes precedence over `billing_country`, then `business_country`.
+
+The removed fields (`payment_type`, `transaction_type`, EMI fields, `internal_metadata`, `order_amount`, `payment_amount`, `udfs`, `payment_metadata`, `payment_source`, `auth_type`, and `channel`), old `context` / `created_by`, top-level card fields, and `fallback_connectors` are not accepted by `/decide`. Other endpoints retain their existing contracts. Missing required fields, unknown fields, and incorrect JSON types return `400` in the standard invalid-request format.
+
+## Response
+
+```json
+{
+ "evaluated_connectors": [
+ { "gateway_name": "worldpay", "payment_merchant_connector_id": "mca_wp" }
+ ],
+ "decision": {
+ "outcome": "routed",
+ "source": "volume_split",
+ "decision_id": "req_1234"
+ }
+}
+```
+
+`decision_id` matches the `x-request-id` response header. `source` identifies the static algorithm or dynamic routing approach. A `source` of `eligible_connectors` means hybrid used the supplied candidates after static evaluation failed. `outcome` is `routed` for a selection, `fallback` when hybrid uses a fallback, or `no_active_algorithm` / `no_eligible_connector` for an empty successful result.
+
+The endpoint preserves hybrid's connector order, selection, and errors. When there is no active rule, hybrid can still return the supplied candidates as a fallback. Existing hybrid candidate filtering still applies: a rule output outside the supplied candidate list falls back to eligible candidates. If a legacy rule returns only a gateway name, its response account ID is null. A dynamic success returns the same winning connector that hybrid puts in `evaluated_connectors`.
+
+The response omits the legacy static/dynamic diagnostic envelopes. Analytics retain those internal details, add the original `/decide` request and response, and identify the API route as `decide`. Decisions remain in the hybrid analytics and A/B experiment family.
diff --git a/api-reference/decision_engine_openapi-specs.json b/api-reference/decision_engine_openapi-specs.json
index 6a6a48be2d..9b6cc68628 100644
--- a/api-reference/decision_engine_openapi-specs.json
+++ b/api-reference/decision_engine_openapi-specs.json
@@ -2738,6 +2738,127 @@
}
}
},
+ "/decide": {
+ "post": {
+ "operationId": "decide",
+ "tags": [
+ "Routing Rules"
+ ],
+ "summary": "Decide routing",
+ "description": "Evaluate the existing hybrid routing pipeline using the flat request contract. Existing rule evaluation, SR feature gates, A/B experiments and fallback behavior apply.",
+ "security": [
+ {
+ "BearerAuth": []
+ },
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/DecideRequest"
+ },
+ "example": {
+ "payment_id": "pay_demo",
+ "merchant_id": "pro_demo",
+ "amount": 1000,
+ "currency": "USD",
+ "payment_method_type": "card",
+ "payment_method_sub_type": "credit",
+ "authentication_type": null,
+ "capture_method": null,
+ "mandate_type": null,
+ "mandate_acceptance_type": null,
+ "setup_future_usage": null,
+ "transaction_initiator": null,
+ "surcharge_amount": null,
+ "business_country": null,
+ "billing_country": "US",
+ "business_label": null,
+ "card": {
+ "card_isin": "001234",
+ "card_extended_bin": "00123456",
+ "card_network": "Visa",
+ "card_type": "credit",
+ "card_issuer": null,
+ "card_issuing_country_code": "US",
+ "card_subtype": null,
+ "card_discovery": null,
+ "card_switch_provider": null
+ },
+ "customer_device_platform": null,
+ "customer_device_type": null,
+ "customer_device_display_size": null,
+ "pay_later": null,
+ "wallet": null,
+ "upi": null,
+ "voucher": null,
+ "bank_redirect": null,
+ "bank_debit": null,
+ "bank_transfer": null,
+ "real_time_payment": null,
+ "gift_card": null,
+ "card_redirect": null,
+ "open_banking": null,
+ "mobile_payment": null,
+ "crypto": null,
+ "reward": null,
+ "network_token": null,
+ "metadata": {
+ "segment": "premium"
+ },
+ "country": null,
+ "customer_id": null,
+ "routing_config": {
+ "algorithm_for": "payment",
+ "elimination_enabled": null,
+ "enable_multi_objective": null,
+ "ranking_algorithm": null,
+ "eligible_connectors": [
+ {
+ "gateway_name": "worldpay",
+ "payment_merchant_connector_id": "mca_wp"
+ },
+ {
+ "gateway_name": "checkout",
+ "payment_merchant_connector_id": "mca_cko"
+ }
+ ],
+ "preferred_connectors": null
+ }
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Routing decision. Connector order and account IDs are preserved from hybrid routing. An account ID can be null when a legacy rule identifies only a gateway.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/DecideResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Missing required fields, unknown fields, incorrect JSON types, invalid routing input or an existing hybrid evaluation error."
+ },
+ "401": {
+ "description": "Authentication required."
+ },
+ "403": {
+ "description": "The authenticated session or API key cannot act on this merchant."
+ },
+ "500": {
+ "description": "Routing configuration or service unavailable."
+ }
+ }
+ }
+ },
"/routing/list/{created_by}": {
"post": {
"operationId": "listRoutingRules",
@@ -8487,6 +8608,444 @@
}
}
},
+ "DecideRequest": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "payment_id",
+ "merchant_id",
+ "amount",
+ "currency",
+ "routing_config"
+ ],
+ "properties": {
+ "payment_id": {
+ "type": "string"
+ },
+ "amount": {
+ "type": "integer",
+ "description": "Amount in currency minor units. Supplies both existing amount and payment_amount rule keys and the dynamic payment amount."
+ },
+ "currency": {
+ "type": "string",
+ "description": "Currency code, e.g. USD."
+ },
+ "payment_method_type": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Payment method family, e.g. card."
+ },
+ "payment_method_sub_type": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Payment method subtype, e.g. credit."
+ },
+ "authentication_type": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "capture_method": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "mandate_type": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "mandate_acceptance_type": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "setup_future_usage": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "transaction_initiator": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "surcharge_amount": {
+ "type": [
+ "integer",
+ "null"
+ ],
+ "description": "Amount in currency minor units."
+ },
+ "business_country": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "ISO 3166 alpha-2 country code."
+ },
+ "billing_country": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "ISO 3166 alpha-2 country code."
+ },
+ "business_label": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card": {
+ "$ref": "#/components/schemas/DecideCard"
+ },
+ "customer_device_platform": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "customer_device_type": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "customer_device_display_size": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "pay_later": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "wallet": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "upi": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "voucher": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "bank_redirect": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "bank_debit": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "bank_transfer": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "real_time_payment": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "gift_card": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_redirect": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "open_banking": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "mobile_payment": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "crypto": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "reward": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "network_token": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "metadata": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "country": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "ISO 3166 alpha-2 country code."
+ },
+ "customer_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "routing_config": {
+ "$ref": "#/components/schemas/DecideRoutingConfig"
+ },
+ "merchant_id": {
+ "type": "string",
+ "description": "Routing scope previously supplied as created_by. Use the same identifier, including the HS profile ID where applicable."
+ }
+ }
+ },
+ "DecideCard": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "additionalProperties": false,
+ "properties": {
+ "card_isin": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_extended_bin": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_network": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_type": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_issuer": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_issuing_country_code": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_subtype": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_discovery": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "card_switch_provider": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ }
+ },
+ "DecideConnector": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "gateway_name",
+ "payment_merchant_connector_id"
+ ],
+ "properties": {
+ "gateway_name": {
+ "type": "string"
+ },
+ "payment_merchant_connector_id": {
+ "type": "string"
+ }
+ }
+ },
+ "DecideRoutingConfig": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "algorithm_for",
+ "eligible_connectors"
+ ],
+ "properties": {
+ "algorithm_for": {
+ "type": "string"
+ },
+ "elimination_enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "enable_multi_objective": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ },
+ "ranking_algorithm": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "SR_BASED_ROUTING",
+ "PL_BASED_ROUTING",
+ "NTW_BASED_ROUTING",
+ "NTW_SR_HYBRID_ROUTING",
+ null
+ ]
+ },
+ "eligible_connectors": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideConnector"
+ }
+ },
+ "preferred_connectors": {
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "$ref": "#/components/schemas/DecideConnector"
+ }
+ }
+ }
+ },
+ "DecideResponse": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "evaluated_connectors",
+ "decision"
+ ],
+ "properties": {
+ "evaluated_connectors": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ }
+ },
+ "decision": {
+ "$ref": "#/components/schemas/DecideDecision"
+ }
+ }
+ },
+ "DecideResultConnector": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "gateway_name",
+ "payment_merchant_connector_id"
+ ],
+ "properties": {
+ "gateway_name": {
+ "type": "string"
+ },
+ "payment_merchant_connector_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ }
+ },
+ "DecideDecision": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "outcome",
+ "source",
+ "decision_id"
+ ],
+ "properties": {
+ "outcome": {
+ "type": "string",
+ "enum": [
+ "routed",
+ "fallback",
+ "no_active_algorithm",
+ "no_eligible_connector"
+ ]
+ },
+ "source": {
+ "type": "string"
+ },
+ "decision_id": {
+ "type": "string",
+ "description": "The x-request-id associated with this evaluation."
+ }
+ }
+ },
"ApiClusterSegment": {
"type": "object",
"properties": {
diff --git a/api-reference/docs.json b/api-reference/docs.json
index 8adcfd03b3..4e3a4c4465 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -606,6 +606,7 @@
{
"group": "OpenAPI: Gateway Decision",
"pages": [
+ "decision-engine-api-reference/api-reference/endpoint/routing-rules/decide",
"decision-engine-api-reference/api-reference/endpoint/gateway-decision/decideGateway"
]
},
@@ -753,7 +754,8 @@
"decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-list",
"decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-list-active",
"decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-evaluate",
- "decision-engine-api-reference/api-reference/guides/configure-routing/routing-hybrid"
+ "decision-engine-api-reference/api-reference/guides/configure-routing/routing-hybrid",
+ "decision-engine-api-reference/api-reference/guides/configure-routing/routing-decide"
]
},
{