> 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 Blocklist Rule

PATCH https://api-gateway.merge.dev/v1/blocklist-rules/{rule_id}
Content-Type: application/json

Update the fields you send. A list you send replaces the whole list.

Reference: https://docs.merge.dev/merge-gateway/management-api/security-rules/update-blocklist-rule

## Authentication

- `Authorization` header (bearer token, required) — A management key (`mgmt_...`), sent as `Authorization: Bearer <key>`. Reading /v1/routing-policies also accepts the organization's gateway API keys; writing there needs a management key.

## Request

### Path parameters

- `rule_id` (string, required) — The rule's `id`.

### Body (application/json)

This endpoint expects a BlocklistRuleV1Update.

- `customer_ids` (list of string, optional, nullable) — Values of the `X-Customer-ID` request header the rule applies to. Empty matches every customer. Omit, or send null, to keep the current value.
- `models` (list of string, optional, nullable) — Full model ids, like `openai/gpt-5.5`. Omit, or send null, to keep the current value.
- `providers` (list of string, optional, nullable) — Model providers, the prefix of a model id, like `anthropic`. With `models` empty too, matches every model. Omit, or send null, to keep the current value.
- `reason` (string, optional, nullable) — Why the rule exists, such as a ticket or contract clause. Omit, or send null, to keep the current value.
- `rule_type` (enum, optional, nullable) — `block` denies a request when its customer matches and its model or provider matches. `pin` lets the listed customers use only the listed providers and models, and needs `customer_ids` plus `providers` or `models`. A block always wins over a pin. Omit, or send null, to keep the current value.
  - Allowed values: `block`, `pin`

## Response

### 200

The updated blocklist rule

- `created_at` (datetime, required) — When the rule was created.
- `customer_ids` (list of string, required) — Values of the `X-Customer-ID` request header the rule applies to. Empty matches every customer.
- `id` (string, required) — The rule's id.
- `models` (list of string, required) — Full model ids, like `openai/gpt-5.5`.
- `providers` (list of string, required) — Model providers, the prefix of a model id, like `anthropic`. With `models` empty too, matches every model.
- `reason` (string, required) — Why the rule exists, such as a ticket or contract clause.
- `rule_type` (enum, required) — `block` denies a request when its customer matches and its model or provider matches. `pin` lets the listed customers use only the listed providers and models, and needs `customer_ids` plus `providers` or `models`. A block always wins over a pin.
  - Allowed values: `block`, `pin`
- `updated_at` (datetime, required) — When the rule last changed.

## Errors

### 401 Unauthorized Error

The key is missing or invalid.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 403 Forbidden Error

The key lacks the scope this route needs, or the change is not allowed.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 404 Not Found Error

The resource does not exist in the key's organization.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 422 Unprocessable Entity Error

The request is invalid.

- `Update_blocklist_ruleRequestUnprocessableEntityError`

## Types

### ErrorResponseDetail

A message, or an object with a `code` to branch on and a `message`.

### HTTPValidationError

- `detail` (list of ValidationError, optional)

### ErrorResponse

The body of an error response.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### ErrorDetail

A structured error. Some carry extra fields, like `count`.

- `code` (string, required) — A stable code to branch on, like `payment_method_required`.
- `message` (string, required) — A human-readable explanation.

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "models": [
    "openai/gpt-5.5",
    "anthropic/claude-opus-4-7"
  ]
}
```

**Response**

```json
{
  "created_at": "2026-06-02T17:04:00Z",
  "customer_ids": [
    "cus_trial_4821"
  ],
  "id": "9e1c5a3f-7b2d-4a8e-b6c0-2d4f6a8c0e35",
  "models": [
    "openai/gpt-5.5"
  ],
  "providers": [],
  "reason": "Trial customers can't use GPT-5.5.",
  "rule_type": "block",
  "updated_at": "2026-09-14T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/blocklist-rules/rule_id"

payload = { "models": ["openai/gpt-5.5", "anthropic/claude-opus-4-7"] }
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/blocklist-rules/rule_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"models":["openai/gpt-5.5","anthropic/claude-opus-4-7"]}'
};

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/blocklist-rules/rule_id"

	payload := strings.NewReader("{\n  \"models\": [\n    \"openai/gpt-5.5\",\n    \"anthropic/claude-opus-4-7\"\n  ]\n}")

	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/blocklist-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 = "{\n  \"models\": [\n    \"openai/gpt-5.5\",\n    \"anthropic/claude-opus-4-7\"\n  ]\n}"

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/blocklist-rules/rule_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"models\": [\n    \"openai/gpt-5.5\",\n    \"anthropic/claude-opus-4-7\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api-gateway.merge.dev/v1/blocklist-rules/rule_id', [
  'body' => '{
  "models": [
    "openai/gpt-5.5",
    "anthropic/claude-opus-4-7"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/blocklist-rules/rule_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"models\": [\n    \"openai/gpt-5.5\",\n    \"anthropic/claude-opus-4-7\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["models": ["openai/gpt-5.5", "anthropic/claude-opus-4-7"]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/blocklist-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()
```