← All tags

Code-Scanning API Reference

Retrieve code scanning alerts from a repository.

21 endpoints tagged code-scanning, each listing its parameters and possible responses. Search or scroll the index below to jump to a specific endpoint.

No endpoints match your search.

List code scanning alerts 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."

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
tool_namequerynoThe 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_guidquerynoThe 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.
beforequerynoA 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."
afterquerynoA 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."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
directionquerynoThe direction to sort the results by.
statequerynoIf specified, only code scanning alerts with this state will be returned.
sortquerynoThe property by which to sort the results.
severityquerynoIf specified, only code scanning alerts with this severity will be returned.
assigneesquerynoFilter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot).

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
503Service unavailableyes

List code scanning alerts for a repository

GET /repos/{owner}/{repo}/code-scanning/alerts

Lists code scanning alerts.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
tool_namequerynoThe 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_guidquerynoThe 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.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
refquerynoThe Git reference for the results you want to list. The ref for a branch can be formatted either as refs/heads/<branch name> or simply <branch name>. To reference a pull request use refs/pull/<number>/merge.
prquerynoThe number of the pull request for the results you want to list.
directionquerynoThe direction to sort the results by.
beforequerynoA 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."
afterquerynoA 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."
sortquerynoThe property by which to sort the results.
statequerynoIf specified, only code scanning alerts with this state will be returned.
severityquerynoIf specified, only code scanning alerts with this severity will be returned.
assigneesquerynoFilter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot).

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Get a code scanning alert

GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}

Gets a single code scanning alert.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Update a code scanning alert

PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}

Updates the status of a single code scanning alert.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Get the status of an autofix for 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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
500Internal Erroryes

Create an autofix for a code scanning alert

POST /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix

Creates an autofix for a code scanning alert from the repository's default branch.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.

Responses

StatusDescriptionHas JSON body
200OKyes
202Acceptedyes
400Bad Requestyes
403Response if the repository is archived, if GitHub Advanced Security is not enabled for this repository or if rate limit is exceededyes
404Resource not foundyes
422Unprocessable Entityno
500Internal Erroryes

Commit 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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.

Responses

StatusDescriptionHas JSON body
201Createdyes
400Bad Requestyes
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
422Unprocessable Entityno
503Service unavailableyes

List instances of a code scanning alert

GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances

Lists all instances of the specified code scanning alert.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
alert_numberpathyesThe 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.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
refquerynoThe Git reference for the results you want to list. The ref for a branch can be formatted either as refs/heads/<branch name> or simply <branch name>. To reference a pull request use refs/pull/<number>/merge.
prquerynoThe number of the pull request for the results you want to list.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

List code scanning analyses for a repository

GET /repos/{owner}/{repo}/code-scanning/analyses

Lists the details of all code scanning analyses for a repository,

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
tool_namequerynoThe 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_guidquerynoThe 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.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
prquerynoThe number of the pull request for the results you want to list.
refquerynoThe Git reference for the analyses you want to list. The ref for a branch can be formatted either as refs/heads/<branch name> or simply <branch name>. To reference a pull request use refs/pull/<number>/merge.
sarif_idquerynoFilter analyses belonging to the same SARIF upload.
directionquerynoThe direction to sort the results by.
sortquerynoThe property by which to sort the results.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Get a code scanning analysis for a repository

GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}

Gets a specified code scanning analysis for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
analysis_idpathyesThe ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
422Response if analysis could not be processedyes
503Service unavailableyes

Delete a code scanning analysis from a repository

DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}

Deletes a specified code scanning analysis from a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
analysis_idpathyesThe ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation.
confirm_deletequerynoAllow 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.

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

List CodeQL databases for a repository

GET /repos/{owner}/{repo}/code-scanning/codeql/databases

Lists the CodeQL databases that are available in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Get a CodeQL database for a repository

GET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}

Gets a CodeQL database for a language in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
languagepathyesThe language of the CodeQL database.

Responses

StatusDescriptionHas JSON body
200Responseyes
302Foundno
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Delete a CodeQL database

DELETE /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}

Deletes a CodeQL database for a language in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
languagepathyesThe language of the CodeQL database.

Responses

StatusDescriptionHas JSON body
204Responseno
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Create a CodeQL variant analysis

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Variant analysis submitted for processingyes
404Resource not foundyes
422Unable to process variant analysis submissionyes
503Service unavailableyes

Get the summary of a CodeQL variant analysis

GET /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}

Gets the summary of a CodeQL variant analysis.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
codeql_variant_analysis_idpathyesThe unique identifier of the variant analysis.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
503Service unavailableyes

Get the analysis status of a repository in 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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the controller repository.
codeql_variant_analysis_idpathyesThe ID of the variant analysis.
repo_ownerpathyesThe account owner of the variant analysis repository. The name is not case sensitive.
repo_namepathyesThe name of the variant analysis repository.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
503Service unavailableyes

Get a code scanning default setup configuration

GET /repos/{owner}/{repo}/code-scanning/default-setup

Gets a code scanning default setup configuration.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
503Service unavailableyes

Update a code scanning default setup configuration

PATCH /repos/{owner}/{repo}/code-scanning/default-setup

Updates a code scanning default setup configuration.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
202Responseyes
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
409Response if there is already a validation run in progress with a different default setup configurationyes
422Response if the configuration change cannot be made because the repository is not in the required stateyes
503Service unavailableyes

Upload an analysis as SARIF data

POST /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."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
202Responseyes
400Bad Request if the sarif field is invalidno
403Response if the repository is archived or if GitHub Advanced Security is not enabled for this repositoryyes
404Resource not foundyes
413Payload Too Large if the sarif field is too largeno
503Service unavailableyes

Get information about a SARIF upload

GET /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."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
sarif_idpathyesThe SARIF ID obtained after uploading.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Response if GitHub Advanced Security is not enabled for this repositoryyes
404Not Found if the sarif id does not match any uploadno
503Service unavailableyes