{"id":3018,"date":"2026-09-11T05:09:10","date_gmt":"2026-09-11T05:09:10","guid":{"rendered":"https:\/\/dmarketertayeeb.com\/blog\/github-ai-scan-pull-request-apis\/"},"modified":"2026-09-11T05:11:29","modified_gmt":"2026-09-11T05:11:29","slug":"github-ai-scan-pull-request-apis","status":"publish","type":"post","link":"https:\/\/dmarketertayeeb.com\/blog\/github-ai-scan-pull-request-apis\/","title":{"rendered":"GitHub AI Scan APIs: Endpoints, Permissions and a Safe Pull-Request Pilot"},"content":{"rendered":"\n<p><strong>GitHub\u2019s AI Scan for pull requests is now controllable through REST APIs in public preview.<\/strong> The useful implementation question is not whether a team should \u201cturn on AI security\u201d everywhere. It is whether the enterprise, organization, repository, token, CodeQL setup and review process are ready for a preview feature whose findings are informational.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What the preview exposes<\/h2>\n\n\n\n<p>GitHub\u2019s September 10 changelog describes organization- and repository-level controls. The documented repository paths are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n  <li><code>GET \/repos\/{owner}\/{repo}\/code-scanning\/ai-scan<\/code> to read the setting.<\/li>\n  <li><code>PATCH \/repos\/{owner}\/{repo}\/code-scanning\/ai-scan<\/code> with <code>{\"pr_scan\":\"enabled\"}<\/code> or <code>{\"pr_scan\":\"disabled\"}<\/code> to update it.<\/li>\n  <li><code>\/orgs\/{org}\/code-scanning\/ai-scan<\/code> for organization-level control, as named in the changelog.<\/li>\n<\/ul>\n\n\n\n<p>The organization setting is the upper boundary: a repository setting cannot override an organization-level disablement. GitHub says the preview is on GitHub.com for GitHub Advanced Security customers; GitHub Enterprise Server is not supported for this release.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Read the setting before changing it<\/h2>\n\n\n\n<p>The following is a documentation-derived request example. It is illustrative; it was not executed against a GitHub account in this review.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -L   -H \"Accept: application\/vnd.github+json\"   -H \"Authorization: Bearer &lt;YOUR-TOKEN&gt;\"   -H \"X-GitHub-Api-Version: 2026-03-10\"   https:\/\/api.github.com\/repos\/OWNER\/REPO\/code-scanning\/ai-scan<\/code><\/pre>\n\n\n\n<p>The documented successful response is small:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"pr_scan\":\"enabled\"}<\/code><\/pre>\n\n\n\n<p>Interpret that response as an enablement state, not as proof that every pull request has been scanned or that a finding is correct. Store the repository, commit or pull-request context and the response timestamp with your own change record.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Permissions are different for read and update<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table>\n  <thead><tr><th>Operation<\/th><th>Classic token guidance<\/th><th>Fine-grained permission<\/th><th>Important failure<\/th><\/tr><\/thead>\n  <tbody>\n    <tr><td>Read repository state<\/td><td><code>security_events<\/code> for private\/public repositories, or <code>public_repo<\/code> for public-only use<\/td><td>Code scanning alerts: read<\/td><td>403 when Advanced Security is not enabled<\/td><\/tr>\n    <tr><td>Update repository state<\/td><td><code>repo<\/code> for private\/public repositories, or <code>public_repo<\/code> for public-only use<\/td><td>Administration: write<\/td><td>403 for an archived repository or missing Advanced Security; 422 for validation\/spam<\/td><\/tr>\n  <\/tbody>\n<\/table><\/figure>\n\n\n\n<p>The REST documentation also lists GitHub App user, installation and fine-grained personal access tokens for these endpoints. Choose the least-privilege token that fits the operating model. Do not give a read-only scanner an administration write permission merely because the same job may later need to enable a setting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites before a pilot<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n  <li>Confirm the enterprise policy allows AI security detections, the organization is enabled, and the repository has CodeQL default setup where required by the documented feature announcement.<\/li>\n  <li>Confirm GitHub Advanced Security entitlement and the GitHub.com boundary. A 403 is an entitlement or repository-state signal, not a reason to retry with a broader token.<\/li>\n  <li>Read the current state, record the response, and select one non-critical repository. Keep the PATCH operation behind a human approval.<\/li>\n  <li>Compare the informational AI findings with the existing code-scanning and code-owner process. Do not make the AI result a merge authority without a separate policy decision.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">What this does not prove<\/h2>\n\n\n\n<p>AI Scan does not replace CodeQL, code owners, branch protection or human security review. The GitHub Community announcement says findings are informational and do not block merges. Keep a review record that distinguishes an AI detection, a human disposition and the merge decision.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Failure modes and rollback<\/h2>\n\n\n\n<p>Put the response code and the feature boundary in the pilot runbook before anyone receives a write token.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table>\n  <thead><tr><th>Signal<\/th><th>What it can mean<\/th><th>Safe response<\/th><\/tr><\/thead>\n  <tbody>\n    <tr><td>403<\/td><td>Advanced Security is unavailable, the repository is archived, the organisation has disabled the feature, or the token lacks the required permission.<\/td><td>Read the organisation and repository state, check entitlement and token scope, then stop. Do not widen the token as a blind retry.<\/td><\/tr>\n    <tr><td>404<\/td><td>The owner\/repository path is wrong or the endpoint is not available for that repository context.<\/td><td>Verify the repository, GitHub.com boundary and feature eligibility; record the request URL and response.<\/td><\/tr>\n    <tr><td>422<\/td><td>The PATCH body is invalid or GitHub rejected the request as a validation or abuse condition.<\/td><td>Compare the body with the current REST documentation and ask an administrator to approve the corrected request.<\/td><\/tr>\n    <tr><td>Organisation disabled<\/td><td>A repository-level enablement cannot override the organisation boundary.<\/td><td>Escalate to the organisation owner and leave the repository unchanged.<\/td><\/tr>\n    <tr><td>GitHub Enterprise Server<\/td><td>The September preview is described for GitHub.com, not GHES.<\/td><td>Keep the preview out of the GHES rollout plan until GitHub documents support.<\/td><\/tr>\n  <\/tbody>\n<\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Record a reversible pilot<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n  <li>Choose one non-critical repository and write down its current AI Scan state, Advanced Security entitlement, CodeQL setup and organisation policy.<\/li>\n  <li>Use a read-only token for the inventory request. Store the repository, commit or pull-request scope, response body and timestamp in the change record.<\/li>\n  <li>Have the repository owner approve one PATCH request. Keep the previous state in the record so the setting can be restored without guessing.<\/li>\n  <li>Run several representative pull requests and label findings as informational until a human reviewer confirms what the result means for the repository.<\/li>\n  <li>Stop the pilot if the response, entitlement or finding semantics are inconsistent. Roll back the setting and retain the evidence rather than widening the rollout.<\/li>\n<\/ol>\n\n\n\n<p>The existing <a href=\"https:\/\/dmarketertayeeb.com\/blog\/github-copilot-september-2026-model-budget-review-changes\">Copilot governance checklist<\/a> owns model, budget and review policy. The <a href=\"https:\/\/dmarketertayeeb.com\/blog\/github-copilot-vscode-august-2026-releases\">Copilot VS Code release guide<\/a> owns feature-surface context. Link to those pages when the reader needs the adjacent decision; keep this page responsible for AI Scan API enablement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ: questions readers ask<\/h2>\n\n\n<dl>\n  <dt><strong>Does AI Scan replace human code review?<\/strong><\/dt>\n  <dd>No. The preview exposes a scan setting and findings; it does not make a finding an approval authority or replace repository review rules.<\/dd>\n  <dt><strong>Can a repository enable AI Scan if the organisation disables it?<\/strong><\/dt>\n  <dd>No. The organisation-level boundary takes precedence, so resolve the organisation policy first.<\/dd>\n  <dt><strong>Is this API available on GHES?<\/strong><\/dt>\n  <dd>The September announcement describes the public preview on GitHub.com and says GHES is unsupported for this release.<\/dd>\n<\/dl>\n\n\n<p><strong>Source note:<\/strong> The request paths, scopes, permissions, response and status codes above come from GitHub\u2019s current REST documentation; the preview and product boundary come from GitHub\u2019s September 10 changelog. The curl and JSON blocks are illustrative documentation examples, not an executed account test.<\/p>\n\n\n\n<p>For adjacent governance, see the <a href=\"https:\/\/dmarketertayeeb.com\/blog\/github-copilot-september-2026-model-budget-review-changes\">Copilot model and review checklist<\/a> and the <a href=\"https:\/\/dmarketertayeeb.com\/blog\/github-copilot-vscode-august-2026-releases\">Copilot release workflow guide<\/a>.<\/p>\n\n\n\n<p><strong>Sources:<\/strong> <a href=\"https:\/\/github.blog\/changelog\/2026-09-10-ai-scan-for-pull-request-apis-in-public-preview\/\">GitHub Changelog<\/a> <a href=\"https:\/\/docs.github.com\/en\/rest\/code-scanning\/code-scanning?apiVersion=2026-03-10\">GitHub REST code-scanning documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use GitHub AI Scan APIs safely: exact endpoints, token permissions, eligibility failures, response handling and a reversible pull-request pilot.<\/p>\n","protected":false},"author":1,"featured_media":3017,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183,180,178],"tags":[393,319,396,426,315,422],"class_list":["post-3018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-in-marketing","category-ai-news","category-artificial-intelligence","tag-ai-model-releases","tag-ai-workflows","tag-coding-agents","tag-content-governance","tag-developer-tools","tag-marketing-operations","has-featured-image"],"_links":{"self":[{"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/posts\/3018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/comments?post=3018"}],"version-history":[{"count":1,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/posts\/3018\/revisions"}],"predecessor-version":[{"id":3020,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/posts\/3018\/revisions\/3020"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/media\/3017"}],"wp:attachment":[{"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/media?parent=3018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/categories?post=3018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dmarketertayeeb.com\/blog\/wp-json\/wp\/v2\/tags?post=3018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}