---
title: "Create Routing Algorithm"
description: "Curl examples for /routing/create."
---

# Create Routing Algorithm

Use `/routing/create` to persist a merchant-scoped routing algorithm. Creating an algorithm does not make it active; call [`/routing/activate`](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-activate) after creation.

Supported `algorithm.type` values:

| Type | Use case | Full example |
| --- | --- | --- |
| `single` | Always return one connector. | [Single connector](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-single-connector-example) |
| `priority` | Return connectors in the configured order. | [Priority routing](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-priority-example) |
| `volume_split` | Split decisions by percentage. | [Volume split](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-volume-split-example) |
| `advanced` | Evaluate AND/OR/nested conditions before returning an output. | [Advanced routing](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-advanced-example) |
| `ab_test` | Split traffic between a control and variant strategy with guardrails and significance testing. | [A/B testing](/decision-engine-api-reference/api-reference/guides/ab-testing/ab-testing-create) |

Use [`/routing/deactivate`](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-deactivate) to deactivate the currently active algorithm without deleting it, and [update or delete](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-update-delete) an inactive algorithm in place.

## Priority Rule

```bash
curl --location "$BASE_URL/routing/create" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "priority rule",
    "created_by": "merchant_demo",
    "description": "try stripe before adyen",
    "algorithm_for": "payment",
    "algorithm": {
      "type": "priority",
      "data": [
        { "gateway_name": "stripe", "gateway_id": "mca_111" },
        { "gateway_name": "adyen", "gateway_id": "mca_112" }
      ]
    }
  }'
```

## Single Connector Rule

```bash
curl --location "$BASE_URL/routing/create" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "single connector rule",
    "created_by": "merchant_demo",
    "description": "always route to stripe",
    "algorithm_for": "payment",
    "algorithm": {
      "type": "single",
      "data": { "gateway_name": "stripe", "gateway_id": "mca_111" }
    }
  }'
```

## Volume Split Rule

```bash
curl --location "$BASE_URL/routing/create" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "volume split rule",
    "created_by": "merchant_demo",
    "description": "split traffic between stripe and adyen",
    "algorithm_for": "payment",
    "algorithm": {
      "type": "volume_split",
      "data": [
        {
          "split": 70,
          "output": { "gateway_name": "stripe", "gateway_id": "mca_111" }
        },
        {
          "split": 30,
          "output": { "gateway_name": "adyen", "gateway_id": "mca_112" }
        }
      ]
    }
  }'
```

## Advanced Rule

Use `advanced` for conditional routing. The complete AND/OR/nested reference is in [Advanced Routing Example](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-advanced-example).

```bash
curl --location "$BASE_URL/routing/create" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "advanced card rule",
    "created_by": "merchant_demo",
    "description": "route Visa cards to adyen first",
    "algorithm_for": "payment",
    "algorithm": {
      "type": "advanced",
      "data": {
        "globals": {},
        "default_selection": {
          "priority": [{ "gateway_name": "stripe", "gateway_id": "mca_111" }]
        },
        "rules": [
          {
            "name": "visa_card_rule",
            "routing_type": "priority",
            "output": {
              "priority": [
                { "gateway_name": "adyen", "gateway_id": "mca_112" },
                { "gateway_name": "stripe", "gateway_id": "mca_111" }
              ]
            },
            "statements": [
              {
                "condition": [
                  {
                    "lhs": "card_network",
                    "comparison": "equal",
                    "value": { "type": "enum_variant", "value": "Visa" },
                    "metadata": {}
                  }
                ],
                "nested": null
              }
            ]
          }
        ],
        "metadata": {}
      }
    }
  }'
```

## Response

```json
{
  "rule_id": "routing_e641380c-6f24-4405-8454-5ae6cbceb7a0",
  "name": "priority rule",
  "created_at": "2026-04-25 11:45:03",
  "modified_at": "2026-04-25 11:45:03"
}
```

## Related

- [Activate Routing Algorithm](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-activate)
- [Update & Delete Routing Algorithm](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-update-delete)
- [List Routing Algorithms](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-list)
- [Evaluate Routing Algorithm](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-evaluate)
- [Advanced Routing Example](/decision-engine-api-reference/api-reference/guides/configure-routing/routing-advanced-example)
- [A/B Testing: Create An Experiment](/decision-engine-api-reference/api-reference/guides/ab-testing/ab-testing-create)
