# Mark files reviewed, or clear the marks.

> Records who marked which file at which head commit.
> https://koi.dog/docs/api/pull-requests/mark-pull-request-files-reviewed/

`PUT /api/v1/pull-requests/{id}/files/reviewed` · Scope: `crews`

`headSha` must be the pull request's head as GitHub has it now (`409 head_moved` otherwise, with `next` to read the files again); a path the pull request does not change answers `422`. Marking a file that is already marked, or clearing one that is not, changes nothing.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The pull request's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `headSha` | `string` | yes | The head commit the files were read at; refused when the pull request has moved since. Matches `^[0-9a-f]{40}$`. |
| `paths` | `array` | yes | The files to mark or clear, by their path in the pull request. 1 to 500 items. |
| `reviewed` | `boolean` | yes | true marks them reviewed; false clears the marks. |

## Response.

200 OK · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X PUT "https://api.koi.dog/api/v1/pull-requests/$ID/files/reviewed" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "headSha": "<head commit sha>",
      "paths": [
        "src/app.ts"
      ],
      "reviewed": true
    }'
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/pull-requests/${process.env.ID}/files/reviewed`, {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    headSha: "<head commit sha>",
    paths: [
      "src/app.ts",
    ],
    reviewed: true,
  }),
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.put(
    f"https://api.koi.dog/api/v1/pull-requests/{os.environ['ID']}/files/reviewed",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    json={
        "headSha": "<head commit sha>",
        "paths": [
            "src/app.ts",
        ],
        "reviewed": True,
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "headSha": "string",
  "reviewed": 0,
  "total": 0,
  "changed": []
}
```
