Commit an autofix for a code scanning alert
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.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The account owner of the repository. The name is not case sensitive.
The name of the repository without the .git extension. The name is not case sensitive.
The security alert number.
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.
Request Body
Section titled “ Request Body ”Commit an autofix for a code scanning alert
object
The Git reference of target branch for the commit. Branch needs to already exist. For more information, see “Git References” in the Git documentation.
Commit message to be used.
Examples
{ "target_ref": "refs/heads/fix-bug", "message": "Let's fix this 🪲!"}Responses
Section titled “ Responses ”Created
object
The Git reference of target branch for the commit. For more information, see “Git References” in the Git documentation.
SHA of commit with autofix.
Examples
{ "target_ref": "refs/heads/main", "sha": "178f4f6090b3fccad4a65b3e83d076a622d59652"}Bad Request
Basic Error
object
Examples
{ "message": "The alert_number is not valid", "documentation_url": "https://docs.github.com/rest/code-scanning/code-scanning#get-the-status-of-an-autofix-for-a-code-scanning-alert", "status": "400"}Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Resource not found
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Unprocessable Entity
Service unavailable
object
Example generated
{ "code": "example", "message": "example", "documentation_url": "example"}