> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paymentkit.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paymentkit.com/_mcp/server.

# Update Routing Rule

PATCH https://app.paymentkit.com/api/{account_id}/routing-rules/{rule_id}
Content-Type: application/json

Update a routing rule, or activate/deactivate it. **Deprecated** -- use
`PATCH /processor-routes/{route_id}`.

Reference: https://docs.paymentkit.com/api-reference/api-reference/routing-rules/update-routing-rule

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://app.paymentkit.com` (Production, default)
- `https://staging.paymentkit.com` (Staging)

## Request

### Path parameters

- `rule_id` (string, required)
- `account_id` (string, required)

### Body (application/json)

This endpoint expects a RoutingRuleUpdate.

- `name` (string, optional, nullable)
- `match_mode` (enum, optional, nullable) — How a route combines its conditions. The spec offers exactly these two and no nesting of boolean logic. Compound logic that neither expresses is written as several conditional routes pointing at the same route -- see the spec's "subscription tenure" example. That keeps the stored shape flat and the builder UI honest about what it can express.
  - Allowed values: `all`, `any`
- `conditions` (list of RuleCondition, optional, nullable)
- `outcome` (enum, optional, nullable) — What a matching rule did. Mapped onto a route's `type` by `rule_shim`: `stop` is a STOP route, `primary_only` a step-less LAST_SUCCESSFUL_ONLY one, and `route_to` any route that names steps.
  - Allowed values: `route_to`, `stop`, `primary_only`
- `route_id` (string, optional, nullable)
- `route_distribution` (list of RouteSplit-Input, optional, nullable) — Replace the rule's route split. Send an empty list to clear it (paired with a route_id, that turns a split rule back into a single-route one).
- `status` (enum, optional, nullable) — Activate or deactivate the rule. Draft is not reachable again.
  - Allowed values: `draft`, `active`, `inactive`

## Response

### 200

Successful Response

- `id` (string, required)
- `name` (string, required)
- `position` (integer, required) — Evaluation order, 1 = first
- `match_mode` (enum, required) — How a route combines its conditions. The spec offers exactly these two and no nesting of boolean logic. Compound logic that neither expresses is written as several conditional routes pointing at the same route -- see the spec's "subscription tenure" example. That keeps the stored shape flat and the builder UI honest about what it can express.
  - Allowed values: `all`, `any`
- `conditions` (list of RuleCondition, required)
- `outcome` (enum, required) — What a matching rule did. Mapped onto a route's `type` by `rule_shim`: `stop` is a STOP route, `primary_only` a step-less LAST_SUCCESSFUL_ONLY one, and `route_to` any route that names steps.
  - Allowed values: `route_to`, `stop`, `primary_only`
- `status` (enum, required) — Unchanged from the old API: the values are identical to `RouteStatus`.
  - Allowed values: `draft`, `active`, `inactive`
- `created_at` (datetime, required)
- `updated_at` (datetime, required)
- `route_id` (string, optional, nullable) — Route ID, when outcome is 'route_to' and one route takes all
- `route_distribution` (list of RouteSplit-Output, optional, nullable) — Weighted route split, when outcome is 'route_to' and traffic is shared

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### RuleCondition

One `field operator value` test. `value` is typed loosely on purpose: its shape depends on the operator. A scalar for equals/not_equals and the ordering operators, a list for in/not_in, a string for contains/not_contains, and a BillingFrequencyValue object for billing_frequency.

- `field` (enum, required) — The fact to match on. See GET /processor-routes/matchers for the catalog.
  - Allowed values: `payment_method`, `card_brand`, `card_funding_type`, `card_bin`, `card_issuer_country`, `billing_country`, `network_token_available`, `product`, `price`, `price_amount`, `billing_frequency`, `currency`, `processing_phase`, `payment_sequence`, `payment_type`, `initiator`, `mit_type`, `is_dunning_retry`, `last_decline_type`, `subscription_status`, `successful_payments`, `successful_rebills`, `failed_payments`
- `operator` (enum, required) — How to compare
  - Allowed values: `equals`, `not_equals`, `in`, `not_in`, `greater_than`, `greater_or_equal`, `less_than`, `less_or_equal`, `contains`, `not_contains`
- `value` (any, required) — What to compare against

### RouteSplit-Input

One slice of a rule's route distribution.

- `route_id` (string, required) — Route this share goes to
- `weight` (RouteSplitInputWeight, required) — Share of matching traffic, as a percentage

### RouteSplit-Output

One slice of a rule's route distribution.

- `route_id` (string, required) — Route this share goes to
- `weight` (string, required) — Share of matching traffic, as a percentage

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### RouteSplitInputWeight

Share of matching traffic, as a percentage

- double
- string

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "rrule_dev_a1b2c3d4e5f6g7h8",
  "name": "string",
  "position": 1,
  "match_mode": "all",
  "conditions": [
    {
      "field": "initiator",
      "operator": "equals",
      "value": null
    }
  ],
  "outcome": "route_to",
  "status": "draft",
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z",
  "route_id": "string",
  "route_distribution": [
    {
      "route_id": "proute_dev_x7k9m2n4p8q1",
      "weight": "80"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.paymentkit.com/api/account_id/routing-rules/rule_id"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.paymentkit.com/api/account_id/routing-rules/rule_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.paymentkit.com/api/account_id/routing-rules/rule_id"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.paymentkit.com/api/account_id/routing-rules/rule_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://app.paymentkit.com/api/account_id/routing-rules/rule_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.paymentkit.com/api/account_id/routing-rules/rule_id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.paymentkit.com/api/account_id/routing-rules/rule_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.paymentkit.com/api/account_id/routing-rules/rule_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```