> 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 customer PI settings

PUT https://api-gateway.merge.dev/v1/customers/{customer_id}/pi-settings
Content-Type: application/json

Replaces the customer's prompt injection override as a whole. The override is sparse: set only the fields to pin, everything else inherits the organization policy. An empty body restores full inheritance. Changes propagate to request enforcement within about 60 seconds. Requires the customer_guardrails feature; without it the request is rejected with a 403.

Reference: https://docs.merge.dev/merge-gateway/embedded-routing/guardrails/update-customer-pi-settings

## Authentication

- `Authorization` header (bearer token, required) — Your production key sent as a bearer token.

## Request

### Path parameters

- `customer_id` (string, required)

### Body (application/json)

This endpoint expects a PiProtectionOverride.

- `pi_mode` (enum, optional, nullable) — Direct-injection enforcement mode: off, alert, or block
  - Allowed values: `off`, `alert`, `block`
- `pi_block_threshold` (double, optional, nullable) — Direct-injection block threshold. Must be at least the organization's pi_pass_threshold, which is not overridable per customer
- `pi_indirect_mode` (enum, optional, nullable) — Indirect-injection enforcement mode, a separate axis from pi_mode
  - Allowed values: `off`, `alert`, `block`
- `pi_tier2a_block_threshold` (double, optional, nullable) — Indirect-injection heuristic-confidence threshold
- `pi_tier2b_block_threshold` (double, optional, nullable) — Indirect-injection embedding-similarity threshold
- `pi_output_action` (enum, optional, nullable) — What to do when the response-side check fires
  - Allowed values: `observe`, `redact`, `route`, `block`, `escalate`
- `pi_fail_closed` (boolean, optional, nullable) — Whether to reject requests when the detection service is unavailable. Defaults to failing open
- `pi_allowlist_patterns` (list of string, optional, nullable) — Regexes whose matching segments skip scanning. Unioned with the organization's list, never replacing it. A pattern broad enough to match ordinary prose disables enforcement rather than narrowing it

## Response

### 200

Successful Response

- `override` (PiProtectionOverride, optional) — What this customer sets. Fields it does not set are null here
- `effective` (PiProtectionSettings, optional) — The policy a request scoped to this customer runs under
- `inherited_fields` (list of string, optional) — Fields taken from the organization policy because the customer does not set them

## Types

### PiProtectionOverride

A customer's sparse prompt injection override. Every field is optional: omitted means inherit the organization value, null clears the field back to inheritance. Unknown fields are rejected with a 422. Whether an override may relax the organization policy depends on how the request names the customer: a customer API key applies it in full, while a customer named by the request's customer field may only tighten.

- `pi_mode` (enum, optional, nullable) — Direct-injection enforcement mode: off, alert, or block
  - Allowed values: `off`, `alert`, `block`
- `pi_block_threshold` (double, optional, nullable) — Direct-injection block threshold. Must be at least the organization's pi_pass_threshold, which is not overridable per customer
- `pi_indirect_mode` (enum, optional, nullable) — Indirect-injection enforcement mode, a separate axis from pi_mode
  - Allowed values: `off`, `alert`, `block`
- `pi_tier2a_block_threshold` (double, optional, nullable) — Indirect-injection heuristic-confidence threshold
- `pi_tier2b_block_threshold` (double, optional, nullable) — Indirect-injection embedding-similarity threshold
- `pi_output_action` (enum, optional, nullable) — What to do when the response-side check fires
  - Allowed values: `observe`, `redact`, `route`, `block`, `escalate`
- `pi_fail_closed` (boolean, optional, nullable) — Whether to reject requests when the detection service is unavailable. Defaults to failing open
- `pi_allowlist_patterns` (list of string, optional, nullable) — Regexes whose matching segments skip scanning. Unioned with the organization's list, never replacing it. A pattern broad enough to match ordinary prose disables enforcement rather than narrowing it

### PiProtectionSettings

A fully resolved prompt injection policy, with no field left to inherit.

- `pi_mode` (string, optional)
- `pi_block_threshold` (double, optional)
- `pi_pass_threshold` (double, optional)
- `pi_input_action` (string, optional)
- `pi_output_action` (string, optional)
- `pi_allowlist_patterns` (list of string, optional)
- `pi_safer_vendor_route` (string, optional, nullable)
- `pi_fail_closed` (boolean, optional)
- `pi_log_full_text_on_block` (boolean, optional)
- `pi_indirect_mode` (string, optional)
- `pi_tier2a_block_threshold` (double, optional)
- `pi_tier2b_block_threshold` (double, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "override": {
    "pi_mode": "off",
    "pi_block_threshold": 0.5,
    "pi_indirect_mode": "off",
    "pi_tier2a_block_threshold": 0.5,
    "pi_tier2b_block_threshold": 0.5,
    "pi_output_action": "observe",
    "pi_fail_closed": true,
    "pi_allowlist_patterns": [
      "string"
    ]
  },
  "effective": {
    "pi_mode": "string",
    "pi_block_threshold": 1.1,
    "pi_pass_threshold": 1.1,
    "pi_input_action": "string",
    "pi_output_action": "string",
    "pi_allowlist_patterns": [
      "string"
    ],
    "pi_safer_vendor_route": "string",
    "pi_fail_closed": true,
    "pi_log_full_text_on_block": true,
    "pi_indirect_mode": "string",
    "pi_tier2a_block_threshold": 1.1,
    "pi_tier2b_block_threshold": 1.1
  },
  "inherited_fields": [
    "string"
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/customers/customer_id/pi-settings"

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

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/customers/customer_id/pi-settings';
const options = {
  method: 'PUT',
  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/customers/customer_id/pi-settings"

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

	req, _ := http.NewRequest("PUT", 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/customers/customer_id/pi-settings")

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

request = Net::HTTP::Put.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.put("https://api-gateway.merge.dev/v1/customers/customer_id/pi-settings")
  .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('PUT', 'https://api-gateway.merge.dev/v1/customers/customer_id/pi-settings', [
  '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/customers/customer_id/pi-settings");
var request = new RestRequest(Method.PUT);
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/customers/customer_id/pi-settings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```