GitHub lets organisations switch AI Scan for repositories on or off through the REST API
GitHub has added REST API control over AI Scan for repositories, part of GitHub code scanning, in public preview. The changelog entry of 13 November says the point is to roll the setting out with scripts and infrastructure as code instead of changing it one organisation or repository at a time.
The change adds a repository_scan property to the existing AI Scan enablement endpoints. GET and PATCH /orgs/{org}/code-scanning/ai-scan handle the organisation level, and GET and PATCH /repos/{owner}/{repo}/code-scanning/ai-scan the repository level. The property takes enabled or disabled.
It behaves like the pr_scan setting that already governs AI Scan for pull requests. If an organisation disables AI Scan for repositories, its repositories cannot enable it. If the organisation enables it, repositories inherit the setting and can opt out one by one. If an enterprise policy does not allow AI Scan, a request to enable it returns a 422 error. Both properties can be changed in one request, and if either change is blocked the whole request fails with 422 and neither setting changes.
Enabling the setting does not start anything. Users with write access still run scans on demand, and each scan consumes GitHub Code Security AI credits.
Organisation owners and security managers manage the organisation setting; repository administrators can opt individual repositories out. The feature is available for public repositories owned by organisations, and for private or internal repositories with GitHub Code Security or GitHub Advanced Security. Enterprise owners must first allow AI Scan in the enterprise policy, and GitHub Enterprise Server is not supported.

Why it matters
The all-or-nothing rule for a combined request is the detail to note for automation. A script that sets both properties will not leave an organisation half-configured, but it also will not apply the permitted change when the other one is refused, so error handling has to read the 422 rather than assume partial success.