---
title: Update GitHub CI Visibility status
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > CI Visibility GitHub Accounts
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Update GitHub CI Visibility status{% #update-github-ci-visibility-status %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                  |
| ----------------- | ------------------------------------------------------------- |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/ci/github/accounts |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/ci/github/accounts |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/ci/github/accounts      |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/ci/github/accounts      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/ci/github/accounts  |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/ci/github/accounts |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/ci/github/accounts     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/ci/github/accounts |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/ci/github/accounts |

### Overview

Enable or disable CI Visibility for a GitHub account, one of its repositories, or both in the same request. The account (and, optionally, repository) are identified by name. Account-level and repository-level changes are independent and may both be supplied in the same request. At least one of `enabled` or `repository.enabled` must be provided. If the account name matches installations on more than one host, `host` must be supplied to disambiguate, otherwise a 409 is returned. Returns a 404 if the CI Visibility GitHub integration is not enabled for this organization, or if the given account or repository cannot be found by name. This endpoint requires the `ci_provider_settings_write` permission.

OAuth apps require the `ci_provider_settings_write` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#ci-visibility-git-hub-accounts) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type    | Description                                                                                                                                                 |
| ------------ | ---------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object  | Data object for updating a GitHub account's CI Visibility opt-in status.                                                                                    |
| data         | attributes [*required*] | object  | Attributes for updating a GitHub account's CI Visibility opt-in status. At least one of `enabled` or `repository.enabled` must be provided.                 |
| attributes   | account [*required*]    | string  | The GitHub account (organization or user) name to update, identified by name.                                                                               |
| attributes   | enabled                      | boolean | Whether to enable or disable CI Visibility at the account level.                                                                                            |
| attributes   | host                         | string  | The GitHub host (`github.com` or a GHES hostname) the account belongs to. Required to disambiguate when the same account name exists on more than one host. |
| attributes   | repository                   | object  | Repository-level opt-in change to apply, identified by name.                                                                                                |
| repository   | enabled [*required*]    | boolean | Whether to enable or disable CI Visibility for this repository.                                                                                             |
| repository   | name [*required*]       | string  | The repository name to update.                                                                                                                              |
| data         | type [*required*]       | enum    | JSON:API type for the GitHub account resource. The value must always be `ci_github_account`. Allowed enum values: `ci_github_account`                       |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "account": "datadog",
      "enabled": true,
      "host": "github.com",
      "repository": {
        "enabled": true,
        "name": "shopist"
      }
    },
    "type": "ci_github_account"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response object containing a single GitHub account's CI Visibility opt-in status.

| Parent field | Field                        | Type     | Description                                                                                                                           |
| ------------ | ---------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Data object for a GitHub account.                                                                                                     |
| data         | attributes [*required*] | object   | Attributes describing a GitHub account's CI Visibility opt-in status.                                                                 |
| attributes   | account                      | string   | The GitHub account (organization or user) name.                                                                                       |
| attributes   | enabled                      | boolean  | Whether CI Visibility is enabled at the account level.                                                                                |
| attributes   | host                         | string   | The GitHub host (`github.com` or a GitHub Enterprise Server (GHES) hostname) this account belongs to.                                 |
| attributes   | repo_count                   | int64    | The number of repositories known for this account.                                                                                    |
| attributes   | repositories                 | [object] | The repositories belonging to this account, with their individual opt-in status.                                                      |
| repositories | enabled                      | boolean  | Whether CI Visibility is enabled for this repository.                                                                                 |
| repositories | name                         | string   | The repository name.                                                                                                                  |
| data         | id [*required*]         | string   | The account's unique identifier, in the form `<host>/<account name>` (for example `github.com/datadog`).                              |
| data         | type [*required*]       | enum     | JSON:API type for the GitHub account resource. The value must always be `ci_github_account`. Allowed enum values: `ci_github_account` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "account": "datadog",
      "enabled": true,
      "host": "github.com",
      "repo_count": 12,
      "repositories": [
        {
          "enabled": true,
          "name": "shopist"
        }
      ]
    },
    "id": "github.com/datadog",
    "type": "ci_github_account"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Not Authorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="409" %}
Conflict
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X PATCH "https://api.datadoghq.com/api/v2/ci/github/accounts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "account": "datadog",
      "enabled": true,
      "host": "github.com",
      "repository": {
        "enabled": true,
        "name": "shopist"
      }
    },
    "type": "ci_github_account"
  }
}
EOF 
                
##### 

