# Get a code scanning alert

From **GitHub v3 REST API**.

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

Gets a single code scanning alert. You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint.

**Deprecation notice**:
The instances field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The same information can now be retrieved via a GET request to the URL specified by `instances_url`.

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

### `alert_number`

- Location: path
- Required: true
- Type: `integer`

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.

## Responses

### `200`

Response

### `application/json`

- Type: `object`

```json
{
  "created_at": "2020-06-19T11:21:34Z",
  "dismissed_at": "2020-02-14T12:29:18Z",
  "dismissed_by": {
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "events_url": "https://api.github.com/users/octocat/events{/privacy}",
    "followers_url": "https://api.github.com/users/octocat/followers",
    "following_url": "https://api.github.com/users/octocat/following{/other_user}",
    "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
    "gravatar_id": "",
    "html_url": "https://github.com/octocat",
    "id": 54933897,
    "login": "octocat",
    "node_id": "MDQ6VXNlcjE=",
    "organizations_url": "https://api.github.com/users/octocat/orgs",
    "received_events_url": "https://api.github.com/users/octocat/received_events",
    "repos_url": "https://api.github.com/users/octocat/repos",
    "site_admin": false,
    "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
    "type": "User",
    "url": "https://api.github.com/users/octocat"
  },
  "dismissed_reason": "false positive",
  "html_url": "https://github.com/octocat/hello-world/code-scanning/42",
  "instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42/instances",
  "most_recent_instance": {
    "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
    "classifications": [
      "test"
    ],
    "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
    "environment": "{}",
    "location": {
      "end_column": 18,
      "end_line": 917,
      "path": "spec-main/api-session-spec.ts",
      "start_column": 7,
      "start_line": 917
    },
    "message": {
      "text": "This path depends on a user-provided value."
    },
    "ref": "refs/heads/main",
    "state": "dismissed"
  },
  "number": 42,
  "rule": {
    "description": "Arbitrary file write during zip extraction (\"Zip Slip\")",
    "full_description": "Extracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten.",
    "help": "# Arbitrary file write during zip extraction (\"Zip Slip\")\\nExtracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten ...",
    "id": "js/zipslip",
    "name": "js/zipslip",
    "severity": "error",
    "tags": [
      "security",
      "external/cwe/cwe-022"
    ]
  },
  "state": "dismissed",
  "tool": {
    "guid": null,
    "name": "CodeQL",
    "version": "2.4.0"
  },
  "url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42"
}
```

```json
{"properties":{"created_at":{"$ref":"#/components/schemas/alert-created-at"},"dismissed_at":{"$ref":"#/components/schemas/code-scanning-alert-dismissed-at"},"dismissed_by":{"$ref":"#/components/schemas/nullable-simple-user"},"dismissed_reason":{"$ref":"#/components/schemas/code-scanning-alert-dismissed-reason"},"html_url":{"$ref":"#/components/schemas/alert-html-url"},"instances":{"deprecated":true},"instances_url":{"$ref":"#/components/schemas/alert-instances-url"},"most_recent_instance":{"$ref":"#/components/schemas/code-scanning-alert-instance"},"number":{"$ref":"#/components/schemas/alert-number"},"rule":{"$ref":"#/components/schemas/code-scanning-alert-rule"},"state":{"$ref":"#/components/schemas/code-scanning-alert-state"},"tool":{"$ref":"#/components/schemas/code-scanning-analysis-tool"},"url":{"$ref":"#/components/schemas/alert-url"}},"required":["number","created_at","url","html_url","instances_url","state","dismissed_by","dismissed_at","dismissed_reason","rule","tool","most_recent_instance"],"type":"object"}
```

### `403`

Response if GitHub Advanced Security is not enabled for this repository

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `404`

Resource not found

### `application/json`

- Type: `object`

Basic Error

```json
{"description":"Basic Error","properties":{"documentation_url":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"}},"title":"Basic Error","type":"object"}
```

### `503`

Service unavailable

### `application/json`

- Type: `object`

```json
{"properties":{"code":{"type":"string"},"documentation_url":{"type":"string"},"message":{"type":"string"}},"type":"object"}
```

## Request examples

### cURL

```shell
curl --request GET \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
```
