---
title: Review a pull request
description: Start a review of a pull request's head commit.
url: https://www.hacktron.ai/docs/api/pull-requests/review-pull-request
---

# Review a pull request

Starts a [review](/docs/review) of a pull or merge request, as if a repository member commented `@hacktronai review` on it. The review runs on the head commit and posts on the pull request as your [PR review settings](/docs/api/repos/get-pr-review-settings) say: `posts_comments` and `posts_check_status` report what it will post. You need the member role or above.

When the head commit already has a review, Hacktron returns that one instead of starting another, with `status` set to `in_progress` or `already_reviewed`.

- A closed or merged pull request returns `409 Conflict`.
- A review that can't run returns `422 Unprocessable Entity`, with the reason in `message`. You can retry a failed start.

Follow the review with [`GET /scans/{id}/status`](/docs/api/scans/get-scan-status), using `scan_id`.

## Request

`POST /pull-requests/review`

Send an [API key](/docs/api/authentication) with the `write` scope in the `X-Api-Key` header.

:::examples

```bash title="Request" wrap=false
curl -X POST "https://api.hacktron.ai/v1/pull-requests/review" \
  -H "X-Api-Key: $HACKTRON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "pr_url": "https://github.com/acme/api/pull/42"
}'
```

```json title="Response 200 OK" showLineNumbers=false wrap=false
{
  "status": "started",
  "scan_id": "6f1c2d3e-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
  "task_id": "string",
  "repository": "acme/api",
  "number": 42,
  "url": "https://github.com/acme/api/pull/42",
  "posts_comments": true,
  "posts_check_status": true
}
```

:::

### Body

A required `application/json` body.

| Field | Type | Description |
| --- | --- | --- |
| `pr_url` | string, required | The pull or merge request's web link. |

## Responses

### 200 OK

| Field | Type | Description |
| --- | --- | --- |
| `status` | string, required | started, or in_progress / already_reviewed when a review of the head commit already exists. One of `started`, `in_progress`, or `already_reviewed`. |
| `scan_id` | string (uuid), required, nullable | Scan id, for the scans routes. |
| `task_id` | string, required | |
| `repository` | string, required | |
| `number` | number, required | |
| `url` | string, required | |
| `posts_comments` | boolean, required | Whether findings are posted as comments on the pull request (the organisation's scm_comments_enabled). |
| `posts_check_status` | boolean, required | Whether the review shows as a check or status on the pull request (scm_check_statuses_enabled). |

### 400 Bad Request

Not a pull request link, a repository not enabled for Hacktron, or a GitHub repository connected with a personal access token.

### 404 Not Found

The pull request, or its repository in the organization, wasn't found.

### 409 Conflict

The pull request is closed or merged.

### 422 Unprocessable Entity

The review could not run; the message says why. A failed start can be retried.

### 503 Service Unavailable

The repository's provider could not be read; try again later.
