> ## 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.

# Hybrid Routing

> Evaluate hybrid routing using the active routing rule plus runtime payment context.



## OpenAPI

````yaml decision_engine_openapi-specs.json POST /routing/hybrid
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:
  /routing/hybrid:
    post:
      tags:
        - Routing Rules
      summary: Hybrid routing evaluation
      description: >-
        Evaluate hybrid routing using the active routing rule plus runtime
        payment context.
      operationId: hybridRouting
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HybridRoutingRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HybridRoutingResponse'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    HybridRoutingRequest:
      type: object
      properties:
        static_routing_request:
          oneOf:
            - $ref: '#/components/schemas/RoutingRequest'
            - type: 'null'
        dynamic_routing_request:
          oneOf:
            - $ref: '#/components/schemas/DecideGatewayRequest'
            - type: 'null'
      description: >-
        At least one of `static_routing_request` or `dynamic_routing_request`
        must be provided.
    HybridRoutingResponse:
      type: object
      properties:
        static_routing:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Result of the static rule evaluation.
        dynamic_routing:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: >-
            Decision-gateway result, wrapped as `{status, decision,
            fallback_connectors}`.
        evaluated_connectors:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Connectors clients should consume. Prefer this over the per-branch
            outputs.
    RoutingRequest:
      type: object
      required:
        - created_by
        - parameters
      description: >-
        Request body for POST /routing/evaluate
        (src/euclid/types.rs::RoutingRequest). No camelCase rename — snake_case
        field names.
      properties:
        payment_id:
          type:
            - string
            - 'null'
        created_by:
          type: string
          example: test_merchant
        fallback_output:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ConnectorInfo'
          description: Used when the rule evaluation yields no eligible connector.
        parameters:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ValueType'
          description: >-
            Map of DSL parameter name (e.g. currency, amount, cardType) to its
            ValueType.
          example:
            currency:
              type: str_value
              value: USD
    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.
    ConnectorInfo:
      type: object
      properties:
        gateway_name:
          type: string
        gateway_id:
          type:
            - string
            - 'null'
    ValueType:
      type: object
      required:
        - type
      description: Euclid condition value. Tagged by `type`; `value` holds the payload.
      properties:
        type:
          type: string
          enum:
            - number
            - enum_variant
            - metadata_variant
            - str_value
            - global_ref
            - number_array
            - enum_variant_array
            - number_comparison_array
        value:
          description: >-
            Shape depends on `type`: number->integer,
            enum_variant/str_value/global_ref->string,
            number_array/enum_variant_array->array of number/string,
            number_comparison_array->array of comparisons.
    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
            - 'null'
          description: ISO 3166-1 alpha-2 country code.
          example: US
        customerId:
          type:
            - string
            - 'null'
          example: cust_123
        udfs:
          type:
            - object
            - 'null'
          description: User-defined fields, keyed udf1..udf20.
          additionalProperties:
            type: string
        preferredGateway:
          type:
            - string
            - 'null'
          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
            - 'null'
        internalMetadata:
          type:
            - string
            - 'null'
        isEmi:
          type:
            - boolean
            - 'null'
        emiBank:
          type:
            - string
            - 'null'
        emiTenure:
          type:
            - integer
            - 'null'
          format: int32
        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
            - 'null'
        authType:
          type:
            - string
            - 'null'
          enum:
            - ATMPIN
            - THREE_DS
            - THREE_DS2
            - OTP
            - OBO_OTP
            - VIES
            - NO_THREE_DS
            - NETWORK_TOKEN
            - MOTO
            - FIDO
            - CTP
          example: THREE_DS
        cardIssuerBankName:
          type:
            - string
            - 'null'
        cardIsin:
          type:
            - string
            - 'null'
          example: '411111'
        cardType:
          type:
            - string
            - 'null'
          description: e.g. CREDIT, DEBIT, PREPAID, UPI, NB.
          example: CREDIT
        cardSwitchProvider:
          type:
            - string
            - 'null'
        cardProgram:
          type:
            - string
            - 'null'
        cardIssuerCountry:
          type:
            - string
            - 'null'
        channel:
          type:
            - string
            - 'null'
          description: 'Acceptance channel: ecom / pos / contactless.'
  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

````