> 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 a project's prompt injection settings

GET https://api-gateway.merge.dev/v1/projects/{project_id}/pi-settings

Returns the project's override, the effective policy after merging with the organization's, and which fields are inherited. A project pinned to an API key uses this policy as written. A project named per request (project_id body field or X-Project-Id header) may only tighten the organization policy; anything that loosens it is ignored at request time.

Reference: https://docs.merge.dev/merge-gateway/management-api/projects/get-project-pi-settings

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

- `project_id` (string, required)

## Response

### 200

The project's settings, with the effective policy resolved.

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

## Errors

### 403 Forbidden Error

The management key lacks the `manage_projects` scope.

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

### 404 Not Found Error

Project not found, or it belongs to another organization.

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

## Types

### PiProtectionOverride

A project'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.

- `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 project
- `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

**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/projects/project_id/pi-settings"

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

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/projects/project_id/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/projects/project_id/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/projects/project_id/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/projects/project_id/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/projects/project_id/pi-settings', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

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