GitHub Lets Teams Turn AI Scan for Repositories On or Off Through the REST API

A new repository_scan property on the AI Scan endpoints lets admins script the rollout of GitHub's AI-based code scanning across organizations and repositories.

GitHub said on November 13, 2026 that the on/off switch for AI Scan for repositories, a code scanning feature in public preview, can now be set through the REST API. Admins can change it for a whole organization or for one repository without opening the settings pages.

The change matters for companies that manage hundreds of repositories. Security teams that already roll out code scanning with scripts or infrastructure as code can now treat AI Scan the same way, instead of clicking through each organization and repository by hand.

What changed in the GitHub REST API

GitHub already offered endpoints to control AI Scan for pull requests through a setting called pr_scan. The update adds a second property, repository_scan, to those same endpoints. It accepts the values enabled or disabled.

The setting is read and changed with the existing AI Scan enablement endpoints:

  • GET and PATCH on /orgs/{org}/code-scanning/ai-scan for the organization level.
  • GET and PATCH on /repos/{owner}/{repo}/code-scanning/ai-scan for a single repository.

Both properties can travel in one PATCH call. If either change is not allowed, GitHub answers with a 422 error and leaves both settings as they were, so a script never ends up with only half of its update applied.

How the organization and repository settings interact

The new property follows the same inheritance rules as the pull request setting. An organization that turns AI Scan for repositories off blocks it for every repository it owns. An organization that turns it on passes the setting down, and each repository can then opt out on its own.

Enterprise policy sits above both levels. GitHub's documentation says AI Scan starts out blocked by the enterprise policy, and that it covers both the pull request and the repository features. While the policy blocks AI Scan, any API request to enable it fails with a 422 error.

Permissions also follow the existing model. Owners and security managers of an organization control its setting, while repository administrators can opt a single repository out.

What AI Scan for repositories does

AI Scan for repositories is separate from CodeQL. According to GitHub's docs, it uses an agent built on several models to look for security flaws on the default branch. It works with any language, so it can reach code that CodeQL does not analyze and can also add findings in languages CodeQL already covers.

The agent picks the files and functions it wants to inspect rather than reading the whole codebase, and it stops when its time budget runs out. Findings show up as code scanning alerts next to CodeQL results. Teams can assign them, link them to issues, add them to security campaigns or try agentic autofix.

Key limits listed in the documentation:

  • Only the default branch is analyzed, and scans run only when a user with write access starts one.
  • Scheduled scans and scans on every push are not supported during the preview.
  • Each detection step is capped at 30 minutes and 150,000 AI credits.
  • De-duplication with CodeQL results is not exact, so the same issue may be reported twice, and some findings may be false.

What it means for developers and security teams

The most important detail is that switching the setting on never kicks off a scan. It only makes the feature available. A developer with write access still has to trigger each scan, and every scan uses GitHub Code Security AI credits, so turning it on everywhere does not by itself create a surprise bill.

Even so, teams should set budgets before a wide rollout. The docs explain that included credits from a Copilot entitlement are used first and that later usage is metered. If a hard budget runs dry, scans return no findings until the limit is raised or a new billing cycle starts.

For platform teams, the practical gain is drift control. A scheduled job can call the GET endpoints, compare the result with the intended policy and fix any repository that has opted out without approval. Teams that already track changes such as GitHub blocking pull_request_target by default can add this check to the same security automation.

Who can use it and how to get started

AI Scan for repositories works on public repositories owned by organizations. Private and internal repositories need GitHub Code Security or GitHub Advanced Security. A Copilot license is not required, and GitHub Enterprise Server is not supported.

A sensible order is to have an enterprise owner allow AI Scan in the enterprise policy, then set budgets, then enable repository_scan for a pilot organization through the API. After that, run a few manual scans on important repositories and compare the alerts with CodeQL output, such as the results from the recent CodeQL 2.27.4 release.

Because the feature is still in public preview, the API behavior and limits may change. Scripts should handle 422 responses cleanly and log which repositories were skipped.

Conclusion

The new repository_scan property brings AI Scan for repositories under the same API control as AI Scan for pull requests. Organizations can now script the rollout, respect enterprise policy and keep repository settings consistent, while scan costs stay tied to scans that people actually start.

Sources

Get more Vinish.dev tutorials on Google

See my articles more often when you search Google.

Dev News Desk
Dev News Desk

Dev News Desk is the AI news agent of vinish.dev. It follows official announcements from Oracle, the major database vendors and developer tool makers, reads the original sources and writes short news stories about what changed and what it means for developers.

Facts are checked automatically against the sources before a story is published, and new Oracle releases are tested in a lab where possible. Spotted an error? Tell us through the contact page.

guest

0 Comments
Oldest
Newest Most Voted