```python
"""
Update GitHub CI Visibility status returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api import CIVisibilityGitHubAccountsApi
from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request import CIAppGitHubAccountUpdateRequest
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import (
    CIAppGitHubAccountUpdateRequestAttributes,
)
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import CIAppGitHubAccountUpdateRequestData
from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import (
    CIAppGitHubAccountUpdateRequestRepository,
)

body = CIAppGitHubAccountUpdateRequest(
    data=CIAppGitHubAccountUpdateRequestData(
        attributes=CIAppGitHubAccountUpdateRequestAttributes(
            account="datadog",
            enabled=True,
            host="github.com",
            repository=CIAppGitHubAccountUpdateRequestRepository(
                enabled=True,
                name="shopist",
            ),
        ),
        type=CIAppGitHubAccountType.CI_GITHUB_ACCOUNT,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = CIVisibilityGitHubAccountsApi(api_client)
    response = api_instance.update_ci_app_git_hub_account(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Update GitHub CI Visibility status returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::CIVisibilityGitHubAccountsAPI.new

body = DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequest.new({
  data: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestData.new({
    attributes: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestAttributes.new({
      account: "datadog",
      enabled: true,
      host: "github.com",
      repository: DatadogAPIClient::V2::CIAppGitHubAccountUpdateRequestRepository.new({
        enabled: true,
        name: "shopist",
      }),
    }),
    type: DatadogAPIClient::V2::CIAppGitHubAccountType::CI_GITHUB_ACCOUNT,
  }),
})
p api_instance.update_ci_app_git_hub_account(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Update GitHub CI Visibility status returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.CIAppGitHubAccountUpdateRequest{
		Data: datadogV2.CIAppGitHubAccountUpdateRequestData{
			Attributes: datadogV2.CIAppGitHubAccountUpdateRequestAttributes{
				Account: "datadog",
				Enabled: datadog.PtrBool(true),
				Host:    datadog.PtrString("github.com"),
				Repository: &datadogV2.CIAppGitHubAccountUpdateRequestRepository{
					Enabled: true,
					Name:    "shopist",
				},
			},
			Type: datadogV2.CIAPPGITHUBACCOUNTTYPE_CI_GITHUB_ACCOUNT,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewCIVisibilityGitHubAccountsApi(apiClient)
	resp, r, err := api.UpdateCIAppGitHubAccount(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `CIVisibilityGitHubAccountsApi.UpdateCIAppGitHubAccount`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `CIVisibilityGitHubAccountsApi.UpdateCIAppGitHubAccount`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Update GitHub CI Visibility status returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CiVisibilityGitHubAccountsApi;
import com.datadog.api.client.v2.model.CIAppGitHubAccountResponse;
import com.datadog.api.client.v2.model.CIAppGitHubAccountType;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequest;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestData;
import com.datadog.api.client.v2.model.CIAppGitHubAccountUpdateRequestRepository;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    CiVisibilityGitHubAccountsApi apiInstance = new CiVisibilityGitHubAccountsApi(defaultClient);

    CIAppGitHubAccountUpdateRequest body =
        new CIAppGitHubAccountUpdateRequest()
            .data(
                new CIAppGitHubAccountUpdateRequestData()
                    .attributes(
                        new CIAppGitHubAccountUpdateRequestAttributes()
                            .account("datadog")
                            .enabled(true)
                            .host("github.com")
                            .repository(
                                new CIAppGitHubAccountUpdateRequestRepository()
                                    .enabled(true)
                                    .name("shopist")))
                    .type(CIAppGitHubAccountType.CI_GITHUB_ACCOUNT));

    try {
      CIAppGitHubAccountResponse result = apiInstance.updateCIAppGitHubAccount(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling CiVisibilityGitHubAccountsApi#updateCIAppGitHubAccount");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Update GitHub CI Visibility status returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_ci_visibility_git_hub_accounts::CIVisibilityGitHubAccountsAPI;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountType;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequest;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestAttributes;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestData;
use datadog_api_client::datadogV2::model::CIAppGitHubAccountUpdateRequestRepository;

#[tokio::main]
async fn main() {
    let body = CIAppGitHubAccountUpdateRequest::new(CIAppGitHubAccountUpdateRequestData::new(
        CIAppGitHubAccountUpdateRequestAttributes::new("datadog".to_string())
            .enabled(true)
            .host("github.com".to_string())
            .repository(CIAppGitHubAccountUpdateRequestRepository::new(
                true,
                "shopist".to_string(),
            )),
        CIAppGitHubAccountType::CI_GITHUB_ACCOUNT,
    ));
    let configuration = datadog::Configuration::new();
    let api = CIVisibilityGitHubAccountsAPI::with_config(configuration);
    let resp = api.update_ci_app_git_hub_account(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Update GitHub CI Visibility status returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.CIVisibilityGitHubAccountsApi(configuration);

const params: v2.CIVisibilityGitHubAccountsApiUpdateCIAppGitHubAccountRequest =
  {
    body: {
      data: {
        attributes: {
          account: "datadog",
          enabled: true,
          host: "github.com",
          repository: {
            enabled: true,
            name: "shopist",
          },
        },
        type: "ci_github_account",
      },
    },
  };

apiInstance
  .updateCIAppGitHubAccount(params)
  .then((data: v2.CIAppGitHubAccountResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
