> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.hyperswitch.io/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/DecideGatewayRequest'
      responses:
        '200':
          description: Gateway decision result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecidedGateway'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    DecideGatewayRequest:
      type: object
      required:
        - merchantId
        - paymentInfo
        - eligibleGatewayList
        - rankingAlgorithm
      properties:
        merchantId:
          type: string
          example: test_merchant
        paymentInfo:
          $ref: '#/components/schemas/PaymentInfo'
        eligibleGatewayList:
          type: array
          items:
            type: string
          example:
            - stripe
            - paypal
            - adyen
        rankingAlgorithm:
          type: string
          enum:
            - SR_BASED_ROUTING
            - PL_BASED_ROUTING
            - NTW_BASED_ROUTING
            - NTW_SR_HYBRID_ROUTING
          example: SR_BASED_ROUTING
        eliminationEnabled:
          type: boolean
          default: false
        enableMultiObjective:
          type: boolean
          description: >-
            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.
    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:
          allOf:
            - $ref: '#/components/schemas/MultiObjectiveInfo'
          nullable: true
          description: >-
            Populated when the multi-objective post-step ran
            (multi_objective_routing_enabled feature flag or
            enableMultiObjective request field, outside hedging). Null
            otherwise.
    PaymentInfo:
      type: object
      required:
        - paymentId
        - amount
        - currency
        - paymentType
        - paymentMethodType
        - paymentMethod
      properties:
        paymentId:
          type: string
          example: pay_001
        amount:
          type: number
          format: double
          example: 1000
        currency:
          type: string
          description: ISO 4217 currency code.
          example: USD
        country:
          type: string
          nullable: true
          description: ISO 3166-1 alpha-2 country code.
          example: US
        customerId:
          type: string
          nullable: true
          example: cust_123
        udfs:
          type: object
          nullable: true
          description: User-defined fields, keyed udf1..udf20.
          additionalProperties:
            type: string
        preferredGateway:
          type: string
          nullable: true
          description: Pins routing to a specific gateway when set.
        paymentType:
          type: string
          enum:
            - ORDER_PAYMENT
            - MANDATE_REGISTER
            - EMANDATE_REGISTER
            - MANDATE_PAYMENT
            - EMANDATE_PAYMENT
            - TPV_PAYMENT
            - TPV_EMANDATE_REGISTER
            - TPV_MANDATE_REGISTER
            - TPV_EMANDATE_PAYMENT
            - TPV_MANDATE_PAYMENT
            - PARTIAL_CAPTURE
            - PARTIAL_VOID
            - VAN_PAYMENT
            - MOTO_PAYMENT
            - UNKNOWN
          example: ORDER_PAYMENT
        metadata:
          type: string
          nullable: true
        internalMetadata:
          type: string
          nullable: true
        isEmi:
          type: boolean
          nullable: true
        emiBank:
          type: string
          nullable: true
        emiTenure:
          type: integer
          format: int32
          nullable: true
        paymentMethodType:
          type: string
          description: >-
            Connector-defined payment method type, e.g. CARD, UPI, WALLET,
            NETBANKING.
          example: CARD
        paymentMethod:
          type: string
          description: Connector-defined payment method, e.g. CREDIT, DEBIT, GPAY.
          example: CREDIT
        paymentSource:
          type: string
          nullable: true
        authType:
          type: string
          nullable: true
          enum:
            - ATMPIN
            - THREE_DS
            - THREE_DS2
            - OTP
            - OBO_OTP
            - VIES
            - NO_THREE_DS
            - NETWORK_TOKEN
            - MOTO
            - FIDO
            - CTP
          example: THREE_DS
        cardIssuerBankName:
          type: string
          nullable: true
        cardIsin:
          type: string
          nullable: true
          example: '411111'
        cardType:
          type: string
          nullable: true
          description: e.g. CREDIT, DEBIT, PREPAID, UPI, NB.
          example: CREDIT
        cardSwitchProvider:
          type: string
          nullable: true
        cardProgram:
          type: string
          nullable: true
        cardIssuerCountry:
          type: string
          nullable: true
        channel:
          type: string
          nullable: true
          description: 'Acceptance channel: ecom / pos / contactless.'
    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
          nullable: true
        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:
          allOf:
            - $ref: '#/components/schemas/PspSummary'
          nullable: true
          description: The PSP the SR scorer would have picked.
        chosen:
          allOf:
            - $ref: '#/components/schemas/PspSummary'
          nullable: true
          description: The PSP the post-step actually chose. Equals srHead when auth won.
        costSavedBps:
          type: number
          nullable: true
          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
          nullable: true
          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
          nullable: true
          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

````