Skip to content

Modify project code approval settings

PUT /api/v5/repos/{owner}/{repo}/reviewer

Call this endpoint to modify the project code approval settings.

Supported access tokens

  • AtomGit user access tokens

Anonymous access allowed

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 organization or user)
repo path string Yes Repository path (path)
access_token query string Yes User authorization code

Request Body:

The request body is a JSON object that sets the code review and test rules.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "assignees": {
      "description": "Usernames of the reviewers; multiple names are separated by commas, for example: (username1,username2)",
      "type": "string"
    },
    "testers": {
      "description": "Usernames of the testers; multiple names are separated by commas, for example: (username1,username2)",
      "type": "string"
    },
    "assignees_number": {
      "description": "Minimum number of reviewers",
      "type": "integer"
    },
    "testers_number": {
      "description": "Minimum number of testers",
      "type": "integer"
    }
  }
}

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Code approval settings ID
created_at string Yes No Creation time
updated_at string Yes No Update time

Error response

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Invalid parameters"
}

401 Unauthenticated

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

HTTP status codes

Status code Description
200 Success (OK)
400 Invalid parameters (Bad request)
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden)
404 Request path does not exist (Not found)

Request example

Parameter notes

Replace <owner> with the namespace address to which the repository belongs (address path of the organization or user); replace <repo> with the repository path (path); replace <token> with your AtomGit user access token.

cURL

curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/reviewer?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -d '{"assignees":"username1,username2","testers":"username3","assignees_number":1,"testers_number":1}'

JavaScript

// Native fetch (Node.js 18+ / browsers)
const response = await fetch(
  "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/reviewer?access_token=<token>",
  {
    method: "PUT",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json",
    },
    body: JSON.stringify({
      assignees: "username1,username2",
      testers: "username3",
      assignees_number: 1,
      testers_number: 1,
    }),
  }
);

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

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

Python

import requests

resp = requests.put(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/reviewer",
    params={"access_token": "<token>"},
    json={
        "assignees": "username1,username2",
        "testers": "username3",
        "assignees_number": 1,
        "testers_number": 1,
    },
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 7543745,
  "created_at": "2024-01-24T14:33:44+08:00",
  "updated_at": "2024-04-07T21:23:08+08:00"
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access credentials)
400 Invalid parameters or the request cannot be parsed
404 Request path does not exist
405 Request method not supported
429 Too many requests; rate limit triggered
500 Internal system error

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