Back to Hyperswitch

Update & Delete Routing Algorithm

api-reference/decision-engine-api-reference/api-reference/guides/configure-routing/routing-algorithm-update-delete.mdx

2026.08.07.02.5 KB
Original Source

Update & Delete Routing Algorithm

Edit or remove a previously created routing algorithm — including A/B test experiments, which are stored the same way. Both operations only work on an inactive algorithm; deactivate it first with /routing/deactivate if it's currently live.

Update

Rewrites the name, description, and algorithm definition in place — the rule_id doesn't change.

bash
curl --location "$BASE_URL/routing/update" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "created_by": "merchant_demo",
    "routing_algorithm_id": "routing_e641380c-6f24-4405-8454-5ae6cbceb7a0",
    "name": "priority rule (v2)",
    "description": "try adyen before stripe",
    "algorithm": {
      "type": "priority",
      "data": [
        { "gateway_name": "adyen", "gateway_id": "mca_112" },
        { "gateway_name": "stripe", "gateway_id": "mca_111" }
      ]
    }
  }'

algorithm accepts the same type values as /routing/createsingle, priority, volume_split, advanced, or ab_test.

json
{
  "id": "routing_e641380c-6f24-4405-8454-5ae6cbceb7a0",
  "name": "priority rule (v2)",
  "algorithm_for": "payment",
  "created_at": "2026-07-01 09:12:04",
  "modified_at": "2026-07-16 10:00:00"
}

Returns an error if the algorithm is currently active, or if created_by doesn't own the algorithm.

Delete

bash
curl --location "$BASE_URL/routing/delete" \
  --header "$AUTH_HEADER" \
  --header "Content-Type: application/json" \
  --data '{
    "created_by": "merchant_demo",
    "routing_algorithm_id": "routing_e641380c-6f24-4405-8454-5ae6cbceb7a0"
  }'
json
{
  "status": "deleted",
  "routing_algorithm_id": "routing_e641380c-6f24-4405-8454-5ae6cbceb7a0"
}