Skip to content

Update project member roles

PUT /api/v5/repos/{owner}/{repo}/members/{username}

This endpoint updates the role permissions of the specified member in the specified repository. Set permission levels such as participant, developer, maintainer, or custom role to adjust the member's operation permissions in the repository. On success, the user information of the member and the updated permission configuration are returned.

Access token support

  • AtomGit user 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 Address path of the namespace the repository belongs to (the address path of an enterprise, organization, or individual)
repo path string Yes Repository path (path)
username path string Yes User name of the project member
access_token query string Yes User authorization code

Request Body:

The request body is a JSON object that specifies the new role of the member.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "permission": {
      "description": "Member permission: participant (pull), developer (push), maintainer (admin), customized (custom role); default push",
      "type": "string",
      "enum": ["pull", "push", "admin", "customized"],
      "default": "push"
    },
    "role_id": {
      "description": "Role ID; required when permission is customized",
      "type": "string"
    }
  }
}

Response parameters

Field Type Always returned Nullable Description
followers_url string Yes No User followers list address
html_url string Yes No User homepage address
id string Yes No User ID
login string Yes No User name (login name)
name string Yes No User nickname
type string Yes No User type
url string Yes No User API address
permissions object Yes No Member permission information

permissions object

Field Type Always returned Nullable Description
permissions.admin boolean Yes No Whether the member has maintainer (admin) permission
permissions.push boolean Yes No Whether the member has developer (push) permission
permissions.customized boolean Yes No Whether the member has custom role (customized) permission
permissions.pull boolean Yes No Whether the member has participant (pull) permission

Note: In the reference documentation's schema, the permissions fields are marked as integer, whereas the actual response values are boolean (true/false).

Error response

A success response alone is not enough: callers need to know what a failure looks like in order to write error handling.

401 Unauthenticated

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

400 Parameter error

{
  "error": "invalid_request",
  "message": "Invalid value for permission"
}

Note: The actual error field names in the failure responses above are subject to what the backend returns.

HTTP response status codes

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

Request example

Parameter description

Replace <owner> with the address path of the namespace the repository belongs to (the address path of an enterprise, organization, or individual);
replace <repo> with the repository path (path);
replace <username> with the user name of the project member;
replace <token> with your AtomGit user access token;
replace <role_id> with the custom role ID (required when permission is customized).

cURL

curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/members/<username>?access_token=<token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"permission": "customized", "role_id": "<role_id>"}'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/members/<username>?access_token=<token>", {
  method: "PUT",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    permission: "customized",
    role_id: "<role_id>",
  }),
});

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>/members/<username>?access_token=<token>",
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
    },
    json={
        "permission": "customized",
        "role_id": "<role_id>",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "followers_url": "https://api.atomgit.com/api/v5/users/xiaogang2/followers",
  "html_url": "https://api.atomgit.com/xiaogang2",
  "id": "65ffca965079ba0d1c00f6f2",
  "login": "xiaogang2",
  "name": "Xiao Gang 2",
  "type": "User",
  "url": "https://api.atomgit.com/api/v5/xiaogang2",
  "permissions": {
    "admin": false,
    "push": false,
    "customized": true,
    "pull": false
  }
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Parameter error or the request cannot be parsed
403 Forbidden
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