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

GET https://api-gateway.merge.dev/v1/guardrails/{project_id}

Get one project's guardrails.

Needs `view_security_rules` or `manage_security_rules`, and
`view_org_settings` or `manage_org_settings`.

Reference: https://docs.merge.dev/merge-gateway/management-api/lookups/get-guardrail

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

- `project_id` (string, required) — The project's `id`.

## Response

### 200

The project's guardrails

- `controls` (ProjectControlsV1Response, required) — The project's vendor, region and zero-data-retention controls.
- `dlp_settings` (ProjectDLPSettingsV1Response, required) — The project's DLP settings.
- `pi_settings` (ProjectPISettingsV1Response, required) — The project's prompt injection settings.
- `project_id` (string, required) — The project's id.
- `project_name` (string, required) — The project's name.

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

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ProjectControlsV1Response

A project's vendor, region and zero-data-retention controls.

- `effective` (ProjectControlsEffectiveV1, required) — The controls in force.
- `override` (ProjectControlsOverrideV1, required) — What the project sets.
- `scope` (string, required) — Always `project` here.
- `scope_id` (string, required) — The project's id.
- `sources` (ProjectControlsSourcesV1, required) — Where each unit's effective value comes from.

### ProjectDLPSettingsV1Response

A project's DLP settings.

- `entities` (list of ProjectDLPEntityStateV1, required) — Every entity type in the organization's rules, with the project's override applied.
- `override` (map from string to DLPEntityOverrideV1, required) — What the project sets, keyed by entity type. Entity types it doesn't set are absent.

### ProjectPISettingsV1Response

A project's prompt injection settings.

- `effective` (PIProtectionSettingsV1, required) — The policy a request to this project runs under, when the project is pinned to an API key.
- `inherited_fields` (list of string, required) — Fields taken from the organization policy because the project doesn't set them.
- `override` (PIProtectionOverrideV1, required) — What the project sets. Fields it doesn't set are null.

### ErrorResponseDetail

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

### ValidationError

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

### ProjectControlsEffectiveV1

The controls actually in force for the project: the organization's, with the project's units applied.

- `allowed_regions` (list of string, required) — When non-empty, the only regions the project may route to. Vendors with no known region are excluded.
- `allowed_vendors` (list of string, required) — When non-empty, the only vendors the project may route to.
- `ignored_regions` (list of string, required) — Regions the project may never route to.
- `ignored_vendors` (list of string, required) — Vendors the project may never route to.
- `vendor_routing_preference` (list of string, required) — Vendors to try first among those that remain. Never excludes a vendor.
- `zero_data_retention` (boolean, required) — Whether only zero-data-retention vendors are used.

### ProjectControlsOverrideV1

Exactly what the project sets, one key per unit. A unit the project inherits is absent, never null; an empty object means it inherits everything.

- `regions` (RegionControlsV1, optional) — Present when the last PUT sent `ignored_regions` or `allowed_regions`. A field it didn't send is `[]`.
- `vendors` (VendorControlsV1, optional) — Present when the last PUT sent any of `ignored_vendors`, `allowed_vendors` or `vendor_routing_preference`. Fields it didn't send are `[]`.
- `zero_data_retention` (boolean, optional) — Present when the project sets zero data retention.

### ProjectControlsSourcesV1

Per unit, whether the effective value comes from the organization (`org`) or the project.

- `regions` (enum, required) — Where the region lists come from.
  - Allowed values: `org`, `project`
- `vendors` (enum, required) — Where the vendor lists come from.
  - Allowed values: `org`, `project`
- `zero_data_retention` (enum, required) — Where the zero-data-retention setting comes from.
  - Allowed values: `org`, `project`

### ProjectDLPEntityStateV1

How one entity type resolves for the project.

- `category` (string, required) — `custom` for the organization's own rules; `global` and `usa` are seeded.
- `entity_type` (string, required) — The entity type, like `US_SSN`.
- `is_seeded` (boolean, required) — Whether the entity type comes from the seeded catalog.
- `overridden` (boolean, required) — Whether the project overrides this entity type.
- `display_name` (string, optional, nullable) — The name the dashboard shows.
- `effective_action` (string, optional, nullable) — What the project does with it after its override. Null means not scanned.
- `org_action` (string, optional, nullable) — What the organization's rule does with it. Null means not scanned. `log` records a match and sends the prompt unchanged, `redact` replaces each match with a placeholder such as `<US_SSN>` before the prompt is sent, and `block` refuses the request with 422.

### DLPEntityOverrideV1

What the project does with one entity type. A field left null inherits the organization's rule.

- `action` (enum, optional, nullable) — `log` records a match and sends the prompt unchanged, `redact` replaces each match with a placeholder such as `<US_SSN>` before the prompt is sent, and `block` refuses the request with 422.
  - Allowed values: `log`, `redact`, `block`
- `enabled` (boolean, optional, nullable) — Whether the project scans for this entity.

### PIProtectionSettingsV1

A prompt injection policy.

