Skip to content

Assign users to review a pull request

POST /api/v5/repos/{owner}/{repo}/pulls/{number}/reviewers

Assigns users as reviewers for a pull request in the specified repository, supporting both adding reviewers and overwriting the reviewer list, and returning the reviewer information after assignment.

Supported access tokens

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Namespace address to which the repository belongs (address path of the enterprise, organization, or user)
repo path string Yes Repository path (path)
number path string Yes Which PR it is, that is, the ordinal number of the PR in this repository, corresponding to iid
access_token query string Yes User authorization code

Request Body:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "reviewers": {
      "description": "Personal namespace addresses of users, separated by commas",
      "type": "string"
    },
    "add": {
      "description": "Whether to add reviewers; true adds reviewers, false overwrites the reviewers",
      "type": "boolean",
      "default": false
    }
  },
  "required": ["reviewers"]
}

Response parameters

The response body is an array of reviewer objects, where each element is one reviewer's information.

Reviewer object

Field Type Always returned Nullable Description
id integer Yes No User ID
login string Yes No Account (login name)
name string Yes No Nickname
avatar_url string No Yes Avatar URL
object_id string Yes No User object ID

Error response

Callers need to know what error responses look like in order to write error handling. Error field names follow what the backend actually returns.

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "A parameter is missing or has an invalid format"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Parameter error (Bad request)
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden)
404 Resource does not exist (Not found)
500 Internal server error (Internal server error)

Request example

Parameter notes

The example can be used as-is; the placeholders are described below:

replace <owner> with the namespace address to which the repository belongs (address path of the enterprise, organization, or user); replace <repo> with the repository path (path); replace <number> with which PR it is (corresponding to iid); replace <token> with your AtomGit user access token; replace <reviewers> with the personal namespace addresses of the users to assign, separated by commas when there are several.

cURL

curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/reviewers?access_token=<token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"reviewers":"<reviewers>","add":false}'

JavaScript

// Native fetch (Node.js 18+ / browsers)
const response = await fetch(
  "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/reviewers?access_token=<token>",
  {
    method: "POST",
    headers: {
      "Accept": "application/json",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      reviewers: "<reviewers>",
      add: false
    })
  }
);

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.post(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/reviewers",
    params={"access_token": "<token>"},
    json={"reviewers": "<reviewers>", "add": False},
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

[
  {
    "id": 10086,
    "login": "octocat",
    "name": "Octocat",
    "avatar_url": "https://api.atomgit.com/avatars/octocat.png",
    "object_id": "a8f0c2d4e6"
  }
]

Error codes

Error code Description
400 Invalid parameters or unparseable request
401 Unauthenticated or invalid credentials (missing or invalid access credentials)
403 Access forbidden
404 Request path or resource does not exist
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc