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

> Change the settings new repositories start with

Updates the defaults named in `updateMask`. Repositories added to the workspace afterwards start with the new values. Repositories already in the workspace keep their settings; change those one repository at a time with [Update repository settings](https://docs.macroscope.com/api-reference/endpoint/update-repo-settings.md). If any default is invalid or you lack permission to change it, the whole update fails.

A repository copies every default once, when it is added. Later changes to the defaults do not reach it. If the Policy Repo default is no longer in the workspace when a repository is added, that repository starts with no Policy Repo.

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

Read the [current defaults](https://docs.macroscope.com/api-reference/endpoint/get-workspace-repo-defaults.md) before updating. If someone saves the defaults in the meantime, including in the Macroscope app, the update returns `409 Conflict` and changes nothing. Read them again, check that your change still applies, and retry with the new `version`. A successful update also advances the version, so resending one whose response you lost returns `409`; read the defaults to see whether it applied.

## Permissions

Use an Admin key for the workspace. Every Admin key can change defaults, including keys created before this endpoint existed. Read and Write keys can read defaults but cannot change them.

With [OAuth sign-in](https://docs.macroscope.com/api-reference/mcp.md#permissions), the client needs Admin access and you must be a Macroscope workspace admin. A client with Read or Write access receives an `insufficient_scope` challenge for `macroscope:admin`. Connections already approved at Admin need no new approval.

An Admin key can change repository defaults and repository settings, and use the workspace administration operations listed under [Endpoints](https://docs.macroscope.com/api#endpoints), including [granting](https://docs.macroscope.com/api-reference/endpoint/add-delegated-admin.md) or [removing](https://docs.macroscope.com/api-reference/endpoint/remove-delegated-admin.md) workspace Admin. The key itself is not a workspace admin: it cannot manage billing or API keys.

Check `editableFields` in the [Get repository defaults](https://docs.macroscope.com/api-reference/endpoint/get-workspace-repo-defaults.md) response to see which defaults you can change. With OAuth sign-in, the list is empty unless the client has Admin access and you are a workspace admin. Defaults for features the workspace does not have, such as Approvability, cannot be changed. To set a Policy Repo, you also need read access to the source repository in the same workspace.

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

## Body

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

**version** `string` *required*

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

**updateMask** `string` *required*

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

**settings** `WorkspaceRepoDefaultValues`

New values for the fields in `updateMask`. To clear `correctnessMaxRunsPerPr`, `correctnessMaxFileSizeBytes`, `policyRepoId`, `releaseRefPatterns`, `skipPrAuthorLogins`, `skipPrLabels`, `skipPrTargetBranches`, or `alwaysReviewPrLabels`, 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. A filter list replaces the whole list. Clearing it, or sending `{}`, leaves it empty so that no pull requests match it. A detection mode that is not among the workspace's choices in the Macroscope app is refused with `400`. See [WorkspaceRepoDefaultValues](https://docs.macroscope.com/api-reference/endpoint/get-workspace-repo-defaults.md#workspacerepodefaultvalues) for field values.

## Response

**defaults** `WorkspaceRepoDefaults`

The workspace's repository defaults and `version` after the update, in the same form as [Get repository defaults](https://docs.macroscope.com/api-reference/endpoint/get-workspace-repo-defaults.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 default that cannot be cleared, a value out of range, or a detection mode the workspace does not offer</td>
    </tr>

    <tr>
      <td>`403`</td>
      <td>Your credential cannot change defaults, you cannot read the Policy Repo you named, or the feature a named default belongs to is unavailable</td>
    </tr>

    <tr>
      <td>`404`</td>
      <td>The workspace has no repository defaults</td>
    </tr>

    <tr>
      <td>`409`</td>
      <td>The defaults 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 make new repositories skip pull requests labeled `no-review`. The response shows selected defaults.

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

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

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

url = "https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/repository-defaults"
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()["defaults"]["version"],
    "updateMask": "skipPrLabels",
    "settings": {"skipPrLabels": {"labels": ["no-review"]}},
})
updated.raise_for_status()
print(updated.json())
```

```javascript JavaScript theme={null}
const url = "https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/repository-defaults";
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 { defaults } = await current.json();

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

```json 200 theme={null}
{
  "defaults": {
    "version": "8",
    "configured": { "skipPrLabels": { "labels": ["no-review"] } },
    "effective": { "skipPrLabels": { "labels": ["no-review"] } },
    "editableFields": "correctnessReview,checkRunAgents,githubActionsAgentRunsEnabled,commitSummarizationEnabled,prSummaryEnabled,commentSeverityThreshold,detectionMode,correctnessMaxRunsPerPr,correctnessMaxFileSizeBytes,draftPrReviewEnabled,autoMergeFixPrsEnabled,requestReview,skipDependabot,policyRepoId,releaseRefPatterns,crossRepoPrReviewEnabled,skipPrAuthorLogins,skipPrLabels,skipPrTargetBranches,alwaysReviewPrLabels"
  }
}
```


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