> This page is for Gateway.

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

# Update a routing policy

PATCH https://api-gateway.merge.dev/v1/routing-policies/{policy_id}
Content-Type: application/json

Update in place; the policy id is stable across updates.

Authenticates with a management key (manage_routing scope) or any active gateway API key of the organization.

Reference: https://docs.merge.dev/merge-gateway/management-api/routing-policies/update-routing-policy

## Authentication

- `Authorization` header (bearer token, required) — A management key (prefixed `mgmt_`), created on the dashboard's **API keys** page under **Management keys**. Distinct from a regular gateway API key, and never used to call models.

## Request

### Path parameters

- `policy_id` (string, required)

### Body (application/json)

This endpoint expects an OrgRoutingPolicyUpdate.

- `name` (string, optional)
- `description` (string, optional)
- `slug` (string, optional) — Renames the policy's model alias. The alias never changes on a policy rename (it is a contract with your clients), so this field is the only way to change it; a name already in use returns 409. Clients still sending the old alias receive 404s.
- `is_default` (boolean, optional)
- `strategy` (enum, optional)
  - Allowed values: `PRIORITY`, `INTELLIGENT`
- `allowed_providers` (list of string, optional) — INTELLIGENT only, optional. If provided, must match the providers of allowed_models (it does not filter independently); returned derived from allowed_models on reads.
- `allowed_models` (list of string, optional)
- `priority_order` (list of PriorityEntry, optional)
- `axis` (enum, optional) — INTELLIGENT only. Optimization axis the router optimizes for; defaults to COST.
  - Allowed values: `COST`, `PERFORMANCE`, `CAPABILITY`

## Response

### 200

The updated policy.

- `id` (string, optional)
- `name` (string, optional)
- `description` (string, optional)
- `slug` (string, optional, nullable) — The policy's model alias (bare name), e.g. "fast-experiment". Null only when no alias could be minted, such as an organization at its alias cap.
- `model` (string, optional, nullable) — The ready-to-send model string for this policy, e.g. "@alias/fast-experiment". Send it as the model in any Gateway request to route with this policy.
- `strategy` (enum, optional)
  - Allowed values: `PRIORITY`, `INTELLIGENT`
- `allowed_providers` (list of string, optional)
- `allowed_models` (list of string, optional)
- `priority_order` (list of PriorityEntry, optional)
- `axis` (enum, optional) — Optimization axis the router optimizes for (INTELLIGENT only, else null); one of COST, PERFORMANCE, CAPABILITY.
  - Allowed values: `COST`, `PERFORMANCE`, `CAPABILITY`
- `created_at` (datetime, optional)
- `modified_at` (datetime, optional)

## Errors

### 404 Not Found Error

Not found.

- `detail` (string, optional) — Human-readable error message.

### 422 Unprocessable Entity Error

Invalid strategy fields.

- `detail` (string, optional) — Human-readable error message.

## Types

### PriorityEntry

- `model` (string, required) — Canonical model slug (provider/model).
- `priority` (integer, required) — Lower tries first.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "string",
  "name": "string",
  "description": "string",
  "slug": "string",
  "model": "string",
  "strategy": "PRIORITY",
  "allowed_providers": [
    "string"
  ],
  "allowed_models": [
    "string"
  ],
  "priority_order": [
    {
      "model": "openai/gpt-5.5",
      "priority": 1
    }
  ],
  "axis": "COST",
  "created_at": "2024-01-15T09:30:00Z",
  "modified_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/routing-policies/policy_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://api-gateway.merge.dev/v1/routing-policies/policy_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()
```