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

# Replace a project's controls

PUT https://api-gateway.merge.dev/v1/projects/{project_id}/controls
Content-Type: application/json

Replaces the project's override with exactly the fields you send; omit a field to inherit it. A management key may only TIGHTEN the organization's controls (narrow an allowlist, add to a denylist, turn ZDR on); anything that loosens them is rejected with 403 `scoped_controls_loosening_forbidden`. Loosening is available in the dashboard, which requires the organization-settings permission. Requires the manage_projects scope.

Reference: https://docs.merge.dev/merge-gateway/management-api/projects/update-project-controls

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

### Body (application/json)

This endpoint expects a ScopedControlsUpdate.

- `zero_data_retention` (boolean, optional, nullable) — Tri-state: omit to inherit the organization's setting, send false to turn organization-wide ZDR OFF for this scope, true to turn it on.
- `ignored_vendors` (list of string, optional) — Vendors this scope may never route to
- `allowed_vendors` (list of string, optional) — When non-empty, the only vendors this scope may route to
- `vendor_routing_preference` (list of string, optional) — Soft ordering hint among the vendors that remain; never excludes a vendor
- `ignored_regions` (list of string, optional) — Region tokens (ISO country code or coarse region such as EU, NA) this scope may never route to
- `allowed_regions` (list of string, optional) — When non-empty, the only region tokens this scope may route to. Vendors with no known region are excluded.

## Response

### 200

The stored override and the resulting effective controls.

- `scope` (string, optional)
- `scope_id` (string, optional)
- `override` (ProjectControlsOverride, optional) — Exactly what this scope stores, unit-wrapped: `zero_data_retention`, `vendors` \{ignored\_vendors, allowed\_vendors, vendor\_routing\_preference}, `regions` \{ignored\_regions, allowed\_regions}. Empty means it inherits everything.
- `effective` (ProjectControlsEffective, optional) — The controls actually in force for the scope: the organization's with this scope's units applied. For a customer, a project is not folded in; at request time a customer override still wins over a project's.
- `sources` (map from string to string, optional) — Per unit (`zero_data_retention`, `vendors`, `regions`), which scope supplied the effective value: `org` or this scope

## Errors

### 403 Forbidden Error

The override would loosen the organization's controls, or the key lacks the manage_projects scope.

- `any`

### 422 Unprocessable Entity Error

Unknown field, or a vendor slug / region token that does not exist.

- `any`

## Types

### ProjectControlsOverride

Exactly what this scope stores, unit-wrapped: `zero_data_retention`, `vendors` \{ignored\_vendors, allowed\_vendors, vendor\_routing\_preference}, `regions` \{ignored\_regions, allowed\_regions}. Empty means it inherits everything.

### ProjectControlsEffective

The controls actually in force for the scope: the organization's with this scope's units applied. For a customer, a project is not folded in; at request time a customer override still wins over a project's.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "scope": "project",
  "scope_id": "string",
  "override": {
    "vendors": {
      "allowed_vendors": [
        "openai",
        "bedrock"
      ],
      "ignored_vendors": [],
      "vendor_routing_preference": []
    }
  },
  "effective": {
    "allowed_regions": [
      "NA"
    ],
    "allowed_vendors": [
      "openai",
      "bedrock"
    ],
    "ignored_regions": [],
    "ignored_vendors": [],
    "vendor_routing_preference": [],
    "zero_data_retention": true
  },
  "sources": {
    "regions": "org",
    "vendors": "project",
    "zero_data_retention": "org"
  }
}
```

**SDK Code**

```python
import requests

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

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/projects/project_id/controls';
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/projects/project_id/controls"

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

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/projects/project_id/controls")
  .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/projects/project_id/controls', [
  '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/projects/project_id/controls");
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/projects/project_id/controls")! 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()
```