# Code hotspots

```
GET /api/v1/sources/{id}/code-hotspots
```

The lines of your code that raised a source's open issues lately, grouped by file and line, busiest first. It's what the
[VS Code extension](https://tailcove.dev/docs/editor) reads to mark lines in the editor. Requires the `issues:read` ability.

Only open issues seen in the window are read, and only those whose exception carried a `location`. The path is made
relative to your repository with the source's [code links](https://tailcove.dev/docs/code-links) settings (its path prefixes, then the usual
roots); a minified browser file is placed through its uploaded source map. A location that can't be placed (a library
file, a path under no prefix, a minified file with no map) is left out.

## Query parameters

| Parameter | Type    | Default | Notes                                                                                |
| --------- | ------- | ------- | ------------------------------------------------------------------------------------ |
| `days`    | integer | 7       | How far back, from `1` to `30`. Anything else is a `422`.                            |
| `path`    | string  | none    | One file, relative to the repository: `app/Jobs/ChargeCard.php`. Must match exactly. |

## Example

```bash
curl -G https://tailcove.dev/api/v1/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/code-hotspots \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  --data-urlencode "path=app/Jobs/ChargeCard.php"
```

```json
{
    "data": [
        {
            "path": "app/Jobs/ChargeCard.php",
            "line": 42,
            "occurrences": 214,
            "last_seen": "2026-11-30T11:00:00.000Z",
            "commit": "4f1c2e9a7b3d5c8e0f2a4b6c8d0e1f3a5b7c9d1e",
            "issues": [
                {
                    "id": "iss_01jbx5qa3v7n9p2r4s6t8v0w1x",
                    "title": "CardDeclined: insufficient funds",
                    "occurrences": 200,
                    "last_seen": "2026-11-30T10:00:00.000Z",
                    "url": "https://tailcove.dev/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/issues/iss_01jbx5qa3v7n9p2r4s6t8v0w1x"
                },
                {
                    "id": "iss_01jbx5qb8c2d4f6g8h0j2k4m6n",
                    "title": "TimeoutException: payment gateway timed out",
                    "occurrences": 14,
                    "last_seen": "2026-11-30T11:00:00.000Z",
                    "url": "https://tailcove.dev/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/issues/iss_01jbx5qb8c2d4f6g8h0j2k4m6n"
                }
            ]
        }
    ],
    "meta": {
        "source_id": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
        "days": 7,
        "from": "2026-11-23T12:00:00.000Z",
        "to": "2026-11-30T12:00:00.000Z",
        "truncated": false,
        "unmatched": {
            "count": 2,
            "examples": [
                "/srv/shop/releases/42/app/Http/Controllers/CartController.php"
            ]
        },
        "code_links_url": "https://tailcove.dev/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/settings?team=team_01jbx5q8k7m3n2p4r6s8t0v1w4#code-links"
    }
}
```

## Fields

- `occurrences` on a line is the sum of its issues' occurrences in the window. Each issue's count comes from the logs
  you still keep, so a window longer than the source's retention counts only what's left.
- `line` is `null` when the client sent a file with no line number.
- `commit` is the commit of the last [deploy](https://tailcove.dev/docs/deploy-checks) recorded with one before the line's latest error, so
  the line number is that commit's. Diff it against your checkout to find where the line is now. It's `null` when no
  deploy with a commit came before.
- `unmatched` counts the issues raised in your own code whose path no prefix or root turned into a repository path,
  with up to three of those paths as your client sent them. Libraries and the runtime's own frames aren't counted. When
  it's above zero, add the part before your repository's path as a prefix on the Code links card, which
  `code_links_url` opens.
- The keys are snake_case, like the other answers the command line and the extension read.
- `truncated` is `true` when there was more than one answer holds: at most 2,000 issues are read (the busiest) and 500
  lines are returned.

A token from another team, or a source outside your client groups, gets a `404`, the same as a source that doesn't
exist.