- `pi_allowlist_patterns` (list of string, optional) — 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, optional, 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, optional, default: false) — Reject requests, with `code: "sidecar_error"`, when screening is unavailable. false lets them through unscreened.
- `pi_indirect_mode` (string, optional, default: off) — Indirect injection, in tool results and documents: `off`, `alert` or `block`. A separate axis from `pi_mode`.
- `pi_input_action` (string, optional, default: block) — Reserved: requests are screened as `pi_mode` says.
- `pi_log_full_text_on_block` (boolean, optional, default: false) — Log the full text of blocked prompts.
- `pi_mode` (string, optional, default: off) — Direct injection, in the prompt a user sends: `off`, `alert` (score and record, never block) or `block`.
- `pi_output_action` (string, optional, 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`.
- `pi_pass_threshold` (double, optional, default: 0.3) — Reserved: no effect on screening yet. At most `pi_block_threshold`.
- `pi_safer_vendor_route` (string, optional, nullable) — Reserved for a future `route` action.
- `pi_tier2a_block_threshold` (double, optional, default: 0.6) — Indirect injection: the score, from 0 to 1, at which the heuristic signal fires.
- `pi_tier2b_block_threshold` (double, optional, default: 0.45) — Indirect injection: the score, from 0 to 1, at which the similarity-to-known-attacks signal fires.

### PIProtectionOverrideV1

The prompt injection fields a project sets. Fields it doesn't set inherit the organization's value, and come back null.

- `pi_allowlist_patterns` (list of string, optional, nullable) — 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, optional, nullable) — 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, optional, nullable) — Reject requests, with `code: "sidecar_error"`, when screening is unavailable. false lets them through unscreened.
- `pi_indirect_mode` (enum, optional, nullable) — Indirect injection, in tool results and documents: `off`, `alert` or `block`. A separate axis from `pi_mode`.
  - Allowed values: `off`, `alert`, `block`
- `pi_mode` (enum, optional, nullable) — 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, optional, nullable) — 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_tier2a_block_threshold` (double, optional, nullable) — Indirect injection: the score, from 0 to 1, at which the heuristic signal fires.
- `pi_tier2b_block_threshold` (double, optional, nullable) — Indirect injection: the score, from 0 to 1, at which the similarity-to-known-attacks signal fires.

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

### ValidationErrorLocItems

### ValidationErrorCtx

### RegionControlsV1

The project's region controls.

- `allowed_regions` (list of string, required) — When non-empty, the only regions the project may route to. Vendors with no known region are excluded.
- `ignored_regions` (list of string, required) — Regions the project may never route to.

### VendorControlsV1

The project's vendor controls.

- `allowed_vendors` (list of string, required) — When non-empty, the only vendors the project may route to.
- `ignored_vendors` (list of string, required) — Vendors the project may never route to.
- `vendor_routing_preference` (list of string, required) — Vendors to try first among those that remain. Never excludes a vendor.

## Examples

**Response**

```json
{
  "controls": {
    "effective": {
      "allowed_regions": [
        "NA"
      ],
      "allowed_vendors": [
        "anthropic",
        "bedrock"
      ],
      "ignored_regions": [],
      "ignored_vendors": [],
      "vendor_routing_preference": [
        "bedrock"
      ],
      "zero_data_retention": true
    },
    "override": {
      "regions": {
        "allowed_regions": [
          "NA"
        ],
        "ignored_regions": []
      },
      "vendors": {
        "allowed_vendors": [
          "anthropic",
          "bedrock"
        ],
        "ignored_vendors": [],
        "vendor_routing_preference": [
          "bedrock"
        ]
      },
      "zero_data_retention": true
    },
    "scope": "project",
    "scope_id": "8b6f2d4a-1c3e-4b5a-9f7d-2e0c6a8b4d91",
    "sources": {
      "regions": "project",
      "vendors": "project",
      "zero_data_retention": "project"
    }
  },
  "dlp_settings": {
    "entities": [
      {
        "category": "global",
        "entity_type": "EMAIL_ADDRESS",
        "is_seeded": true,
        "overridden": true,
        "display_name": "EMAIL_ADDRESS",
        "effective_action": "block",
        "org_action": "redact"
      },
      {
        "category": "global",
        "entity_type": "DATE_TIME",
        "is_seeded": true,
        "overridden": true,
        "display_name": "DATE_TIME",
        "effective_action": null,
        "org_action": "log"
      },
      {
        "category": "global",
        "entity_type": "CREDIT_CARD",
        "is_seeded": true,
        "overridden": false,
        "display_name": "CREDIT_CARD",
        "effective_action": "redact",
        "org_action": "redact"
      }
    ],
    "override": {
      "DATE_TIME": {
        "enabled": false
      },
      "EMAIL_ADDRESS": {
        "action": "block",
        "enabled": true
      }
    }
  },
  "pi_settings": {
    "effective": {
      "pi_allowlist_patterns": [
        "(?i)ignore the previous ticket"
      ],
      "pi_block_threshold": 0.7,
      "pi_fail_closed": false,
      "pi_indirect_mode": "alert",
      "pi_input_action": "block",
      "pi_log_full_text_on_block": false,
      "pi_mode": "alert",
      "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
    },
    "inherited_fields": [
      "pi_indirect_mode",
      "pi_input_action",
      "pi_output_action",
      "pi_pass_threshold",
      "pi_tier2a_block_threshold",
      "pi_tier2b_block_threshold",
      "pi_fail_closed",
      "pi_log_full_text_on_block",
      "pi_allowlist_patterns",
      "pi_safer_vendor_route"
    ],
    "override": {
      "pi_block_threshold": 0.7,
      "pi_mode": "alert"
    }
  },
  "project_id": "8b6f2d4a-1c3e-4b5a-9f7d-2e0c6a8b4d91",
  "project_name": "support-bot"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/guardrails/project_id"

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

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/guardrails/project_id';
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/guardrails/project_id"

	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/guardrails/project_id")

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/guardrails/project_id")
  .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/guardrails/project_id', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

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