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

GET https://api-gateway.merge.dev/v1/dlp-rules/{rule_id}

Return a DLP rule, seeded or custom.

Reference: https://docs.merge.dev/merge-gateway/management-api/security-rules/get-dlp-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`.

## Response

### 200

The DLP rule

- `action` (enum, required) — `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`
- `category` (enum, required) — custom for rules the organization creates; global and usa are seeded.
  - Allowed values: `global`, `usa`, `custom`
- `created_at` (datetime, required) — For a seeded rule never changed, the time of the request.
- `description` (string, required) — What the rule detects.
- `detection_method` (string, required) — How the rule finds matches, like `Pattern match and checksum`.
- `display_name` (string, required) — The name the dashboard shows.
- `enabled` (boolean, required) — Whether the rule scans requests.
- `entity_type` (string, required) — The rule's name. Unique among the organization's custom rules.
- `id` (string, required) — Stable for seeded rules, even before they are first changed.
- `is_seeded` (boolean, required) — Seeded rules can't be created or deleted, only enabled and given an action.
- `keywords` (list of string, required, nullable) — Words the rule matches, if it has any.
- `pattern` (string, required, nullable) — The rule's regular expression, if it has one.
- `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

Validation Error

- `detail` (list of ValidationError, optional)

## Types

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

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

## Examples

**Response**

```json
{
  "action": "redact",
  "category": "custom",
  "created_at": "2026-06-02T17:04:00Z",
  "description": "Acme order numbers, like ACME-123456.",
  "detection_method": "Custom (regex + keywords)",
  "display_name": "ACME_ORDER_ID",
  "enabled": true,
  "entity_type": "ACME_ORDER_ID",
  "id": "4c8e2a6d-0b3f-4e7a-9d1c-5a7b9e3f2d60",
  "is_seeded": false,
  "keywords": [
    "order",
    "order number"
  ],
  "pattern": "\\bACME-\\d{6}\\b",
  "updated_at": "2026-09-14T09:30:00Z"
}
```

**SDK Code**

```python
import requests

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

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

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

print(response.json())
```

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

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

```csharp
using RestSharp;

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