Sample - GitHub REST API
POST/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix

Create an autofix for a code scanning alert

Creates an autofix for a code scanning alert on a repository's default branch. Supply owner, repo, and alert_number to identify the repository and alert, and use the required authorization scope for the repository's visibility. A 202 response indicates that an autofix is being generated or newly created, while a 200 response indicates that an autofix already exists.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.
alert_numberintegerrequired
The integer identifying the code scanning alert, available in the alert URL and the `number` field returned by the code scanning alerts operation.

7 status codes
200Returns an existing autofix object containing its `status`, description, and `started_at` timestamp. The `status` is one of `pending`, `error`, `success`, or `outdated`.
statusstringrequired
The status of an autofix.
Allowed:pendingerrorsuccessoutdated
descriptionstringrequired
The description of an autofix.
started_atstringrequired
The start time of an autofix in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.
202Returns an autofix object for a newly created or currently generating autofix, containing its `status`, description, and `started_at` timestamp. The `status` is one of `pending`, `error`, `success`, or `outdated`.
statusstringrequired
The status of an autofix.
Allowed:pendingerrorsuccessoutdated
descriptionstringrequired
The description of an autofix.
started_atstringrequired
The start time of an autofix in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.
400Returned when the request is invalid. The response contains a basic error object with fields such as `message`, `documentation_url`, `url`, and `status`.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
403Returned when the repository is archived, GitHub Advanced Security is not enabled for the repository, or the rate limit is exceeded. The response contains a basic error object.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the requested resource is not found. The response contains a basic error object.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when the request cannot be processed because it is unprocessable.
500Returned when an internal error occurs. The response contains a basic error object.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional

Error handling

A 400 is returned when the request is invalid, a 403 is returned when the repository is archived, GitHub Advanced Security is disabled, or the rate limit is exceeded, and a 404 is returned when the requested resource is not found. A 422 is returned for an unprocessable request, and a 500 indicates an internal error. For private or public repositories, OAuth app tokens and personal access tokens (classic) need the security_events scope; use public_repo for public repositories only.