Use the REST API to retrieve and update code scanning alerts from a repository.
You can retrieve and update code scanning alerts from a repository. You can use the endpoints to create automated reports for the code scanning alerts in an organization or upload analysis results generated using offline code scanning tools. For more information, see Find and fix code vulnerabilities.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /orgs/{org}/code-scanning/ai-scan
Gets the AI Scan setting stored on an organization.
The response reports the value stored on the organization. Organization respects enterprise policy.
The authenticated user must be an owner or security manager for the organization to use this endpoint.
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.
accept (string)application/vnd.github+json is recommended.org (string) (required)200 - OK
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/code-scanning/ai-scan
Response schema (Status: 200):
pr_scan: required, string, enum: enabled, disabledPATCH /orgs/{org}/code-scanning/ai-scan
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.
accept (string)application/vnd.github+json is recommended.org (string) (required)pr_scan (string)enabled, disabled200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PATCH \
https://api.github.com/orgs/ORG/code-scanning/ai-scan \
-d '{
"pr_scan": "enabled"
}'
Response schema (Status: 200):
Same response schema as Get the AI Scan setting for an organization.
GET /orgs/{org}/code-scanning/alerts
Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."
The authenticated user must be an owner or security manager for the organization to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the security_events or repos cope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
tool_name (string)
The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either tool_name or tool_guid, but not both.
tool_guid (string or null)
The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either tool_guid or tool_name, but not both.
before (string)
A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API."
after (string)
A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API."
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
direction (string)
The direction to sort the results by.
Default: desc
Can be one of: asc, desc
state (string)
If specified, only code scanning alerts with this state will be returned.
Can be one of: open, closed, dismissed, fixed
sort (string)
The property by which to sort the results.
Default: created
Can be one of: created, updated
severity (string)
If specified, only code scanning alerts with this severity will be returned.
Can be one of: critical, high, medium, low, warning, note, error
assignees (string)
Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot).
Use * to list alerts with at least one assignee or none to list alerts with no assignees.
200 - OK
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/code-scanning/alerts
Response schema (Status: 200):
Array of objects:
number: required, integer, read-onlycreated_at: required, string, format: date-time, read-onlyupdated_at: string, format: date-time, read-onlyurl: required, string, format: uri, read-onlyhtml_url: required, string, format: uri, read-onlyinstances_url: required, string, format: uri, read-onlystate: required, string or null, enum: open, dismissed, fixed, nullfixed_at: string or null, format: date-time, read-onlydismissed_by: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringdismissed_at: required, string or null, format: date-time, read-onlydismissed_reason: required, string or null, enum: false positive, won't fix, used in tests, mitigated, nulldismissed_comment: string or null, maxLength: 280rule: required, object:
id: string or nullname: stringseverity: string or null, enum: none, note, warning, error, nullsecurity_severity_level: string or null, enum: low, medium, high, critical, nulldescription: stringfull_description: stringtags: array of string or nullhelp: string or nullhelp_uri: string or nulltool: required, object:
name: stringversion: string or nullguid: string or nullmost_recent_instance: required, object:
ref: stringanalysis_key: stringenvironment: stringcategory: stringstate: string or null, enum: open, dismissed, fixed, nullcommit_sha: stringmessage: object:
text: stringmarkdown: stringlocation: object:
path: stringstart_line: integerend_line: integerstart_column: integerend_column: integerhtml_url: stringclassifications: array of string or null, enum: source, generated, test, library, nullrepository: required, Simple Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User (see above)private: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringhooks_url: required, string, format: uridismissal_approved_by: any of:
assignees: array of Simple User (see above)GET /repos/{owner}/{repo}/code-scanning/ai-scan
Gets whether AI Scan is enabled for a repository.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/ai-scan
Response schema (Status: 200):
Same response schema as Get the AI Scan setting for an organization.
PATCH /repos/{owner}/{repo}/code-scanning/ai-scan
Updates whether AI Scan is enabled for a repository.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
pr_scan (string)enabled, disabled200 - OK
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PATCH \
https://api.github.com/repos/OWNER/REPO/code-scanning/ai-scan \
-d '{
"pr_scan": "enabled"
}'
Response schema (Status: 200):
Same response schema as Get the AI Scan setting for an organization.
GET /repos/{owner}/{repo}/code-scanning/alerts
Lists code scanning alerts.
The response includes a most_recent_instance object.
This provides details of the most recent instance of this alert
for the default branch (or for the specified Git reference if you used ref in the request).
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
tool_name (string)
The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either tool_name or tool_guid, but not both.
tool_guid (string or null)
The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either tool_guid or tool_name, but not both.
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
ref (string)
The Git reference for the results you want to list. The ref for a branch can be formatted either as refs/heads/
pr (integer)
The number of the pull request for the results you want to list.
direction (string)
The direction to sort the results by.
Default: desc
Can be one of: asc, desc
before (string)
A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API."
after (string)
A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API."
sort (string)
The property by which to sort the results.
Default: created
Can be one of: created, updated
state (string)
If specified, only code scanning alerts with this state will be returned.
Can be one of: open, closed, dismissed, fixed
severity (string)
If specified, only code scanning alerts with this severity will be returned.
Can be one of: critical, high, medium, low, warning, note, error
assignees (string)
Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot).
Use * to list alerts with at least one assignee or none to list alerts with no assignees.
200 - OK
304 - Not modified
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts
Response schema (Status: 200):
Array of objects:
number: required, integer, read-onlycreated_at: required, string, format: date-time, read-onlyupdated_at: string, format: date-time, read-onlyurl: required, string, format: uri, read-onlyhtml_url: required, string, format: uri, read-onlyinstances_url: required, string, format: uri, read-onlystate: required, string or null, enum: open, dismissed, fixed, nullfixed_at: string or null, format: date-time, read-onlydismissed_by: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringdismissed_at: required, string or null, format: date-time, read-onlydismissed_reason: required, string or null, enum: false positive, won't fix, used in tests, mitigated, nulldismissed_comment: string or null, maxLength: 280rule: required, object:
id: string or nullname: stringseverity: string or null, enum: none, note, warning, error, nullsecurity_severity_level: string or null, enum: low, medium, high, critical, nulldescription: stringfull_description: stringtags: array of string or nullhelp: string or nullhelp_uri: string or nulltool: required, object:
name: stringversion: string or nullguid: string or nullmost_recent_instance: required, object:
ref: stringanalysis_key: stringenvironment: stringcategory: stringstate: string or null, enum: open, dismissed, fixed, nullcommit_sha: stringmessage: object:
text: stringmarkdown: stringlocation: object:
path: stringstart_line: integerend_line: integerstart_column: integerend_column: integerhtml_url: stringclassifications: array of string or null, enum: source, generated, test, library, nulldismissal_approved_by: any of:
assignees: array of Simple User (see above)GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
Gets a single code scanning alert.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
200 - OK
304 - Not modified
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER
Response schema (Status: 200):
number: required, integer, read-onlycreated_at: required, string, format: date-time, read-onlyupdated_at: string, format: date-time, read-onlyurl: required, string, format: uri, read-onlyhtml_url: required, string, format: uri, read-onlyinstances_url: required, string, format: uri, read-onlystate: required, string or null, enum: open, dismissed, fixed, nullfixed_at: string or null, format: date-time, read-onlydismissed_by: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringdismissed_at: required, string or null, format: date-time, read-onlydismissed_reason: required, string or null, enum: false positive, won't fix, used in tests, mitigated, nulldismissed_comment: string or null, maxLength: 280rule: required, object:
id: string or nullname: stringseverity: string or null, enum: none, note, warning, error, nullsecurity_severity_level: string or null, enum: low, medium, high, critical, nulldescription: stringfull_description: stringtags: array of string or nullhelp: string or nullhelp_uri: string or nulltool: required, object:
name: stringversion: string or nullguid: string or nullmost_recent_instance: required, object:
ref: stringanalysis_key: stringenvironment: stringcategory: stringstate: string or null, enum: open, dismissed, fixed, nullcommit_sha: stringmessage: object:
text: stringmarkdown: stringlocation: object:
path: stringstart_line: integerend_line: integerstart_column: integerend_column: integerhtml_url: stringclassifications: array of string or null, enum: source, generated, test, library, nulldismissal_approved_by: any of:
assignees: array of Simple User (see above)linked_pull_requests: array of Pull Request Simple:
url: required, string, format: uriid: required, integer, format: int64node_id: required, stringhtml_url: required, string, format: uridiff_url: required, string, format: uripatch_url: required, string, format: uriissue_url: required, string, format: uricommits_url: required, string, format: urireview_comments_url: required, string, format: urireview_comment_url: required, stringcomments_url: required, string, format: uristatuses_url: required, string, format: urinumber: required, integerstate: required, stringlocked: required, booleantitle: required, stringuser: required, any of:
body: required, string or nulllabels: required, array of objects:
id: required, integer, format: int64node_id: required, stringurl: required, stringname: required, stringdescription: required, stringcolor: required, stringdefault: required, booleanarchived_by: required, all of:
milestone: required, any of:
url: required, string, format: urihtml_url: required, string, format: urilabels_url: required, string, format: uriid: required, integernode_id: required, stringnumber: required, integerstate: required, string, enum: open, closed, default: "open"title: required, stringdescription: required, string or nullcreator: required, any of:
open_issues: required, integerclosed_issues: required, integercreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timedue_on: required, string or null, format: date-timeactive_lock_reason: string or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeclosed_at: required, string or null, format: date-timemerged_at: required, string or null, format: date-timeassignees: array of Simple User (see above)requested_reviewers: array of Simple User (see above)requested_teams: array of Team:
id: required, integernode_id: required, stringname: required, stringslug: required, stringdescription: required, string or nullprivacy: stringnotification_setting: stringpermission: required, stringpermissions: object:
pull: required, booleantriage: required, booleanpush: required, booleanmaintain: required, booleanadmin: required, booleanurl: required, string, format: urihtml_url: required, string, format: urimembers_url: required, stringrepositories_url: required, string, format: uritype: required, string, enum: enterprise, organizationaccess_source: string, enum: direct, organization, enterpriseorganization_id: integerenterprise_id: integerparent: required, any of:
id: required, integernode_id: required, stringurl: required, string, format: urimembers_url: required, stringname: required, stringdescription: required, string or nullpermission: required, stringprivacy: stringnotification_setting: stringhtml_url: required, string, format: urirepositories_url: required, string, format: urislug: required, stringldap_dn: stringtype: required, string, enum: enterprise, organizationorganization_id: integerenterprise_id: integerhead: required, object:
label: required, stringref: required, stringrepo: required, Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringlicense: required, any of:
key: required, stringname: required, stringurl: required, string or null, format: urispdx_id: required, string or nullnode_id: required, stringhtml_url: string, format: uriforks: required, integerpermissions: object:
admin: required, booleanpull: required, booleantriage: booleanpush: required, booleanmaintain: booleanowner: required, Simple User (see above)private: required, boolean, default: falsehtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: required, stringmirror_url: required, string or null, format: urihooks_url: required, string, format: urisvn_url: required, string, format: urihomepage: required, string or null, format: urilanguage: required, string or nullforks_count: required, integerstargazers_count: required, integerwatchers_count: required, integersize: required, integerdefault_branch: required, stringopen_issues_count: required, integeris_template: boolean, default: falsetopics: array of stringhas_issues: required, boolean, default: truehas_projects: required, boolean, default: truehas_wiki: required, boolean, default: truehas_pages: required, booleanhas_discussions: boolean, default: falsehas_pull_requests: boolean, default: truepull_request_creation_policy: string, enum: all, collaborators_onlyarchived: required, boolean, default: falsedisabled: required, booleanvisibility: string, default: "public"pushed_at: required, string or null, format: date-timecreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeallow_rebase_merge: boolean, default: truetemp_clone_token: stringallow_squash_merge: boolean, default: trueallow_auto_merge: boolean, default: falsedelete_branch_on_merge: boolean, default: falseallow_update_branch: boolean, default: falsesquash_merge_commit_title: string, enum: PR_TITLE, COMMIT_OR_PR_TITLEsquash_merge_commit_message: string, enum: PR_BODY, COMMIT_MESSAGES, BLANKmerge_commit_title: string, enum: PR_TITLE, MERGE_MESSAGEmerge_commit_message: string, enum: PR_BODY, PR_TITLE, BLANKallow_merge_commit: boolean, default: trueallow_forking: booleanweb_commit_signoff_required: boolean, default: falseopen_issues: required, integerwatchers: required, integerstarred_at: stringanonymous_access_enabled: booleancode_search_index_status: object:
lexical_search_ok: booleanlexical_commit_sha: stringsha: required, stringuser: required, any of:
base: required, object:
label: required, stringref: required, stringrepo: required, Repository (see above)sha: required, stringuser: required, any of:
_links: required, object:
comments: required, Link:
href: required, stringcommits: required, Link (see above)statuses: required, Link (see above)html: required, Link (see above)issue: required, Link (see above)review_comments: required, Link (see above)review_comment: required, Link (see above)self: required, Link (see above)author_association: required, string, enum: COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNERauto_merge: required, Auto merge:
enabled_by: required, Simple User (see above)merge_method: required, string, enum: merge, squash, rebasecommit_title: required, stringcommit_message: required, stringstack: Pull Request Stack:
base: required, object:
ref: required, stringsha: required, stringsize: integerposition: integerid: integernumber: integerdraft: booleanPATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
Updates the status of a single code scanning alert.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
state (string)
Sets the state of the code scanning alert. You must provide dismissed_reason when you set the state to dismissed.
Can be one of: open, dismissed
dismissed_reason (string or null)
Required when the state is dismissed. The reason for dismissing or closing the alert.
Can be one of: false positive, won't fix, used in tests, mitigated, null
dismissed_comment (string or null)
The dismissal comment associated with the dismissal of the alert.
create_request (boolean)
If true, attempt to create an alert dismissal request.
assignees (array of strings)
The list of users to assign to the code scanning alert. An empty array unassigns all previous assignees from the alert.
200 - OK
400 - Bad Request
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X PATCH \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER \
-d '{
"state": "dismissed",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there'\''s a sanitizer included in the library.",
"create_request": true
}'
Response schema (Status: 200):
Same response schema as Get a code scanning alert.
GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix
Gets the status and description of an autofix for a code scanning alert on the repository's default branch.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
200 - OK
400 - Bad Request
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER/autofix
Response schema (Status: 200):
status: required, string, enum: pending, error, success, outdateddescription: required, string or nullstarted_at: required, string, format: date-time, read-onlyPOST /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix
Creates an autofix for a code scanning alert from the repository's default branch.
If a new autofix is to be created as a result of this request or is currently being generated, then this endpoint will return a 202 Accepted response.
If an autofix already exists for a given alert, then this endpoint will return a 200 OK response.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
200 - OK
202 - Accepted
400 - Bad Request
403 - Response if the repository is archived, if GitHub Advanced Security is not enabled for this repository or if rate limit is exceeded
404 - Resource not found
422 - Unprocessable Entity
500 - Internal Error
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER/autofix
Response schema (Status: 200):
Same response schema as Get the status of an autofix for a code scanning alert.
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER/autofix
Response schema (Status: 202):
Same response schema as Get the status of an autofix for a code scanning alert.
POST /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix/commits
Commits an autofix for a code scanning alert from the repository's default branch.
If an autofix is committed as a result of this request, then this endpoint will return a 201 Created response.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
target_ref (string)
The Git reference of target branch for the commit. Branch needs to already exist. For more information, see "Git References" in the Git documentation.
message (string)
Commit message to be used.
201 - Created
400 - Bad Request
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
422 - Unprocessable Entity
503 - Service unavailable
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER/autofix/commits \
-d '{
"target_ref": "refs/heads/fix-bug",
"message": "Let'\''s fix this 🪲!"
}'
Response schema (Status: 201):
target_ref: stringsha: stringGET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances
Lists all instances of the specified code scanning alert.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
alert_number (integer) (required)
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts operation.
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
ref (string)
The Git reference for the results you want to list. The ref for a branch can be formatted either as refs/heads/
pr (integer)
The number of the pull request for the results you want to list.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/alerts/ALERT_NUMBER/instances
Response schema (Status: 200):
Array of objects:
ref: stringanalysis_key: stringenvironment: stringcategory: stringstate: string or null, enum: open, fixed, nullcommit_sha: stringmessage: object:
text: stringlocation: object:
path: stringstart_line: integerend_line: integerstart_column: integerend_column: integerhtml_url: stringclassifications: array of string or null, enum: source, generated, test, library, nullGET /repos/{owner}/{repo}/code-scanning/analyses
Lists the details of all code scanning analyses for a repository,
starting with the most recent.
The response is paginated and you can use the page and per_page parameters
to list the analyses you're interested in.
By default 30 analyses are listed per page.
The rules_count field in the response give the number of rules
that were run in the analysis.
For very old analyses this data is not available,
and 0 is returned in this field.
Warning
Closing down notice: The tool_name field is closing down and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the tool field.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
tool_name (string)
The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either tool_name or tool_guid, but not both.
tool_guid (string or null)
The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either tool_guid or tool_name, but not both.
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
pr (integer)
The number of the pull request for the results you want to list.
ref (string)
The Git reference for the analyses you want to list. The ref for a branch can be formatted either as refs/heads/
sarif_id (string)
Filter analyses belonging to the same SARIF upload.
direction (string)
The direction to sort the results by.
Default: desc
Can be one of: asc, desc
sort (string)
The property by which to sort the results.
Default: created
Can be one of: created
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/analyses
Response schema (Status: 200):
Array of objects:
ref: required, stringcommit_sha: required, string, minLength: 40, maxLength: 64, pattern: ^([0-9a-fA-F]{40}(?:[0-9a-fA-F]{24})?)$analysis_key: required, stringenvironment: required, stringcategory: stringerror: required, stringcreated_at: required, string, format: date-time, read-onlyresults_count: required, integerrules_count: required, integerid: required, integerurl: required, string, format: uri, read-onlysarif_id: required, stringtool: required, object:
name: stringversion: string or nullguid: string or nulldeletable: required, booleanwarning: required, stringGET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}
Gets a specified code scanning analysis for a repository.
The default JSON response contains fields that describe the analysis.
This includes the Git reference and commit SHA to which the analysis relates,
the datetime of the analysis, the name of the code scanning tool,
and the number of alerts.
The rules_count field in the default response give the number of rules
that were run in the analysis.
For very old analyses this data is not available,
and 0 is returned in this field.
This endpoint supports the following custom media types. For more information, see "Media types."
application/sarif+json: Instead of returning a summary of the analysis, this endpoint returns a subset of the analysis data that was uploaded. The data is formatted as SARIF version 2.1.0. It also returns additional data such as the github/alertNumber and github/alertUrl properties.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
analysis_id (integer) (required)
The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
422 - Response if analysis could not be processed
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/analyses/ANALYSIS_ID
Response schema (Status: 200):
ref: required, stringcommit_sha: required, string, minLength: 40, maxLength: 64, pattern: ^([0-9a-fA-F]{40}(?:[0-9a-fA-F]{24})?)$analysis_key: required, stringenvironment: required, stringcategory: stringerror: required, stringcreated_at: required, string, format: date-time, read-onlyresults_count: required, integerrules_count: required, integerid: required, integerurl: required, string, format: uri, read-onlysarif_id: required, stringtool: required, object:
name: stringversion: string or nullguid: string or nulldeletable: required, booleanwarning: required, stringRequest:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/analyses/ANALYSIS_ID \
-H "Accept: application/sarif+json"
Response schema (Status: 200):
object, additional properties allowed
DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}
Deletes a specified code scanning analysis from a repository.
You can delete one analysis at a time.
To delete a series of analyses, start with the most recent analysis and work backwards.
Conceptually, the process is similar to the undo function in a text editor.
When you list the analyses for a repository,
one or more will be identified as deletable in the response:
"deletable": true
An analysis is deletable when it's the most recent in a set of analyses.
Typically, a repository will have multiple sets of analyses
for each enabled code scanning tool,
where a set is determined by a unique combination of analysis values:
ref
tool
category
If you attempt to delete an analysis that is not the most recent in a set,
you'll get a 400 response with the message:
Analysis specified is not deletable.
The response from a successful DELETE operation provides you with
two alternative URLs for deleting the next analysis in the set:
next_analysis_url and confirm_delete_url.
Use the next_analysis_url URL if you want to avoid accidentally deleting the final analysis
in a set. This is a useful option if you want to preserve at least one analysis
for the specified tool in your repository.
Use the confirm_delete_url URL if you are content to remove all analyses for a tool.
When you delete the last analysis in a set, the value of next_analysis_url and confirm_delete_url
in the 200 response is null.
As an example of the deletion process,
let's imagine that you added a workflow that configured a particular code scanning tool
to analyze the code in a repository. This tool has added 15 analyses:
10 on the default branch, and another 5 on a topic branch.
You therefore have two separate sets of analyses for this tool.
You've now decided that you want to remove all of the analyses for the tool.
To do this you must make 15 separate deletion requests.
To start, you must find an analysis that's identified as deletable.
Each set of analyses always has one that's identified as deletable.
Having found the deletable analysis for one of the two sets,
delete this analysis and then continue deleting the next analysis in the set until they're all deleted.
Then repeat the process for the second set.
The procedure therefore consists of a nested loop:
Outer loop:
List the analyses for the repository, filtered by tool.
Parse this list to find a deletable analysis. If found:
Inner loop:
Delete the identified analysis.
Parse the response for the value of confirm_delete_url and, if found, use this in the next iteration.
The above process assumes that you want to remove all trace of the tool's analyses from the GitHub user interface, for the specified repository, and it therefore uses the confirm_delete_url value. Alternatively, you could use the next_analysis_url value, which would leave the last analysis in each set undeleted to avoid removing a tool's analysis entirely.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
analysis_id (integer) (required)
The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation.
confirm_delete (string or null)
Allow deletion if the specified analysis is the last in a set. If you attempt to delete the final analysis in a set without setting this parameter to true, you'll get a 400 response with the message: Analysis is last of its type and deletion may result in the loss of historical alert data. Please specify confirm_delete.
200 - OK
400 - Bad Request
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/code-scanning/analyses/ANALYSIS_ID
Response schema (Status: 200):
next_analysis_url: required, string or null, format: uri, read-onlyconfirm_delete_url: required, string or null, format: uri, read-onlyGET /repos/{owner}/{repo}/code-scanning/codeql/databases
Lists the CodeQL databases that are available in a repository.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/databases
Response schema (Status: 200):
Array of CodeQL Database:
id: required, integername: required, stringlanguage: required, stringuploader: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringcontent_type: required, stringsize: required, integercreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeurl: required, string, format: uricommit_oid: string or nullGET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}
Gets a CodeQL database for a language in a repository.
By default this endpoint returns JSON metadata about the CodeQL database. To
download the CodeQL database binary content, set the Accept header of the request
to application/zip, and make sure
your HTTP client is configured to follow redirects or use the Location header
to make a second request to get the redirect URL.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
language (string) (required)
The language of the CodeQL database.
200 - OK
302 - Found
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/databases/LANGUAGE
Response schema (Status: 200):
id: required, integername: required, stringlanguage: required, stringuploader: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringcontent_type: required, stringsize: required, integercreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeurl: required, string, format: uricommit_oid: string or nullDELETE /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}
Deletes a CodeQL database for a language in a repository.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
language (string) (required)
The language of the CodeQL database.
204 - No Content
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/databases/LANGUAGE
Response schema (Status: 204):
POST /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses
Creates a new CodeQL variant analysis, which will run a CodeQL query against one or more repositories.
Get started by learning more about running CodeQL queries at scale with Multi-Repository Variant Analysis.
Use the owner and repo parameters in the URL to specify the controller repository that
will be used for running GitHub Actions workflows and storing the results of the CodeQL variant analysis.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
language (string) (required)
The language targeted by the CodeQL query
Can be one of: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
query_pack (string) (required)
A Base64-encoded tarball containing a CodeQL query and all its dependencies
repositories (array of strings)
List of repository names (in the form owner/repo-name) to run the query against. Precisely one property from repositories, repository_lists and repository_owners is required.
repository_lists (array of strings)
List of repository lists to run the query against. Precisely one property from repositories, repository_lists and repository_owners is required.
repository_owners (array of strings)
List of organization or user names whose repositories the query should be run against. Precisely one property from repositories, repository_lists and repository_owners is required.
201 - Variant analysis submitted for processing
404 - Resource not found
422 - Unable to process variant analysis submission
503 - Service unavailable
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/variant-analyses \
-d '{
"language": "csharp",
"query_pack": "aGVsbG8=",
"repositories": [
"octocat/Hello-World",
"octocat/example"
]
}'
Response schema (Status: 201):
id: required, integercontroller_repo: required, Simple Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringprivate: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringhooks_url: required, string, format: uriactor: required, Simple User (see above)query_language: required, string, enum: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swiftquery_pack_url: required, stringcreated_at: string, format: date-timeupdated_at: string, format: date-timecompleted_at: string or null, format: date-timestatus: required, string, enum: in_progress, succeeded, failed, cancelledactions_workflow_run_id: integerfailure_reason: string, enum: no_repos_queried, actions_workflow_run_failed, internal_errorscanned_repositories: array of objects:
repository: required, Repository Identifier:
id: required, integername: required, stringfull_name: required, stringprivate: required, booleanstargazers_count: required, integerupdated_at: required, string or null, format: date-timeanalysis_status: required, string, enum: pending, in_progress, succeeded, failed, canceled, timed_outresult_count: integerartifact_size_in_bytes: integerfailure_message: stringskipped_repositories: object:
access_mismatch_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)not_found_repos: required, object:
repository_count: required, integerrepository_full_names: required, array of stringno_codeql_db_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)over_limit_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/variant-analyses \
-d '{
"language": "csharp",
"query_pack": "aGVsbG8=",
"repository_owners": [
"octocat"
]
}'
Response schema (Status: 201):
id: required, integercontroller_repo: required, Simple Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringprivate: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringhooks_url: required, string, format: uriactor: required, Simple User (see above)query_language: required, string, enum: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swiftquery_pack_url: required, stringcreated_at: string, format: date-timeupdated_at: string, format: date-timecompleted_at: string or null, format: date-timestatus: required, string, enum: in_progress, succeeded, failed, cancelledactions_workflow_run_id: integerfailure_reason: string, enum: no_repos_queried, actions_workflow_run_failed, internal_errorscanned_repositories: array of objects:
repository: required, Repository Identifier:
id: required, integername: required, stringfull_name: required, stringprivate: required, booleanstargazers_count: required, integerupdated_at: required, string or null, format: date-timeanalysis_status: required, string, enum: pending, in_progress, succeeded, failed, canceled, timed_outresult_count: integerartifact_size_in_bytes: integerfailure_message: stringskipped_repositories: object:
access_mismatch_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)not_found_repos: required, object:
repository_count: required, integerrepository_full_names: required, array of stringno_codeql_db_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)over_limit_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/variant-analyses \
-d '{
"language": "csharp",
"query_pack": "aGVsbG8=",
"repository_lists": [
"top-100-csharp"
]
}'
Response schema (Status: 201):
id: required, integercontroller_repo: required, Simple Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringprivate: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringhooks_url: required, string, format: uriactor: required, Simple User (see above)query_language: required, string, enum: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swiftquery_pack_url: required, stringcreated_at: string, format: date-timeupdated_at: string, format: date-timecompleted_at: string or null, format: date-timestatus: required, string, enum: in_progress, succeeded, failed, cancelledactions_workflow_run_id: integerfailure_reason: string, enum: no_repos_queried, actions_workflow_run_failed, internal_errorscanned_repositories: array of objects:
repository: required, Repository Identifier:
id: required, integername: required, stringfull_name: required, stringprivate: required, booleanstargazers_count: required, integerupdated_at: required, string or null, format: date-timeanalysis_status: required, string, enum: pending, in_progress, succeeded, failed, canceled, timed_outresult_count: integerartifact_size_in_bytes: integerfailure_message: stringskipped_repositories: object:
access_mismatch_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)not_found_repos: required, object:
repository_count: required, integerrepository_full_names: required, array of stringno_codeql_db_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)over_limit_repos: required, object:
repository_count: required, integerrepositories: required, array of Repository Identifier (see above)GET /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}
Gets the summary of a CodeQL variant analysis.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
codeql_variant_analysis_id (integer) (required)
The unique identifier of the variant analysis.
200 - OK
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/variant-analyses/CODEQL_VARIANT_ANALYSIS_ID
Response schema (Status: 200):
Same response schema as Create a CodeQL variant analysis.
GET /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}/repos/{repo_owner}/{repo_name}
Gets the analysis status of a repository in a CodeQL variant analysis.
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the controller repository.
codeql_variant_analysis_id (integer) (required)
The ID of the variant analysis.
repo_owner (string) (required)
The account owner of the variant analysis repository. The name is not case sensitive.
repo_name (string) (required)
The name of the variant analysis repository.
200 - OK
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/codeql/variant-analyses/CODEQL_VARIANT_ANALYSIS_ID/repos/REPO_OWNER/REPO_NAME
Response schema (Status: 200):
repository: required, Simple Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringprivate: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringhooks_url: required, string, format: urianalysis_status: required, string, enum: pending, in_progress, succeeded, failed, canceled, timed_outartifact_size_in_bytes: integerresult_count: integerfailure_message: stringdatabase_commit_sha: stringsource_location_prefix: stringartifact_url: stringGET /repos/{owner}/{repo}/code-scanning/default-setup
Gets a code scanning default setup configuration.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/default-setup
Response schema (Status: 200):
state: string, enum: configured, not-configuredlanguages: array of string, enum: actions, c-cpp, csharp, go, java-kotlin, javascript-typescript, python, ruby, swiftrunner_type: string or null, enum: standard, labeled, nullrunner_label: string or nullquery_suite: string, enum: default, extendedthreat_model: string, enum: remote, remote_and_localupdated_at: string or null, format: date-timeschedule: string or null, enum: weekly, nullPATCH /repos/{owner}/{repo}/code-scanning/default-setup
Updates a code scanning default setup configuration.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
state (string)
The desired state of code scanning default setup.
Can be one of: configured, not-configured
runner_type (string)
Runner type to be used.
Can be one of: standard, labeled
runner_label (string or null)
Runner label to be used if the runner type is labeled.
query_suite (string)
CodeQL query suite to be used.
Can be one of: default, extended
threat_model (string)
Threat model to be used for code scanning analysis. Use remote to analyze only network sources and remote_and_local to include local sources like filesystem access, command-line arguments, database reads, environment variable and standard input.
Can be one of: remote, remote_and_local
languages (array of strings)
CodeQL languages to be analyzed.
Supported values are: actions, c-cpp, csharp, go, java-kotlin, javascript-typescript, python, ruby, swift
200 - OK
202 - Accepted
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
409 - Response if there is already a validation run in progress with a different default setup configuration
422 - Response if the configuration change cannot be made because the repository is not in the required state
503 - Service unavailable
Request:
curl -L \
-X PATCH \
https://api.github.com/repos/OWNER/REPO/code-scanning/default-setup \
-d '{
"state": "configured",
"threat_model": "remote_and_local"
}'
Response schema (Status: 202):
run_id: integerrun_url: stringPOST /repos/{owner}/{repo}/code-scanning/sarifs
Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. For troubleshooting information, see "Troubleshooting SARIF uploads."
There are two places where you can upload code scanning results.
If you upload to a pull request, for example --ref refs/pull/42/merge or --ref refs/pull/42/head, then the results appear as alerts in a pull request check. For more information, see "Triaging code scanning alerts in pull requests."
If you upload to a branch, for example --ref refs/heads/my-branch, then the results appear in the Security tab for your repository. For more information, see "Managing code scanning alerts for your repository."
You must compress the SARIF-formatted analysis data that you want to upload, using gzip, and then encode it as a Base64 format string. For example:
gzip -c analysis-data.sarif | base64 -w0
SARIF upload supports a maximum number of entries per the following data objects, and an analysis will be rejected if any of these objects is above its maximum value. For some objects, there are additional values over which the entries will be ignored while keeping the most important entries whenever applicable.
To get the most out of your analysis when it includes data above the supported limits, try to optimize the analysis configuration. For example, for the CodeQL tool, identify and remove the most noisy queries. For more information, see "SARIF results exceed one or more limits."
SARIF dataMaximum valuesAdditional limitsRuns per file20Results per run25,000Only the top 5,000 results will be included, prioritized by severity.Rules per run25,000Tool extensions per run100Thread Flow Locations per result10,000Only the top 1,000 Thread Flow Locations will be included, using prioritization.Location per result1,000Only 100 locations will be included.Tags per rule20Only 10 tags will be included.
The 202 Accepted response includes an id value.
You can use this ID to check the status of the upload by using it in the /sarifs/{sarif_id} endpoint.
For more information, see "Get information about a SARIF upload."
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint is limited to 1,000 requests per hour for each user or app installation calling it.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
commit_sha (string) (required)
The SHA of the commit to which the analysis you are uploading relates.
ref (string) (required)
The full Git reference, formatted as refs/heads/
refs/tags/
sarif (string) (required)
A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using gzip and then translate the contents of the file into a Base64 encoding string. For more information, see "SARIF support for code scanning."
checkout_uri (string)
The base directory used in the analysis, as it appears in the SARIF file.
This property is used to convert file paths from absolute to relative, so that alerts can be mapped to their correct location in the repository.
started_at (string)
The time that the analysis run began. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
tool_name (string)
The name of the tool used to generate the code scanning analysis. If this parameter is not used, the tool name defaults to "API". If the uploaded SARIF contains a tool GUID, this will be available for filtering using the tool_guid parameter of operations such as GET /repos/{owner}/{repo}/code-scanning/alerts.
validate (boolean)
Whether the SARIF file will be validated according to the code scanning specifications.
This parameter is intended to help integrators ensure that the uploaded SARIF files are correctly rendered by code scanning.
202 - Accepted
400 - Bad Request if the sarif field is invalid
403 - Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
404 - Resource not found
413 - Payload Too Large if the sarif field is too large
503 - Service unavailable
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/code-scanning/sarifs \
-d '{
"commit_sha": "4b6472266afd7b471e86085a6659e8c7f2b119da",
"ref": "refs/heads/master",
"sarif": "H4sICMLGdF4AA2V4YW1wbGUuc2FyaWYAvVjdbts2FL7PUxDCijaA/CM7iRNfLkPXYgHSNstumlzQ0pHFVCI1korjFgH2ONtr7Ul2KFmy/mOn6QIkjsjDw0/nfN85NL8dEGL9pNwAImqRObECrWM1H40kXQ2XTAfJIlEgXcE1cD10RTQSVDE10K4aKSqZP1AxuKOIKg1ydJU60jSfSh8Hk6EzHA/vlOCWbfa7B6kYPpj90rlsWCZcmbHP5Bs+4oAWIjQD2SMOeJLh2vIQDnIaQerqXHjw8YIgxohybxAyDsS4cAPKsp03K4RcUs6+Up2D+JXpd8mibKIQN9fM/aMCdbyBujGSSQgVxJtx5qX2d2qUcIweQhEuDQf3GBO6CKHkogx/N3MVCKl/AeVKFuf4y5ubsMGDTj1ep+5I7sgmLIpxtU38hLtmMRGSuCFVyip5eKzs5ydh+LztVL6f2m6oih1BkYiuyQIIJWodxVpERPj4sEiWBNNH8EWT0DMG8EAjzKVHXCrB4FkPu/F64NMk1OeC+2yZSNoBOoR7CC0EzYWGbm+xFDFIzbI011+cLjfZtyJkmMZfumAh02uL3NpV2y+MZ6RAjxibyKrNxxJcVjANSb4eBGwZ1M0KsuyR2poLr5rMl8vaDSeVn6eTWEO2j2xIEcmhwlTKNOi4GMOI8gfuZYkvJ7b4v5Tiumyz7RnHeodFzpS8ASIZCH/AYdWi2z3sG8JtFxJ6fF9yR9CdifBr9Pd6d5V2+zbJKjjCFGGmsHuYFy2ytJq9tUxcLSRSQecppOGKrpUxYfxefMEFK+wOGa4hudQByBVT0L+EKtyACxnRsABhEx1QjVDs1KNI9MbpnhqfE45B6FJvu3hRu5VRU9MhZLmK7fqkKyQSTHNoyMqUFMqXCV3CwAeqEwmVokraK8IuBaGvHjQ0gMYrKjnjyw7uk9uD8tgmsBbFMPnU1bV2ZhkJNkuolUiWys3UPWzs5aaIUz9TBe8zMb+6+nT+6fLy91dlE3xzeDDT4zYszb0bW6NjJd0Rvn2EnLvWLFSdKPpBzInzfRgu8ETyMcH8nIfMnJCeC2PyfTA+UKngcnGH7Hw2hGkVQs5YlIRCtdWZYQ4/73es2JlxkfViOEIhoWJq5Oo6UBBfiKIqFBWhiE3jJGbFwVoxBHTRSuIS67sMeplei24X20shLjG+8gqbKC/bESiNMC+wd5q5id0yeS7CJEqXzmrTWNq3k05l84P6f4/bEmXFJjI0fIt1BGQssUnUDkBYeVhE5TqPnMH3jqogDcP0zKcTgLPTMSzOjhbjuVOmW23l1fYNStulfo6sXlFsGLhbDy5RECPRYGCTgOj2bd4nUQEivEd0H7KKYxqnEhFohuur3a3UPskbH/+Yg0+M5P2MHRJu3ziHh3Z2NCrWt3XF1rWTw8Ne/pfbWYXnDSE0SNZQQt1i18q7te2vOhu7ehWuvVyeu0wbLZi24mhoo6aOOTltzG/lgdVvVoXQq5V+pewkFIzL8fjEcadT55jOjpzFzHuOTtDNrMkJPMVQDd7F09RID72O/UPZ0tmctqZ7kWX6EmSZnDpP8GU67SXM8XE3YSrxbKsx6UReZ4y6n/FVZfJjs9Z7stma75W5yQtkzjk5eSJxk1lv4o7+j8TlhaJ2lsKWZO6lruDPBLib3x5ZN/KGWzZ+pn///evv7OOf4iIBv3oY9L/l1wiJ9p0Tc+F1zZnOE9NxXWEus6IQhr5pMfoqxi8WPsuu0azsns4UC6WzNzHIzbeEx4P/AJ3SefgcFAAA"
}'
Response schema (Status: 202):
id: stringurl: string, format: uri, read-onlyGET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}
Gets information about a SARIF upload, including the status and the URL of the analysis that was uploaded so that you can retrieve details of the analysis. For more information, see "Get a code scanning analysis for a repository."
OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
sarif_id (string) (required)
The SARIF ID obtained after uploading.
200 - OK
403 - Response if GitHub Advanced Security is not enabled for this repository
404 - Not Found if the sarif id does not match any upload
503 - Service unavailable
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/code-scanning/sarifs/SARIF_ID
Response schema (Status: 200):
processing_status: string, enum: pending, complete, failedanalyses_url: string or null, format: uri, read-onlyerrors: array of string or null