> ## Documentation Index
> Fetch the complete documentation index at: https://juspay-78-sa-banks.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy Decision Gateway

> Legacy compatibility route. New integrations should use /decide-gateway.



## OpenAPI

````yaml decision_engine_openapi-specs.json POST /decision_gateway
openapi: 3.1.0
info:
  title: Decision Engine
  description: >-
    Open-source payment gateway routing service by Juspay. Selects the optimal
    payment processor for each transaction in real-time using success-rate
    scoring, rule-based routing, and elimination logic.


    ## Authentication


    This API supports two authentication methods:


    1. **JWT Bearer Token** - For dashboard/user sessions
       - Header: `Authorization: Bearer <jwt_token>`
       - Obtain via `/auth/login` endpoint

    2. **API Key** - For service-to-service/programmatic access
       - Header: `x-api-key: DE_<64_char_hex>`
       - Create via `/api-key/create` endpoint

    Protected endpoints require one of these authentication methods.
  version: 1.4.0
  contact:
    name: Juspay
    url: https://github.com/juspay/decision-engine
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
servers:
  - url: http://localhost:8080
    description: Local development
  - url: https://sandbox.hyperswitch.io
    description: 'Hyperswitch sandbox with x-feature: decision-engine'
security: []
tags:
  - name: Health
    description: Service liveness, readiness, and diagnostics
  - name: Auth
    description: Dashboard auth and merchant selection
  - name: API Keys
    description: Service-to-service API key management
  - name: Gateway Decision
    description: Core routing decision APIs
  - name: Score Feedback
    description: Feed transaction outcomes back to improve SR scoring
  - name: Merchant Account
    description: Merchant configuration management
  - name: Routing Rules
    description: Euclid declarative routing rules engine
  - name: Rule Configuration
    description: Service-level SR/elimination config
  - name: Config
    description: Routing key and dimension metadata
  - name: Analytics
    description: ClickHouse-backed analytics and audit reads
  - name: Compatibility
    description: Legacy compatibility routes
  - name: Connector Costs
  - name: Merchant Features
  - name: Autopilot
