Skip to content

Add a repository member or update a member's permissions

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

This endpoint adds a repository member or updates a member's permissions. If the target user is not yet a repository member, the user is added as a member; if the target user is already a repository member, their member permission is updated. The permission can be participant (pull), developer (push), or repository maintainer (admin). The updated member information is returned.

Supported access tokens

  • 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 of the repository (address path of the enterprise, organization, or individual)
repo path string Yes Repository path (path)
username path string Yes User name (username/login)
access_token query string Yes User authorization code

Request Body:

The request body is an optional JSON object that currently contains only one optional field, permission.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "permission": {
      "description": "Member permission: participant (pull), developer (push), repository maintainer (admin), or the role name for a custom role. Default: push",
      "type": "string",
      "enum": ["pull", "push", "admin"],
      "default": "push"
    }
  }
}

Response parameters

Field Type Always returned Nullable Description
id string No Yes User ID
login string No Yes Login name (login)
name string No Yes User name (name)
avatar_url string No Yes Avatar URL; may be null
html_url string No Yes User home page URL
remark string No Yes Remark name in the enterprise
type string No Yes User type (such as User)
url string No Yes User URL
followers_url string No Yes Followers list URL
permissions object No Yes Set of permissions the member holds in the repository
memberRole string No Yes Member role name

permissions object

Field Type Always returned Nullable Description
permissions.pull boolean No Yes Whether the member has permission to pull code (pull)
permissions.push boolean No Yes Whether the member has permission to push code (push)
permissions.admin boolean No Yes Whether the member has repository administration permission (admin)

Error responses

The following are examples of the error status codes the endpoint may return; the actual error response body format is that returned by the backend.

400 Invalid parameters

{
  "error": "bad_request",
  "message": "The role does not exist"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Bad credentials"
}

404 The user does not exist

{
  "error": "not_found",
  "message": "user not found"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Invalid parameters (Bad request)
401 Authentication required (Requires authentication)
403 Access denied (Forbidden)
404 The user does not exist (Not found)
429 Rate limit exceeded (Too many requests)
500 Internal server error

Request example

Parameter notes

Replace <owner> with the namespace address of the repository (address path of the enterprise, organization, or individual); replace <repo> with the repository path (path); replace <username> with the user name of the target user (username/login); replace <token> with your AtomGit user access token.

cURL

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

JavaScript

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

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

print(resp.json())

Response example

Status code: 200

{
  "id": "7543745",
  "login": "centking",
  "name": "Zhan Fen",
  "avatar_url": null,
  "html_url": "https://api.atomgit.com/centking",
  "remark": "",
  "type": "User",
  "permissions": {
    "pull": true,
    "push": true,
    "admin": false
  }
}

Error codes

Error code Description
400 Invalid parameters or an unparsable request (for example, the role does not exist)
401 Unauthenticated or invalid credentials (missing or invalid access token)
403 Access denied (the current token has no permission to operate on this repository member)
404 The user does not exist, or the request path does not exist
429 Too many requests; rate limit triggered
500 Internal server error

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