Sample - GitHub REST API
PATCH/orgs/{org}/code-scanning/ai-scan

Update the AI Scan setting for an organization

[!NOTE] This endpoint is in public preview and is subject to change.

Updates the AI Scan setting stored on an organization.

The organization respects the enterprise policy, so enabling is rejected when the enterprise disallows AI Scan.

OAuth app tokens and personal access tokens (classic) need the admin:org, repo, or write:org scope to use this endpoint. Organization owners can use admin:org or repo; security managers need write:org.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 1 body field
orgstringrequired
The organization name. The name is not case sensitive.
pr_scanstringoptional
Whether AI Scan is enabled for the organization. Organization respects enterprise policy. Disabled organizations prevent repositories from enabling AI Scan. Enabled organizations enable AI Scan for their repositories, but individual repositories can opt out.
Allowed:enableddisabled

4 status codes
200Response
pr_scanstringrequired
Whether AI Scan on pull requests is enabled for the organization. The organization setting respects enterprise policy, and repositories inherit it: when disabled, repositories cannot enable AI Scan; when enabled, repositories can still opt out.
Allowed:enableddisabled
403Forbidden
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned: Forbidden. A 404 is returned: Resource not found. A 422 is returned: Validation failed, or the endpoint has been spammed.