paths:
  /decision_gateway:
    post:
      tags:
        - Compatibility
      summary: Legacy decision gateway
      description: Legacy compatibility route. New integrations should use /decide-gateway.
      operationId: legacyDecisionGateway
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyDeciderRequest'
      responses:
        '200':
          description: Gateway decision result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecidedGateway'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeciderErrorResponse'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    LegacyDeciderRequest:
      type: object
      required:
        - orderReference
        - orderMetadata
        - txnDetail
        - txnCardInfo
        - merchantAccount
      properties:
        orderReference:
          type: object
          additionalProperties: true
          description: >-
            Full internal order object. `merchantId` inside it identifies the
            merchant. `udfs` is an ARRAY of strings, not an object, and `id` is
            an integer.
        orderMetadata:
          type: object
          required:
            - partitionKey
          properties:
            partitionKey:
              type:
                - string
                - 'null'
              description: Required key. May be null.
          additionalProperties: true
          description: >-
            Full internal order-metadata object. Required. Note: `partitionKey`
            must be PRESENT in this object (it may be `null`). It is an `Option`
            field with a custom `deserialize_with` and no `serde(default)`, so
            serde requires the key even though the value is nullable.
        txnDetail:
          type: object
          required:
            - partitionKey
          properties:
            partitionKey:
              type:
                - string
                - 'null'
              description: Required key. May be null.
          additionalProperties: true
          description: >-
            Full internal transaction object. Note: `partitionKey` must be
            PRESENT in this object (it may be `null`). It is an `Option` field
            with a custom `deserialize_with` and no `serde(default)`, so serde
            requires the key even though the value is nullable.
        txnCardInfo:
          type: object
          required:
            - partitionKey
          properties:
            partitionKey:
              type:
                - string
                - 'null'
              description: Required key. May be null.
          additionalProperties: true
          description: >-
            Full internal card/payment-method object. Note: `partitionKey` must
            be PRESENT in this object (it may be `null`). It is an `Option`
            field with a custom `deserialize_with` and no `serde(default)`, so
            serde requires the key even though the value is nullable.
        merchantAccount:
          type: object
          additionalProperties: true
          description: >-
            Full internal merchant account object.
            `gatewaySuccessRateBasedDeciderInput` is a required string - `null`
            is rejected.
        txnOfferDetails:
          type:
            - array
            - 'null'
          items:
            type: object
            additionalProperties: true
        cardToken:
          type:
            - string
            - 'null'
        txnType:
          type:
            - string
            - 'null'
        shouldCreateMandate:
          type:
            - boolean
            - 'null'
        enforceGatewayList:
          type:
            - array
            - 'null'
          items:
            type: string
          example:
            - stripe
            - adyen
        priorityLogicOutput:
          type:
            - object
            - 'null'
          additionalProperties: true
        priorityLogicScript:
          type:
            - string
            - 'null'
        isEdccApplied:
          type:
            - boolean
            - 'null'
        shouldConsumeResult:
          type:
            - boolean
            - 'null'
      description: >-
        Legacy decider payload built from full internal transaction objects.
        This is NOT the `/decide-gateway` shape - posting that body here is
        rejected with a 400. `orderMetadata`, `txnDetail` and `txnCardInfo` must
        each carry a `partitionKey` key (value may be null).
    DecidedGateway:
      type: object
      properties:
        decided_gateway:
          type: string
          example: stripe
        routing_approach:
          type: string
          example: SR_SELECTION_V3_ROUTING
          description: >-
            Routing approach used. SR_SELECTION_MULTI_OBJECTIVE indicates the
            multi-objective post-step promoted a cheaper gateway over the SR
            head.
        gateway_priority_map:
          type: object
          additionalProperties:
            type: number
          example:
            stripe: 0.94
            adyen: 0.87
            paypal: 0.72
        routing_dimension:
          type: string
        routing_dimension_level:
          type: string
        reset_approach:
          type: string
        is_scheduled_outage:
          type: boolean
        is_rust_based_decider:
          type: boolean
        debit_routing_output:
          $ref: '#/components/schemas/DebitRoutingOutput'
        latency:
          type: number
        multi_objective_info:
          oneOf:
            - $ref: '#/components/schemas/MultiObjectiveInfo'
            - type: 'null'
          description: >-
            Populated when the multi-objective post-step ran
            (multi_objective_routing_enabled feature flag or
            enableMultiObjective request field, outside hedging). Null
            otherwise.
        fallback_gateways:
          type: array
          items:
            type: string
          example:
            - adyen
        filter_wise_gateways:
          type:
            - object
            - 'null'
        priority_logic_tag:
          type:
            - string
            - 'null'
        priority_logic_output:
          type:
            - object
            - 'null'
        gateway_mga_id_map:
          type:
            - object
            - 'null'
        is_dynamic_mga_enabled:
          type: boolean
        gateway_before_evaluation:
          type:
            - string
            - 'null'
          description: >-
            Gateway the SR head selected before the multi-objective /
            debit-routing post-step replaced it.
    DeciderErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: '400'
        error_code:
          type: string
          example: DATA_NOT_FOUND
        error_message:
          type: string
          example: merchant iframe preferences not found
        priority_logic_tag:
          type:
            - string
            - 'null'
        routing_approach:
          type:
            - string
            - 'null'
        filter_wise_gateways:
          type:
            - object
            - 'null'
        error_info:
          type: object
          properties:
            code:
              type: string
              example: MERCHANT_IFRAME_PREFERENCES_NOT_FOUND
            user_message:
              type: string
            developer_message:
              type: string
        priority_logic_output:
          type:
            - object
            - 'null'
        is_dynamic_mga_enabled:
          type: boolean
      description: Error envelope returned by the gateway-decision routes.
    DebitRoutingOutput:
      type: object
      properties:
        co_badged_card_networks_info:
          type: array
          items:
            type: object
            properties:
              network:
                type: string
                example: NYCE
              saving_percentage:
                type: number
                example: 1.2
        issuer_country:
          type: string
          example: US
        is_regulated:
          type: boolean
          example: false
        regulated_name:
          type:
            - string
            - 'null'
        card_type:
          type: string
          example: Debit
    MultiObjectiveInfo:
      type: object
      description: >-
        Present when the multi-objective (cost-aware) post-step ran. Explains
        why the gateway was picked: the SR head was kept (AUTH_WON) or a higher
        economic-value PSP was promoted (COST_WON). Economic value is auth rate
        × settlement value, where settlement value = txn amount − cost of
        payment processing (acquirer, issuer & network fee).
      properties:
        outcome:
          type: string
          enum:
            - COST_WON
            - AUTH_WON
          example: COST_WON
        reason:
          type: string
          example: >-
            Promoted 'adyen' over 'stripe' on expected value — saves 80.00 bps
            for 3.00pp auth.
        srHead:
          oneOf:
            - $ref: '#/components/schemas/PspSummary'
            - type: 'null'
          description: The PSP the SR scorer would have picked.
        chosen:
          oneOf:
            - $ref: '#/components/schemas/PspSummary'
            - type: 'null'
          description: The PSP the post-step actually chose. Equals srHead when auth won.
        costSavedBps:
          type:
            - number
            - 'null'
          description: >-
            Fee saved in bps when outcome is COST_WON (srHead.costBps -
            chosen.costBps).
          example: 80
        qualifiedCount:
          type: integer
          description: Number of PSPs that had cost data and were ranked on expected value.
          example: 3
        margin:
          type: number
          description: >-
            Merchant margin (fraction of ticket) applied for this transaction.
            Configured via the successRate config margin field; defaults to 1.0.
          example: 0.2
        evGapTop2:
          type:
            - number
            - 'null'
          description: >-
            Expected-value gap between the top-two EV-ranked PSPs, as a fraction
            of ticket. Null when fewer than two PSPs had cost data.
          example: 0.00182
    PspSummary:
      type: object
      properties:
        psp:
          type: string
          example: adyen
        authRate:
          type: number
          example: 0.91
        costBps:
          type:
            - number
            - 'null'
          example: 100
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from /auth/login
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key created via /api-key/create

````