> For the complete documentation index, see [llms.txt](https://docs.ox.security/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ox.security/api-documentation/api-reference/api--connectors/mutations/monitor-connector-app-branches.md).

# monitorConnectorAppBranches

Sets the branches to scan for a single repository. Each scanned branch is reported as a separate application.

Requires multi-branch scanning to be enabled for the organization. If it is not enabled, the response returns success false with code MULTI\_BRANCH\_NOT\_ENABLED; contact OX support to enable it.

{% hint style="warning" %}

## Complete replacement operation

* Include ALL branches you want scanned for the repository, both existing and new
* Each request must contain at least one branch; an empty list is not supported
* Branches not included in this update are no longer scanned, and their issues are removed
* Include the default branch if it should be scanned, unless the organization is set to always scan it
* The number of branches is limited per repository and per organization; when a limit is exceeded, the response returns success false with the limit in code and reasonFailed
  {% endhint %}

### Examples

{% tabs %}
{% tab title="GraphQL" %}

```graphql
mutation MonitorConnectorAppBranches($monitorConnectorAppBranchesInput: AddAppBranchToMonitorInput!) {
  monitorConnectorAppBranches(monitorConnectorAppBranchesInput: $monitorConnectorAppBranchesInput) {
    success
    code
    reasonFailed
    monitoredBranchesTotal
    maxBranchesToMonitor
  }
}
```

#### Variables

This is an example input showing all available input fields. Only fields marked as required in the schema are mandatory.

```json
{
  "monitorConnectorAppBranchesInput": {
    "connectorID": "2",
    "branches": [
      {
        "name": "release/v3.2",
        "isMonitored": true,
        "appName": "some-repo",
        "appId": "30966426",
        "commitSha": "example"
      }
    ],
    "credentialsId": "example"
  }
}
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl -X POST \
https://api.cloud.ox.security/api/apollo-gateway \
-H 'Content-Type: application/json' \
-H 'Authorization: YOUR_API_TOKEN' \
-d '{
 "query": "mutation MonitorConnectorAppBranches($monitorConnectorAppBranchesInput: AddAppBranchToMonitorInput!) { monitorConnectorAppBranches(monitorConnectorAppBranchesInput: $monitorConnectorAppBranchesInput) { success code reasonFailed monitoredBranchesTotal maxBranchesToMonitor } }",
 "variables": {
    "monitorConnectorAppBranchesInput": {
      "connectorID": "2",
      "branches": [
        {
          "name": "release/v3.2",
          "isMonitored": true,
          "appName": "some-repo",
          "appId": "30966426",
          "commitSha": "example"
        }
      ],
      "credentialsId": "example"
    }
  }
}'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const query = 'mutation MonitorConnectorAppBranches($monitorConnectorAppBranchesInput: AddAppBranchToMonitorInput!) { monitorConnectorAppBranches(monitorConnectorAppBranchesInput: $monitorConnectorAppBranchesInput) { success code reasonFailed monitoredBranchesTotal maxBranchesToMonitor } }';

fetch("https://api.cloud.ox.security/api/apollo-gateway", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "YOUR_API_TOKEN"
  },
  body: JSON.stringify({
    query: query,
    // This is an example input showing all available input fields. Only fields marked as required in the schema are mandatory.
    variables: {
      monitorConnectorAppBranchesInput: {
        connectorID: "2",
        branches: [
          {
            name: "release/v3.2",
            isMonitored: true,
            appName: "some-repo",
            appId: "30966426",
            commitSha: "example"
          }
        ],
        credentialsId: "example"
      }
    }
  })
})
.then(response => response.json())
.then(result => console.log(JSON.stringify(result, null, 2)))
.catch(error => console.error('Error:', error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

query = 'mutation MonitorConnectorAppBranches($monitorConnectorAppBranchesInput: AddAppBranchToMonitorInput!) { monitorConnectorAppBranches(monitorConnectorAppBranchesInput: $monitorConnectorAppBranchesInput) { success code reasonFailed monitoredBranchesTotal maxBranchesToMonitor } }'

response = requests.post(
  "https://api.cloud.ox.security/api/apollo-gateway",
  headers={
    "Content-Type": "application/json",
    "Authorization": "YOUR_API_TOKEN"
  },
  json={
    "query": query,
    # This is an example input showing all available input fields. Only fields marked as required in the schema are mandatory.
    "variables": {
      "monitorConnectorAppBranchesInput": {
        "connectorID": "2",
        "branches": [
          {
            "name": "release/v3.2",
            "isMonitored": true,
            "appName": "some-repo",
            "appId": "30966426",
            "commitSha": "example"
          }
        ],
        "credentialsId": "example"
      }
    }
  }
)

if response.status_code == 200:
    result = response.json()
    print(result)
else:
    print(f"Error: {response.status_code}")
    print(response.text)
```

{% endtab %}
{% endtabs %}

### Arguments

You can use the following argument(s) to customize your `monitorConnectorAppBranches` mutation.

| Argument                                                                                                                                                                                                                                                 | Description                                                     | Supported fields                                                                                                                                                                                                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| monitorConnectorAppBranchesInput [`AddAppBranchToMonitorInput!`](https://docs.ox.security/api-documentation/api-reference/api--connectors/types/inputs/add-app-branch-to-monitor-input.md) <mark style="color:red;background-color:red;">required</mark> | Input specifying the connector, repository and branches to scan | <p>connectorID <code>String!</code><br>branches <a href="https://docs.ox.security/api-documentation/api-reference/api--connectors/types/inputs/branch-input.md"><code>\[BranchInput]</code></a><br>credentialsId <code>String</code></p> |

### Fields

Return type: [`MonitorConnectorAppBranchesResponse`](https://docs.ox.security/api-documentation/api-reference/api--connectors/types/objects/monitor-connector-app-branches-response.md)

You can use the following field(s) to specify what information your `monitorConnectorAppBranches` mutation will return. Please note that some fields may have their own subfields.

| Field                        | Description                                                                                                              | Supported fields |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ---------------- |
| success `Boolean`            | boolean indication if operation succeeded                                                                                |                  |
| code `String`                | Failure code: MULTI\_BRANCH\_NOT\_ENABLED, MAX\_BRANCHES\_PER\_APP\_LIMIT\_REACHED or MAX\_BRANCHES\_ORG\_LIMIT\_REACHED |                  |
| reasonFailed `String`        | human-readable failure reason                                                                                            |                  |
| monitoredBranchesTotal `Int` | projected monitored branches total in the organization                                                                   |                  |
| maxBranchesToMonitor `Int`   | max number of monitored branches allowed                                                                                 |                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ox.security/api-documentation/api-reference/api--connectors/mutations/monitor-connector-app-branches.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
