> ## Documentation Index
> Fetch the complete documentation index at: https://docs.archefusion.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart routing

> Understand how Archefusion's smart routing works

<Note>
  This section assumes you have connected your payment gateways. Visit the [payment gateway](https://docs.archefusion.com/pages/payment-gateway) page to learn more.
</Note>

Smart routing is a core functionality of Archefusion that automatically determines the best payment gateway to process a payment, reducing payment failure.

It selects the most suitable gateway based on your predefined rules and the live health data of each payment gateway. If a gateway is unavailable or unresponsive during routing, Archefusion retries or moves to the next fallback gateway based on your timeout and retry settings.

## How smart routing rules work

A customer initiates a ₦50,000 payment via the card payment method on your platform.

<img src="https://mintcdn.com/archefusion/c3s6nReFl2uoWSeQ/images/Archefusion-smart-routing-payment-condition.png?fit=max&auto=format&n=c3s6nReFl2uoWSeQ&q=85&s=6df1d761cf9610b881990f8f783b07d2" alt="Archefusion smart routing" width="1596" height="721" data-path="images/Archefusion-smart-routing-payment-condition.png" />

→ Archefusion checks your first configured rule: Flutterwave is set as the first gateway to process card payments within ₦100 to ₦100,000.

<img src="https://mintcdn.com/archefusion/GtmHkwy3XSPgj3eg/images/Archefusion-smart-routing-failoverr.png?fit=max&auto=format&n=GtmHkwy3XSPgj3eg&q=85&s=5b9e36797374a995d9b174ae08a5cdfb" alt="Archefusion failover page" width="1611" height="864" data-path="images/Archefusion-smart-routing-failoverr.png" />

→ If Archefusion's live health data shows that Flutterwave is currently down, it skips it and moves to Paystack (your next [fallback gateway](https://docs.archefusion.com/pages/glossary#fallback-gateway)).

→ If Archefusion sends the payment to Paystack and gets no response after 5 seconds (your configured timeout), instead of failing the transaction immediately, Archefusion retries.

<img src="https://mintcdn.com/archefusion/c3s6nReFl2uoWSeQ/images/ArcheFusion-smart-routing-execution.png?fit=max&auto=format&n=c3s6nReFl2uoWSeQ&q=85&s=e14f6b2105fd384100f8e8eb08b043f4" alt="smart routing failover and retry settinngs" width="1613" height="854" data-path="images/ArcheFusion-smart-routing-execution.png" />

→ Archefusion waits for 2 seconds (your base delay) and retries for the first time on Paystack. Still no response after 5 seconds.

→ Since your attempts per gateway is set to 2, it waits 4 seconds (your base delay of 2 seconds doubles because your backoff strategy is exponential) and adds random jitter (e.g., 0.06 seconds) to spread retries so concurrent transactions during high-traffic periods don't overwhelm Paystack at the same moment.

→ Attempts per gateway reached, Archefusion stops trying Paystack. It waits 5 seconds (the exponential backoff calculates 8 seconds at this point, but your max delay cap of 5 seconds applies) and moves to Monnify, your next fallback gateway.

→ Archefusion successfully initiates a payment session on Monnify and redirects the customer to the checkout page.

However, if Monnify also fails, Archefusion stops entirely, all 3 retries (2 on Paystack and 1 on Monnify) are exhausted, and the transaction is marked as failed.

**Total time**: \~22 seconds. The customer never re-enters their details. No double charge.

→ Archefusion sends webhook notifications on payment status to your server.

## How to set your smart routing rules

<Accordion title="Step 1: Set the name and priority of your routing rule.">
  1. Log in to your [merchant account](https://app.archefusion.com/sign-in).

  2. Navigate to "Payment Gateways” > “Smart Routing”.

  3. Click the “First Rule” button.

  4. Enter your rule name and an optional description field. The priority field, which is automatically set to 1 on your first rule, represents the order in which the rule should be executed. I.e., a rule with priority 1 runs before one with priority 2.

  <Note>
    You can drag and reorder rules based on your preference.
  </Note>

  <img src="https://mintcdn.com/archefusion/5tQfV8nb4qyLWq5s/images/Smart-routing-rule-name.png?fit=max&auto=format&n=5tQfV8nb4qyLWq5s&q=85&s=cf377035a76d22962d8af50d3ce91cd1" alt="Archefusion basic smart routing rule" width="1894" height="738" data-path="images/Smart-routing-rule-name.png" />
</Accordion>

<Accordion title="Step 2: Set the condition to execute this rule.">
  Set your currency, payment methods, country, minimum amount, and maximum amount. This determines when the rule applies.

  For example, execute this rule when customers make card payments between ₦100 and ₦50,000.

  <img src="https://mintcdn.com/archefusion/5tQfV8nb4qyLWq5s/images/Smart-routing-payment-scenario.png?fit=max&auto=format&n=5tQfV8nb4qyLWq5s&q=85&s=14217570eed4f1228ee4895cac70183f" alt="Archefusion smart routing condition" width="1884" height="669" data-path="images/Smart-routing-payment-scenario.png" />
</Accordion>

<Accordion title="Step 3: Select your payment gateway order.">
  Select the payment gateways and the order in which Archefusion should route transactions. If the first gateway is unavailable or unhealthy, Archefusion automatically moves to the next one.

  <Note>
    You can only add configured payment gateways to your failover strategy.
  </Note>

  For example, if the provider order is Flutterwave → Paystack → Monnify, Archefusion will attempt Flutterwave first. If it is unavailable, it moves to Paystack, then Monnify.

  <img src="https://mintcdn.com/archefusion/5tQfV8nb4qyLWq5s/images/Smart-routing-failover.png.png?fit=max&auto=format&n=5tQfV8nb4qyLWq5s&q=85&s=a7f4d84256f7d48c43e52e7a3edada15" alt="Archefusion smart routing failover page" width="1877" height="807" data-path="images/Smart-routing-failover.png.png" />
</Accordion>

<Accordion title="Step 4: Configure timeout and retry behavior.">
  Set how Archefusion should handle unresponsive gateways during payment routing.

  * **Timeout (ms)**: The time Archefusion waits for a payment gateway to respond before considering it unresponsive and moving to the next gateway.

  * **Max retries:** The maximum number of times Archefusion should retry a transaction across all gateways before considering it as failed.

  * **Attempts per gateway:** The number of times Archefusion should retry a single gateway before moving to the next one.

  * **Base delay (ms):** The initial wait time before retrying an unresponsive gateway.

  * **Backoff strategy:** Determines how the wait time changes between retries. Accepted values:

    * **Exponential:** Doubles the base delay on each retry. If the base delay is 2 seconds, the wait time doubles on each subsequent retry: 4 seconds, then 8 seconds, then 16 seconds.

    * **Fixed:** The base delay remains constant on each retry. If the base delay is 2 seconds, the wait time remains 2 seconds before attempting the next retry.

  * **Max delay (ms):** The maximum wait time between retries. It is triggered when the backoff strategy's wait time increases on subsequent retries.

  For example, if the base delay is 2 seconds and the backoff strategy is exponential, the sequence would be 2 seconds, then 4 seconds, then 8 seconds. If the max delay is 5 seconds, it caps at 5 seconds.

  * **Jitter (ms):** Applies a random wait time (from 0 to the configured value) to spread retries so concurrent transactions during high-traffic periods don't overwhelm the payment gateway at the same moment.
      <img src="https://mintcdn.com/archefusion/5tQfV8nb4qyLWq5s/images/Smart-routing-execution-retries.png?fit=max&auto=format&n=5tQfV8nb4qyLWq5s&q=85&s=15f2701580f77492e3e1600c847a4d3c" alt="Archefusion smart routing execution" width="1885" height="819" data-path="images/Smart-routing-execution-retries.png" />
</Accordion>

<Accordion title="Step 5: Save your smart routing rule.">
  Click the “Save Rule” button to save your changes.
</Accordion>

<Note>
  Repeat this process for each new smart routing rule you want to create. For example, you can set up a separate rule for bank transfers or for transactions above or below a certain amount, depending on your preference.
</Note>

<Card title="Next step" icon="rocket" href="https://docs.archefusion.com/pages/webhook-setup">
  Register your webhook endpoint with Archefusion to receive payment outcome notifications.
</Card>
