> 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.

# Get Organization PI Settings

GET https://api-gateway.merge.dev/v1/organization/pi-settings

Return the organization's prompt injection policy, which projects
inherit unless they override it. There's one per organization.

Reference: https://docs.merge.dev/merge-gateway/management-api/security-rules/get-organization-pi-settings

## 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.

## Response

### 200

The organization's prompt injection settings

- `pi_allowlist_patterns` (list of string, required) — Regular expressions whose matching prompt segments skip screening. A project's patterns add to the organization's, never replacing them. A pattern that matches ordinary text, such as `.*`, is ignored.
- `pi_block_threshold` (double, required, default: 0.57) — Direct injection: a prompt segment is blocked when its score, from 0 to 1, reaches this value. At least the organization's `pi_pass_threshold`.
- `pi_fail_closed` (boolean, required, default: false) — Reject requests, with `code: "sidecar_error"`, when screening is unavailable. false lets them through unscreened.
- `pi_indirect_mode` (enum, required, default: off) — Indirect injection, in tool results and documents: `off`, `alert` or `block`. A separate axis from `pi_mode`.
  - Allowed values: `off`, `alert`, `block`
- `pi_input_action` (enum, required, default: block) — Reserved: requests are screened as `pi_mode` says.
  - Allowed values: `observe`, `redact`, `route`, `block`, `escalate`
- `pi_log_full_text_on_block` (boolean, required, default: false) — Log the full text of blocked prompts.
- `pi_mode` (enum, required, default: off) — Direct injection, in the prompt a user sends: `off`, `alert` (score and record, never block) or `block`.
  - Allowed values: `off`, `alert`, `block`
- `pi_output_action` (enum, required, default: redact) — What the response-side check does with a leaked credential, such as an API key: `redact` replaces it with a placeholder, `observe` only records it. Other values behave like `observe`.
  - Allowed values: `observe`, `redact`, `route`, `block`, `escalate`
- `pi_pass_threshold` (double, required, default: 0.3) — Reserved: no effect on screening yet. At most `pi_block_threshold`.
- `pi_safer_vendor_route` (string, required, nullable) — Reserved for a future `route` action.
- `pi_tier2a_block_threshold` (double, required, default: 0.6) — Indirect injection: the score, from 0 to 1, at which the heuristic signal fires.
- `pi_tier2b_block_threshold` (double, required, default: 0.45) — Indirect injection: the score, from 0 to 1, at which the similarity-to-known-attacks signal fires.

## 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`.

## Types

### ErrorResponseDetail

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.

## Examples

**Response**

```json
{
  "pi_allowlist_patterns": [
    "(?i)ignore the previous ticket"
  ],
  "pi_block_threshold": 0.57,
  "pi_fail_closed": false,
  "pi_indirect_mode": "alert",
  "pi_input_action": "block",
  "pi_log_full_text_on_block": false,
  "pi_mode": "block",
  "pi_output_action": "redact",
  "pi_pass_threshold": 0.3,
  "pi_safer_vendor_route": null,
  "pi_tier2a_block_threshold": 0.6,
  "pi_tier2b_block_threshold": 0.45
}
```

**SDK Code**

```python
import requests

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

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/organization/pi-settings';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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"
	"net/http"
	"io"
)

func main() {

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

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	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/organization/pi-settings")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://api-gateway.merge.dev/v1/organization/pi-settings")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-gateway.merge.dev/v1/organization/pi-settings', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/organization/pi-settings");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/organization/pi-settings")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```