> This page is for Workforce.

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

# Update Connection Access

PATCH https://ah-api.merge.dev/api/v1/connections/{connection_id}/
Content-Type: application/json

Replaces the full set of registered users excluded from a SHARED or ORGANIZATION connection. Each entry is a registered-user ID. Returns 400 for INDIVIDUAL connections or unknown registered-user IDs.

Reference: https://docs.merge.dev/merge-workforce/agent-handler/connections/update

## Authentication

- `Authorization` header (bearer token, required) — Token-based authentication with required prefix "Bearer"

## Request

### Path parameters

- `connection_id` (string, required)

### Body (application/json)

This endpoint expects a PatchedConnectionUpdate.

- `excluded_registered_users` (list of string, optional) — Full replacement list of registered user IDs to block from this SHARED or ORGANIZATION connection. Send [] to clear all exclusions.

## Response

### 200

- `id` (string, required)
- `connector` (ConnectionConnector, required)
- `organization_id` (string, required)
- `auth_option_name` (string, required, nullable)
- `auth_type` (string, required)
- `auth_scope` (string, required) — The connection's scope: INDIVIDUAL, SHARED, or ORGANIZATION.
- `status` (string, required) — Connection status: ACTIVE (a token refresh succeeded, or the default for a freshly linked connection) or ERROR (a token refresh failed; the connection needs re-linking).
- `retired_at` (datetime, required, nullable) — When set, the connection is retired (out of service) and surfaced as an issue. Null for live connections.
- `owner` (ConnectionOwner, required)
- `excluded_registered_users` (list of string, required) — Registered-user IDs blocked from this SHARED or ORGANIZATION connection. Always empty for INDIVIDUAL connections.
- `created_at` (datetime, required)
- `modified_at` (datetime, required)

## Types

### ConnectionConnector

- `slug` (string, required)
- `name` (string, required)
- `logo_url` (string, required, nullable)

### ConnectionOwner

- `type` (string, required)
- `id` (string, required)
- `name` (string, optional)
- `group` (ConnectionOwnerGroup, optional)

### ConnectionOwnerGroup

- `key` (string, required)
- `value` (string, required)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "string",
  "connector": {
    "slug": "string",
    "name": "string",
    "logo_url": "string"
  },
  "organization_id": "string",
  "auth_option_name": "string",
  "auth_type": "string",
  "auth_scope": "string",
  "status": "string",
  "retired_at": "2024-01-15T09:30:00Z",
  "owner": {
    "type": "string",
    "id": "string",
    "name": "string",
    "group": {
      "key": "string",
      "value": "string"
    }
  },
  "excluded_registered_users": [
    "string"
  ],
  "created_at": "2024-01-15T09:30:00Z",
  "modified_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://ah-api.merge.dev/api/v1/connections/connection_id/"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://ah-api.merge.dev/api/v1/connections/connection_id/';
const options = {
  method: 'PATCH',
  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://ah-api.merge.dev/api/v1/connections/connection_id/"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", 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://ah-api.merge.dev/api/v1/connections/connection_id/")

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

request = Net::HTTP::Patch.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.patch("https://ah-api.merge.dev/api/v1/connections/connection_id/")
  .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('PATCH', 'https://ah-api.merge.dev/api/v1/connections/connection_id/', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://ah-api.merge.dev/api/v1/connections/connection_id/");
var request = new RestRequest(Method.PATCH);
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://ah-api.merge.dev/api/v1/connections/connection_id/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```