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): update the decide endpoint docs (#15167)

Ankit Kumar Guptad75a4bbb83fc
diff --git a/api-reference/decision-engine-api-reference/api-reference.md b/api-reference/decision-engine-api-reference/api-reference.md
index e0ae64859d..7b0b584dbf 100644
--- a/api-reference/decision-engine-api-reference/api-reference.md
+++ b/api-reference/decision-engine-api-reference/api-reference.md
@@ -25,7 +25,7 @@ For advanced rule examples — AND, OR, nested AND+OR, `volume_split_priority`,
| Public | `GET /health`, `GET /health/ready`, `GET /health/diagnostics`, `POST /auth/signup`, `POST /auth/login` | None |
| Admin bootstrap | `POST /merchant-account/create` | Admin secret |
| Protected | All routing, decision, score update, rule config, API key, merchant read/delete, analytics, audit, config, and authenticated auth routes | `Authorization: Bearer <jwt_token>` or `x-api-key: <api_key>` |
-| Sandbox | Any Decision Engine route served through `https://sandbox.hyperswitch.io` | Same auth rules plus `x-feature: decision-engine` |
+| Sandbox | Any Decision Engine route served through `https://sandbox.hyperswitch.io/decision-engine/api` | Same auth rules plus `x-feature: decision-engine` |
## Endpoint Families
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 99d29ba9c9..388648f956 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
@@ -20,7 +20,7 @@ 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 BASE_URL=https://sandbox.hyperswitch.io/decision-engine/api
# export FEATURE_HEADER="x-feature: decision-engine"
```
diff --git a/api-reference/decision-engine-api-reference/api-reference/endpoint/score-feedback/updateGatewayScore.mdx b/api-reference/decision-engine-api-reference/api-reference/endpoint/score-feedback/updateGatewayScore.mdx
index c4d1f15dab..2dec9c8ad8 100644
--- a/api-reference/decision-engine-api-reference/api-reference/endpoint/score-feedback/updateGatewayScore.mdx
+++ b/api-reference/decision-engine-api-reference/api-reference/endpoint/score-feedback/updateGatewayScore.mdx
@@ -20,7 +20,7 @@ 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 BASE_URL=https://sandbox.hyperswitch.io/decision-engine/api
# export FEATURE_HEADER="x-feature: decision-engine"
```
diff --git a/api-reference/decision-engine-api-reference/api-reference/guides/api-ref.mdx b/api-reference/decision-engine-api-reference/api-reference/guides/api-ref.mdx
index 5ab5a89533..b42f451f36 100644
--- a/api-reference/decision-engine-api-reference/api-reference/guides/api-ref.mdx
+++ b/api-reference/decision-engine-api-reference/api-reference/guides/api-ref.mdx
@@ -58,7 +58,7 @@ Set these once in your shell and reuse them across every example.
export BASE_URL=http://localhost:8080
# Sandbox (routed through Hyperswitch), when applicable
-# export BASE_URL=https://sandbox.hyperswitch.io
+# export BASE_URL=https://sandbox.hyperswitch.io/decision-engine/api
# Protected endpoints accept either a dashboard JWT or an API key
export AUTH_HEADER="Authorization: Bearer <jwt_token>"
@@ -72,6 +72,8 @@ export FEATURE_HEADER="x-feature: decision-engine"
export TENANT_HEADER="x-tenant-id: public"
```
+Every path in this reference is written relative to `BASE_URL`. In sandbox, the Decision Engine sits behind the `/decision-engine/api` prefix, which the gateway strips before the request reaches the service — so `POST /decide` is `https://sandbox.hyperswitch.io/decision-engine/api/decide`. Calling it without that prefix reaches the Hyperswitch app server instead and returns `404 IR_02: Unrecognized request URL`.
+
Public routes need no auth. Protected routes include `AUTH_HEADER`:
```bash
@@ -91,7 +93,7 @@ curl "$BASE_URL/analytics/overview?range=1d" \
| Admin bootstrap | `POST /merchant-account/create` | Admin secret configured for the deployment |
| Protected APIs | API keys, merchant reads/deletes, routing, rule config, decisions, score updates, config | `Authorization: Bearer <jwt_token>` or `x-api-key: <api_key>` |
| Protected APIs (tenant-scoped) | All `GET /analytics/*`, `POST /gateway-score/reset` | The above, **plus** `TENANT_HEADER` |
-| Sandbox (Hyperswitch) | Same rules, served through `https://sandbox.hyperswitch.io` | Add `x-feature: decision-engine` |
+| Sandbox (Hyperswitch) | Same rules, served through `https://sandbox.hyperswitch.io/decision-engine/api` | Add `x-feature: decision-engine` |
<Warning>
`TENANT_HEADER` (`x-tenant-id`) has no fallback — omitting it on a route that needs it fails with `TE_03: x-tenant-id not found in headers`, regardless of a valid `AUTH_HEADER`. It's easy to miss because most routes (`/decide-gateway`, `/routing/*`, `/rule/*`, `/merchant-account/*`, `/update-gateway-score`, `/auth/*`, `/api-key/*`) resolve the tenant internally and need no such header — only the routes listed above do.
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
index bd181ca27b..24f582c51d 100644
--- 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
@@ -1,23 +1,35 @@
---
-title: "Decide (Unified Contract)"
-description: "Curl example for /decide, the unified payment payload for hybrid routing."
+title: "Decide"
+description: "Curl example for /decide, the routing decision for a single payment."
---
# 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.
+`POST /decide` routes one payment. It evaluates the merchant's active routing rule, ranks the result by success rate, cost and volume commitments, and answers with the connectors to try in order. [`/routing/hybrid`](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-hybrid) exposes the same evaluation under a different request and response.
-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.
+Authenticate with `Authorization: Bearer <token>` or `x-api-key: <key>`.
-## Full request
+## Merchant
+
+The merchant is named by the `x-connected-merchant-id` header, never the request body.
+
+| Caller | Without the header | With the header |
+| --- | --- | --- |
+| Session or API key | Its own merchant | Its own merchant, or one of its sub-merchants |
+| Service credential (`x-admin-secret`) | Not accepted, as it has no merchant of its own | The merchant named |
+
+`x-request-id` identifies the call. One is generated if absent, and it comes back as a response header. `merchant_reference_id` is your own reference for the payment and is echoed in the response.
+
+## Request
```bash
curl --location "$BASE_URL/decide" \
--header "$AUTH_HEADER" \
+ --header "x-connected-merchant-id: pro_demo" \
--header "Content-Type: application/json" \
--data '{
"payment_id": "pay_demo",
- "merchant_id": "pro_demo",
+ "merchant_reference_id": "order_demo",
"amount": 1000,
"currency": "USD",
"payment_method_type": "card",
@@ -35,56 +47,136 @@ curl --location "$BASE_URL/decide" \
},
"routing_config": {
"algorithm_for": "payment",
+ "decision_arm": "control",
"eligible_connectors": [
- { "gateway_name": "worldpay", "payment_merchant_connector_id": "mca_wp" },
- { "gateway_name": "checkout", "payment_merchant_connector_id": "mca_cko" }
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp" },
+ { "connector": "checkout", "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.
+The required fields are `payment_id`, `amount`, `currency`, `routing_config.algorithm_for` and `routing_config.eligible_connectors`. Other fields may be omitted or null, and unknown fields are rejected.
+
+- `amount` is an unsigned integer in minor units.
+- Country codes are ISO 3166 alpha-2. `billing_country`, then `business_country`, supplies the country the decider scores on.
+- BINs are strings, so leading zeros are kept.
+- A connector needs a nonempty `connector`. `merchant_connector_id` is optional and, when sent, nonempty. A connector named without an account is matched and scored by its name alone.
+- `metadata` adds custom rule parameters. It cannot overwrite a payment field or a configured rule key.
+- `payment_type` (`non_mandate`, `setup_mandate`, `ppt_mandate` and so on) routes mandate payments, such as a processor-token charge to the processor holding the token. A rule that tests it matches only when it is sent, and it does not set the decider's transaction type.
+- `authentication_type` is both matched by rules and scored by the decider.
+- `routing_config.decision_arm` names the arm the caller assigned, `control` or `variant`. It is kept in the request audit and does not override Decision Engine's own experiment assignment.
+- `routing_config` also carries `preferred_connectors`, `ranking_algorithm`, `elimination_enabled` and `enable_multi_objective`, which the decider applies where the merchant's feature and experiment gates allow it.
-## Field mapping
+## Rule keys
-| `/decide` field | Existing internal field |
+Most fields are matched under their own name, and `metadata` entries under their own keys. These are matched under a different key, so write rules against the key rather than the field name.
+
+| Request field | Rule key |
| --- | --- |
-| `amount` | static `amount` and `payment_amount`, plus dynamic payment amount |
-| `payment_method_type` | static `payment_method` |
-| `payment_method_sub_type` | static `payment_method_type` |
+| `amount` | `amount` and `payment_amount` |
+| `payment_method_type` | `payment_method` |
+| `payment_method_sub_type` | `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.
+Country codes are matched as the configured country names, which the adapter derives from the alpha-2 code. Other enum values match exactly where the configuration defines the value, otherwise case-insensitively.
## Response
```json
{
- "evaluated_connectors": [
- { "gateway_name": "worldpay", "payment_merchant_connector_id": "mca_wp" }
+ "id": "dec_1234",
+ "payment_id": "pay_demo",
+ "merchant_reference_id": "order_demo",
+ "created_at": "2026-10-30T09:12:44.518Z",
+ "connectors": [
+ { "connector": "checkout", "merchant_connector_id": "mca_cko" },
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp" }
],
- "decision": {
- "outcome": "routed",
- "source": "volume_split",
- "decision_id": "req_1234"
- }
+ "outcome": {
+ "type": "routed",
+ "strategy": "cost",
+ "reason": "cost_optimized",
+ "message": "checkout has higher expected value than SR head worldpay"
+ },
+ "rule": {
+ "status": "matched",
+ "output": {
+ "type": "priority",
+ "connectors": [
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp" },
+ { "connector": "checkout", "merchant_connector_id": "mca_cko" }
+ ]
+ },
+ "selected": [
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp" },
+ { "connector": "checkout", "merchant_connector_id": "mca_cko" }
+ ],
+ "eligible": [
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp" },
+ { "connector": "checkout", "merchant_connector_id": "mca_cko" }
+ ]
+ },
+ "success_rate": {
+ "status": "applied",
+ "approach": "sr_selection_multi_objective",
+ "scores": [
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp", "score": 0.98 },
+ { "connector": "checkout", "merchant_connector_id": "mca_cko", "score": 0.97 }
+ ],
+ "diagnostics": {
+ "head_before_downtime_check": { "connector": "worldpay", "merchant_connector_id": "mca_wp" },
+ "reset_approach": "no_reset",
+ "dimension": { "value": "ORDER_PAYMENT, CREDIT, CARD", "level": "PM_LEVEL" },
+ "filter_wise_connectors": null,
+ "priority_logic": { "tag": null, "output": null },
+ "dynamic_mga_enabled": false,
+ "connector_mga_id_map": null,
+ "rust_based_decider": true,
+ "latency_ms": 4
+ }
+ },
+ "cost": {
+ "status": "cost_won",
+ "message": "checkout has higher expected value than SR head worldpay",
+ "cost_saved_bps": 1480.0,
+ "qualified_count": 2,
+ "margin": 1.0,
+ "ev_gap_top2": 0.1351,
+ "ranked": [
+ { "connector": "checkout", "merchant_connector_id": "mca_cko", "auth_rate": 0.97, "cost_bps": 20.0,
+ "cost_source": "in_house", "cost_model": null, "ev": 0.9681, "is_sr_head": false, "is_chosen": true },
+ { "connector": "worldpay", "merchant_connector_id": "mca_wp", "auth_rate": 0.98, "cost_bps": 1500.0,
+ "cost_source": "in_house", "cost_model": null, "ev": 0.833, "is_sr_head": true, "is_chosen": false }
+ ]
+ },
+ "volume_steering": null,
+ "debit_routing": null,
+ "warnings": []
}
```
-`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.
+`connectors` is the order to try. The first is the choice and the rest the retry order. Every connector in the response, in every section, has the same `{connector, merchant_connector_id}` shape, and `merchant_connector_id` is null for a connector named without an account.
+
+`outcome` says how the order was reached:
+
+| `type` | Meaning |
+| --- | --- |
+| `routed` | The configured routing produced the order. |
+| `fallback` | Routing could not apply, so the candidates in request order, or the rule output unranked, answered. |
+| `no_connector` | No connector is left to try. `connectors` is empty and the call still succeeds. |
+
+`strategy` names the layer that set the order (`rule`, `success_rate`, `cost`, `volume_commitment`, `debit_network`, `candidate_order`, `none`) and `reason` the specific case, for example `rule_matched`, `success_rate_ranked`, `cost_optimized`, `no_active_rule`, `rule_output_not_eligible`, `rule_input_invalid`, or `success_rate_unavailable`. New values may be added to these enums. `message` is for people reading logs, so branch on `reason`.
+
+Each routing layer has a section, null when that layer did not run: `rule` (null when the rule layer failed), `success_rate` (null when the `sr-routing` setting is off or the A/B arm has no SR layer, with `status: failed` when the decider failed and the order fell back), `cost`, `volume_steering`, and `debit_routing`. `success_rate.diagnostics` carries the decider's internals for support and is not covered by compatibility guarantees.
+
+`warnings` lists problems the decision routed around: `rule_input_invalid` (a request value the routing configuration does not allow, where `param` names the request field such as `card.card_network`, and there is one warning per invalid value), `rule_evaluation_failed` (the rule could not be evaluated for another reason), `rule_output_not_eligible` and `rule_output_partially_eligible` (the rule chose connectors outside `eligible_connectors`), and `success_rate_failed`. Routing problems never fail the call.
+
+`id` is unique per decision, so a retried payment's decisions stay apart. Analytics record the request and response under the route name `decide`.
-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`.
+## Feedback
-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.
+Report the outcome with [`POST /update-gateway-score`](/decision-engine-api-reference/api-reference/guides/feedback-scoring/update-gateway-score), naming the connector as `"connector:merchant_connector_id"`, or `connector` alone when it was named without an account.
diff --git a/api-reference/decision_engine_openapi-specs.json b/api-reference/decision_engine_openapi-specs.json
index 9b6cc68628..4d82568682 100644
--- a/api-reference/decision_engine_openapi-specs.json
+++ b/api-reference/decision_engine_openapi-specs.json
@@ -19,7 +19,7 @@
"description": "Local development"
},
{
- "url": "https://sandbox.hyperswitch.io",
+ "url": "https://sandbox.hyperswitch.io/decision-engine/api",
"description": "Hyperswitch sandbox with x-feature: decision-engine"
}
],
@@ -2745,7 +2745,7 @@
"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.",
+ "description": "Route a payment: evaluate the active rule, then rank by success rate, cost and volume commitments.",
"security": [
{
"BearerAuth": []
@@ -2754,6 +2754,26 @@
"ApiKeyAuth": []
}
],
+ "parameters": [
+ {
+ "name": "x-connected-merchant-id",
+ "in": "header",
+ "required": false,
+ "schema": {
+ "type": "string"
+ },
+ "description": "The merchant to decide for. Optional with a session or API key, which defaults to its own merchant and may also name one of its sub-merchants. Required with a service credential."
+ },
+ {
+ "name": "x-request-id",
+ "in": "header",
+ "required": false,
+ "schema": {
+ "type": "string"
+ },
+ "description": "Identifies the call. One is generated if absent and returned as a response header."
+ }
+ ],
"requestBody": {
"required": true,
"content": {
@@ -2763,15 +2783,14 @@
},
"example": {
"payment_id": "pay_demo",
- "merchant_id": "pro_demo",
+ "merchant_reference_id": "order_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,
+ "payment_type": null,
"setup_future_usage": null,
"transaction_initiator": null,
"surcharge_amount": null,
@@ -2810,21 +2829,21 @@
"metadata": {
"segment": "premium"
},
- "country": null,
"customer_id": null,
"routing_config": {
"algorithm_for": "payment",
+ "decision_arm": null,
"elimination_enabled": null,
"enable_multi_objective": null,
"ranking_algorithm": null,
"eligible_connectors": [
{
- "gateway_name": "worldpay",
- "payment_merchant_connector_id": "mca_wp"
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
},
{
- "gateway_name": "checkout",
- "payment_merchant_connector_id": "mca_cko"
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko"
}
],
"preferred_connectors": null
@@ -2835,26 +2854,146 @@
},
"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.",
+ "description": "Routing decision. `connectors` is the order to try: the first is the choice, the rest the retry order.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecideResponse"
+ },
+ "example": {
+ "id": "dec_1234",
+ "payment_id": "pay_demo",
+ "merchant_reference_id": "order_demo",
+ "created_at": "2026-10-30T09:12:44.518Z",
+ "connectors": [
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko"
+ },
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
+ }
+ ],
+ "outcome": {
+ "type": "routed",
+ "strategy": "cost",
+ "reason": "cost_optimized",
+ "message": "checkout has higher expected value than SR head worldpay"
+ },
+ "rule": {
+ "status": "matched",
+ "output": {
+ "type": "priority",
+ "connectors": [
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
+ },
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko"
+ }
+ ]
+ },
+ "selected": [
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
+ },
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko"
+ }
+ ],
+ "eligible": [
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
+ },
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko"
+ }
+ ]
+ },
+ "success_rate": {
+ "status": "applied",
+ "approach": "sr_selection_multi_objective",
+ "scores": [
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp",
+ "score": 0.98
+ },
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko",
+ "score": 0.97
+ }
+ ],
+ "diagnostics": {
+ "head_before_downtime_check": {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp"
+ },
+ "reset_approach": "no_reset",
+ "dimension": {
+ "value": "ORDER_PAYMENT, CREDIT, CARD",
+ "level": "PM_LEVEL"
+ },
+ "filter_wise_connectors": null,
+ "priority_logic": {
+ "tag": null,
+ "output": null
+ },
+ "dynamic_mga_enabled": false,
+ "connector_mga_id_map": null,
+ "rust_based_decider": true,
+ "latency_ms": 4
+ }
+ },
+ "cost": {
+ "status": "cost_won",
+ "message": "checkout has higher expected value than SR head worldpay",
+ "cost_saved_bps": 1480.0,
+ "qualified_count": 2,
+ "margin": 1.0,
+ "ev_gap_top2": 0.1351,
+ "ranked": [
+ {
+ "connector": "checkout",
+ "merchant_connector_id": "mca_cko",
+ "auth_rate": 0.97,
+ "cost_bps": 20.0,
+ "cost_source": "in_house",
+ "cost_model": null,
+ "ev": 0.9681,
+ "is_sr_head": false,
+ "is_chosen": true
+ },
+ {
+ "connector": "worldpay",
+ "merchant_connector_id": "mca_wp",
+ "auth_rate": 0.98,
+ "cost_bps": 1500.0,
+ "cost_source": "in_house",
+ "cost_model": null,
+ "ev": 0.833,
+ "is_sr_head": true,
+ "is_chosen": false
+ }
+ ]
+ },
+ "volume_steering": null,
+ "debit_routing": null,
+ "warnings": []
}
}
}
},
"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."
+ "description": "`TE_03`: the request body or one of its fields is invalid, or the merchant's routing configuration could not route the payment."
}
}
}
@@ -8613,18 +8752,27 @@
"additionalProperties": false,
"required": [
"payment_id",
- "merchant_id",
"amount",
"currency",
"routing_config"
],
"properties": {
"payment_id": {
- "type": "string"
+ "type": "string",
+ "minLength": 1
+ },
+ "merchant_reference_id": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Your own reference, echoed in the response."
},
"amount": {
"type": "integer",
- "description": "Amount in currency minor units. Supplies both existing amount and payment_amount rule keys and the dynamic payment amount."
+ "minimum": 0,
+ "maximum": 18446744073709551615,
+ "description": "Amount in currency minor units."
},
"currency": {
"type": "string",
@@ -8656,17 +8804,12 @@
"null"
]
},
- "mandate_type": {
- "type": [
- "string",
- "null"
- ]
- },
- "mandate_acceptance_type": {
+ "payment_type": {
"type": [
"string",
"null"
- ]
+ ],
+ "description": "The `payment_type` rule key: `normal`, `new_mandate`, `update_mandate`, `setup_mandate`, `recurring_mandate`, `non_mandate` or `ppt_mandate`. A rule that tests `payment_type` matches only when it is sent."
},
"setup_future_usage": {
"type": [
@@ -8685,6 +8828,8 @@
"integer",
"null"
],
+ "minimum": 0,
+ "maximum": 18446744073709551615,
"description": "Amount in currency minor units."
},
"business_country": {
@@ -8827,13 +8972,6 @@
"type": "string"
}
},
- "country": {
- "type": [
- "string",
- "null"
- ],
- "description": "ISO 3166 alpha-2 country code."
- },
"customer_id": {
"type": [
"string",
@@ -8842,10 +8980,6 @@
},
"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."
}
}
},
@@ -8916,15 +9050,20 @@
"type": "object",
"additionalProperties": false,
"required": [
- "gateway_name",
- "payment_merchant_connector_id"
+ "connector"
],
"properties": {
- "gateway_name": {
- "type": "string"
+ "connector": {
+ "type": "string",
+ "minLength": 1
},
- "payment_merchant_connector_id": {
- "type": "string"
+ "merchant_connector_id": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "minLength": 1,
+ "description": "The connector account. Omit to name the connector by name alone."
}
}
},
@@ -8937,7 +9076,20 @@
],
"properties": {
"algorithm_for": {
- "type": "string"
+ "type": "string",
+ "minLength": 1
+ },
+ "decision_arm": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "control",
+ "variant",
+ null
+ ],
+ "description": "Caller-assigned decision arm, retained in the request audit. Does not override Decision Engine's internal experiment assignment. Omit or send null when unspecified."
},
"elimination_enabled": {
"type": [
@@ -8985,64 +9137,525 @@
"type": "object",
"additionalProperties": false,
"required": [
- "evaluated_connectors",
- "decision"
+ "id",
+ "payment_id",
+ "merchant_reference_id",
+ "created_at",
+ "connectors",
+ "outcome",
+ "rule",
+ "success_rate",
+ "cost",
+ "volume_steering",
+ "debit_routing",
+ "warnings"
],
"properties": {
- "evaluated_connectors": {
+ "id": {
+ "type": "string",
+ "description": "Unique per decision (`dec_` + a time-ordered UUID), so a retried payment's decisions stay apart."
+ },
+ "payment_id": {
+ "type": "string"
+ },
+ "merchant_reference_id": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "The request's `merchant_reference_id`."
+ },
+ "created_at": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "connectors": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ "description": "The order to try connectors in: the first is the choice, the rest the retry order. Empty when no connector is left."
+ },
+ "outcome": {
+ "$ref": "#/components/schemas/DecideOutcome"
+ },
+ "rule": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideRuleSection"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The rule layer's result. Null when it failed, and a `warnings` entry then says why."
+ },
+ "success_rate": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideSuccessRateSection"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Null when success-rate routing did not run (the `sr-routing` setting is off, or the A/B arm has no SR layer)."
+ },
+ "cost": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideCostSection"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Null when the cost step did not run."
+ },
+ "volume_steering": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideVolumeSteeringSection"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Null when no volume commitment was considered."
+ },
+ "debit_routing": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DebitRoutingOutput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "warnings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideWarning"
+ },
+ "description": "Problems the decision routed around. Routing problems never fail the call."
+ }
+ }
+ },
+ "DecideOutcome": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "strategy",
+ "reason",
+ "message"
+ ],
+ "description": "How the order was reached. New values may be added to each enum, so treat an unknown value as its nearest documented meaning.",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "routed",
+ "fallback",
+ "no_connector"
+ ]
+ },
+ "strategy": {
+ "type": "string",
+ "enum": [
+ "rule",
+ "success_rate",
+ "cost",
+ "volume_commitment",
+ "debit_network",
+ "candidate_order",
+ "none"
+ ],
+ "description": "The layer that set the final order."
+ },
+ "reason": {
+ "type": "string",
+ "enum": [
+ "rule_matched",
+ "rule_default_selection",
+ "rule_output_partially_eligible",
+ "priority_logic",
+ "priority_logic_downtime",
+ "merchant_preference",
+ "experiment_rule",
+ "success_rate_ranked",
+ "success_rate_downtime",
+ "success_rate_exploration",
+ "decider_default",
+ "preferred_connector",
+ "cost_optimized",
+ "volume_commitment",
+ "debit_network_optimized",
+ "no_rule_matched",
+ "no_active_rule",
+ "rule_output_not_eligible",
+ "rule_input_invalid",
+ "success_rate_unavailable",
+ "no_eligible_connectors",
+ "no_active_rule_no_candidates"
+ ]
+ },
+ "message": {
+ "type": "string",
+ "description": "For people reading logs. Not stable, so branch on `reason`."
+ }
+ }
+ },
+ "DecideRuleSection": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "status",
+ "output",
+ "selected",
+ "eligible"
+ ],
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": [
+ "matched",
+ "default_selection",
+ "no_active_rule"
+ ]
+ },
+ "output": {
+ "type": "object",
+ "description": "The algorithm's output by `type` (`straight_through`, `priority`, `volume_split`, `volume_split_priority`), laid out as in `RoutingEvaluateResponse.output` with connectors in the `DecideResultConnector` shape."
+ },
+ "selected": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DecideResultConnector"
+ },
+ "description": "The connectors the rule layer chose, narrowed to the eligible ones."
+ },
+ "eligible": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ "description": "The connectors the payment method can use."
+ }
+ }
+ },
+ "DecideSuccessRateSection": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "status",
+ "approach",
+ "scores",
+ "diagnostics"
+ ],
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": [
+ "applied",
+ "failed"
+ ]
+ },
+ "approach": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "The decider's approach, e.g. `sr_selection_v3_routing`."
+ },
+ "scores": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideConnectorScore"
+ },
+ "description": "Every scored connector, best first."
+ },
+ "diagnostics": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "description": "The decider's internals, for support: `head_before_downtime_check`, `reset_approach`, `dimension {value, level}`, `filter_wise_connectors`, `priority_logic {tag, output}`, `dynamic_mga_enabled`, `connector_mga_id_map`, `rust_based_decider` and `latency_ms`. Not covered by compatibility guarantees."
+ }
+ }
+ },
+ "DecideConnectorScore": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ {
+ "type": "object",
+ "required": [
+ "score"
+ ],
+ "properties": {
+ "score": {
+ "type": "number"
+ }
}
+ }
+ ]
+ },
+ "DecideCostSection": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "status",
+ "message",
+ "cost_saved_bps",
+ "qualified_count",
+ "margin",
+ "ev_gap_top2",
+ "ranked"
+ ],
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": [
+ "cost_won",
+ "auth_won"
+ ],
+ "description": "`cost_won`: a cheaper connector won. `auth_won`: the success-rate head kept it."
+ },
+ "message": {
+ "type": "string",
+ "description": "Human-readable text. Branch on `status` instead."
+ },
+ "cost_saved_bps": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "qualified_count": {
+ "type": "integer"
},
- "decision": {
- "$ref": "#/components/schemas/DecideDecision"
+ "margin": {
+ "type": "number"
+ },
+ "ev_gap_top2": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "ranked": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/DecideRankedConnector"
+ },
+ "description": "Every connector ranked on expected value, best first."
}
}
},
- "DecideResultConnector": {
+ "DecideRankedConnector": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ {
+ "type": "object",
+ "required": [
+ "auth_rate",
+ "cost_bps",
+ "cost_source",
+ "cost_model",
+ "ev",
+ "is_sr_head",
+ "is_chosen"
+ ],
+ "properties": {
+ "auth_rate": {
+ "type": "number"
+ },
+ "cost_bps": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "cost_source": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "enum": [
+ "in_house",
+ "seed",
+ "hypersense"
+ ]
+ },
+ "cost_model": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "description": "`brand`, `variant`, `issuer`, `ccy`, `ic_category`, `pct_bps`, `fixed_fee`."
+ },
+ "ev": {
+ "type": "number"
+ },
+ "is_sr_head": {
+ "type": "boolean"
+ },
+ "is_chosen": {
+ "type": "boolean"
+ }
+ }
+ }
+ ]
+ },
+ "DecideVolumeSteeringSection": {
"type": "object",
"additionalProperties": false,
"required": [
- "gateway_name",
- "payment_merchant_connector_id"
+ "status",
+ "message",
+ "sr_head",
+ "chosen",
+ "sr_gap_conceded",
+ "steer_rate",
+ "steering_count",
+ "run_id",
+ "blocked"
],
"properties": {
- "gateway_name": {
- "type": "string"
+ "status": {
+ "type": "string",
+ "enum": [
+ "steered",
+ "sr_prevailed"
+ ],
+ "description": "`steered`: a connector behind on its commitment took it. `sr_prevailed`: normal routing kept it."
+ },
+ "message": {
+ "type": "string",
+ "description": "Human-readable text. Branch on `status` instead."
+ },
+ "sr_head": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "chosen": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "sr_gap_conceded": {
+ "type": [
+ "number",
+ "null"
+ ]
},
- "payment_merchant_connector_id": {
+ "steer_rate": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "steering_count": {
+ "type": "integer"
+ },
+ "run_id": {
"type": [
"string",
"null"
]
+ },
+ "blocked": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "required": [
+ "connector",
+ "reason"
+ ],
+ "properties": {
+ "connector": {
+ "$ref": "#/components/schemas/DecideResultConnector"
+ },
+ "reason": {
+ "type": "string",
+ "enum": [
+ "already_chosen",
+ "not_offered",
+ "cycle_closed",
+ "outside_tolerance",
+ "lost_roll"
+ ],
+ "description": "Why this commitment did not get the payment."
+ }
+ }
+ }
}
}
},
- "DecideDecision": {
+ "DecideWarning": {
"type": "object",
"additionalProperties": false,
"required": [
- "outcome",
- "source",
- "decision_id"
+ "code",
+ "param",
+ "message"
],
"properties": {
- "outcome": {
+ "code": {
"type": "string",
"enum": [
- "routed",
- "fallback",
- "no_active_algorithm",
- "no_eligible_connector"
+ "rule_input_invalid",
+ "rule_evaluation_failed",
+ "rule_output_not_eligible",
+ "rule_output_partially_eligible",
+ "success_rate_failed"
]
},
- "source": {
+ "param": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "The request field the warning is about, such as `card.card_network`, when there is one."
+ },
+ "message": {
+ "type": "string"
+ }
+ }
+ },
+ "DecideResultConnector": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": [
+ "connector",
+ "merchant_connector_id"
+ ],
+ "properties": {
+ "connector": {
"type": "string"
},
- "decision_id": {
- "type": "string",
- "description": "The x-request-id associated with this evaluation."
+ "merchant_connector_id": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Null for a connector named without an account."
}
}
},