> ## Documentation Index
> Fetch the complete documentation index at: https://docs.macroscope.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update repository settings

> Change a repository's settings

Updates the settings named in `updateMask` for one repository. For example, you can turn on pull request summaries or change the Approvability mode. If any setting is invalid or you lack permission to change it, the whole update fails.

> [!WARNING]
>
> Changes take effect immediately for the repository and are recorded in the workspace audit log.

Read the repository's [current settings](https://docs.macroscope.com/api-reference/endpoint/get-repo-settings.md) before updating. If someone saves the settings in the meantime, the update returns `409 Conflict`. Read them again, check that your change still applies, and retry with the new `version`.

## Permissions

Check `editableFields` in the [Get repository settings](https://docs.macroscope.com/api-reference/endpoint/get-repo-settings.md) response to see which settings you can change. Each setting requires both the credential level and repository access shown below.

| Setting | Minimum level | Access required |
| - | - | - |
| `correctnessReview`, `checkRunAgents`, `githubActionsAgentRunsEnabled`, `commitSummarizationEnabled`, `prSummaryEnabled`, `commentSeverityThreshold`, `detectionMode`, `draftPrReviewEnabled`, `autoMergeFixPrsEnabled`, `requestReview`, `skipDependabot`, `approvabilityAutoRerunEnabled`, `releaseRefPatterns` | Write | Write on the repository |
| `approvability`, `approvabilityMode`, `approvabilityMinBlockingSeverity`, `approvabilityConclusion`, `approvabilityPreviewEnabled`, `correctnessMaxRunsPerPr`, `correctnessMaxFileSizeBytes`, `policyRepoId` | Admin | Admin on the repository |

Macroscope checks [repository permissions](https://docs.macroscope.com/settings.md#repository-permissions) for each setting.

* With [OAuth sign-in](https://docs.macroscope.com/api-reference/mcp.md#permissions), you need both the approved level and permission to change the setting. A Macroscope workspace admin has Admin on the workspace's repositories. GitHub repository admin access alone gives Write.
* A Write or Admin API key has the corresponding access on each repository Macroscope tracks in its workspace.

To set a Policy Repo, you also need read access to the source repository in the same workspace. Features such as Approvability must be enabled for the workspace. To change defaults for new repositories, open [**Settings → Repos**](https://app.macroscope.com/settings#Repos) and select **Defaults**.

## Authorization

**Authorization** `string` *required*

`Bearer <key>`. See [Authentication](https://docs.macroscope.com/api#authentication).

**X-Macroscope-Initiation** `string`

How your client identifies the source of the request in the workspace audit log. Use `human` or `agent`. Macroscope records the client's value without verifying it. Other values are treated as unspecified.

## Path parameters

**workspaceType** `string` *required*

`GITHUB_ORGANIZATION` or `GITHUB_USER`.

**workspaceId** `string` *required*

Numeric GitHub ID of the organization or user.

**repositoryId** `string` *required*

Repository ID, as returned in `repositoryId` by other endpoints. 1 to 128 characters.

## Body

Send a JSON body of up to 256 KiB. A larger body returns `413`.

**version** `string` *required*

Version returned by [Get repository settings](https://docs.macroscope.com/api-reference/endpoint/get-repo-settings.md), as a decimal string.

**updateMask** `string` *required*

Comma-separated names of the settings to change, as they appear in `settings`, for example `"prSummaryEnabled,approvabilityMode"`. Between 1 and 21 names, each at most once.

**settings** `RepoSettingValues`

New values for the fields in `updateMask`. To clear `correctnessMaxRunsPerPr`, `correctnessMaxFileSizeBytes`, `policyRepoId`, or `releaseRefPatterns`, name it in the mask and omit its value. All other named fields need a value. The two Correctness limits must be at least 1 when set. See [RepoSettingValues](https://docs.macroscope.com/api-reference/endpoint/get-repo-settings.md#reposettingvalues) for field values.

## Response

**settings** `RepoSettings`

The repository's settings and `version` after the update, in the same form as [Get repository settings](https://docs.macroscope.com/api-reference/endpoint/get-repo-settings.md).

## Audit log

Each successful change is recorded in the workspace audit log with the API key or the signed-in person and connected app, the client's `User-Agent`, and any reported `X-Macroscope-Initiation`. Denied and stale updates can also appear there. Requests rejected before admission, such as malformed requests, invalid credentials, workspace mismatches, and rate-limited requests, may have no audit entry.

## Errors

<table>
  <colgroup>
    <col width="100" />

    <col width="698" />
  </colgroup>

  <thead>
    <tr>
      <th>HTTP</th>
      <th>Meaning</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`400`</td>
      <td>Invalid body: an unknown or repeated name in `updateMask`, a value without its name, a cleared setting that cannot be cleared, or a value out of range</td>
    </tr>

    <tr>
      <td>`403`</td>
      <td>Your credential's level or your access does not allow one of the named settings, or the feature it belongs to is unavailable</td>
    </tr>

    <tr>
      <td>`404`</td>
      <td>The repository is unknown or you cannot read it</td>
    </tr>

    <tr>
      <td>`409`</td>
      <td>The settings changed after `version` was read. Nothing was changed</td>
    </tr>

    <tr>
      <td>`413`</td>
      <td>Body larger than 256 KiB</td>
    </tr>
  </tbody>
</table>

These examples turn on pull request summaries. The response shows selected settings returned to a Write key.

```bash cURL theme={null}
url="https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/repositories/987654321/settings"
auth="Authorization: Bearer $MACROSCOPE_API_KEY"

version=$(curl -fsS "$url" -H "$auth" | jq -er '.settings.version') &&
curl -sS -X PATCH "$url" \
  -H "$auth" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg version "$version" '{version: $version, updateMask: "prSummaryEnabled", settings: {prSummaryEnabled: true}}')"
```

```python Python theme={null}
import os, requests

url = "https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/repositories/987654321/settings"
headers = {"Authorization": f"Bearer {os.environ['MACROSCOPE_API_KEY']}"}
current = requests.get(url, headers=headers)
current.raise_for_status()

updated = requests.patch(url, headers=headers, json={
    "version": current.json()["settings"]["version"],
    "updateMask": "prSummaryEnabled",
    "settings": {"prSummaryEnabled": True},
})
updated.raise_for_status()
print(updated.json())
```

```javascript JavaScript theme={null}
const url = "https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/repositories/987654321/settings";
const headers = { Authorization: `Bearer ${process.env.MACROSCOPE_API_KEY}` };
const current = await fetch(url, { headers });
if (!current.ok) throw new Error(`GET failed (${current.status})`);
const { settings } = await current.json();

const updated = await fetch(url, {
  method: "PATCH",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({
    version: settings.version,
    updateMask: "prSummaryEnabled",
    settings: { prSummaryEnabled: true }
  })
});
if (!updated.ok) throw new Error(`PATCH failed (${updated.status})`);
console.log(await updated.json());
```

```json 200 theme={null}
{
  "settings": {
    "repositoryId": "987654321",
    "version": "43",
    "configured": { "prSummaryEnabled": true },
    "effective": { "prSummaryEnabled": true },
    "editableFields": "correctnessReview,checkRunAgents,githubActionsAgentRunsEnabled,commitSummarizationEnabled,prSummaryEnabled,commentSeverityThreshold,detectionMode,draftPrReviewEnabled,autoMergeFixPrsEnabled,requestReview,skipDependabot,approvabilityAutoRerunEnabled,releaseRefPatterns"
  }
}
```

```json 409 theme={null}
{ "code": 10, "message": "the settings changed after the version was read" }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.