Skip to content

Modify enterprise member permissions

PUT /api/v5/enterprises/{enterprise}/members/{username}

This endpoint modifies the role permissions of a member in the specified enterprise. Set the member's role to viewer, tester, developer, maintainer, admin, or a custom role to adjust permissions, and the endpoint returns the updated activation status, role, and user information of the member.

Access token support

  • AtomGit user access tokens

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
enterprise path string Yes Address path of the namespace that owns the repository (address path of the enterprise, organization, or user)
username path string Yes User name (username/login)
access_token query string Yes User authorization code

Request Body:

The request body is a JSON object that sets the member's role in the enterprise.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "role": {
      "description": "Enterprise role (viewer, tester, developer, maintainer, admin, customized for a custom role)",
      "type": "string",
      "enum": ["viewer", "tester", "developer", "maintainer", "admin", "customized"]
    },
    "role_id": {
      "description": "Role ID. If role is set to customized, the role ID must also be passed",
      "type": "string"
    }
  },
  "required": ["role"]
}

Response parameters

Field Type Always returned Nullable Description
active boolean Yes — Whether the member is activated
role string Yes — Role of the member in the enterprise
url string Yes — Member information URL
user object Yes — User information of the member

user object

Field Type Always returned Nullable Description
user.id integer Yes — User ID
user.login string Yes — User name
user.url string Yes — User information URL
user.html_url string Yes — User profile URL

Error responses

Besides the success response, callers also need to know what a failure looks like so that they can write error handling.

400 Parameter error

{
  "error": "invalid_request",
  "message": "The role parameter cannot be empty",
  "field": "role"
}

401 Unauthenticated

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

403 No permission

{
  "error": "forbidden",
  "message": "The current token is not allowed to modify this enterprise member's permissions"
}

404 Not found

{
  "error": "not_found",
  "message": "The enterprise or member does not exist"
}

The actual error field names are those returned by the backend.

HTTP response status codes

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

Request example

Parameter description

Replace <enterprise> with the enterprise path (the address path of an enterprise, organization, or user); replace <username> with the user name (username/login); replace <token> with your AtomGit user access token.

cURL

curl -X PUT 'https://api.atomgit.com/api/v5/enterprises/<enterprise>/members/<username>?access_token=<token>' -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"role":"developer"}'

JavaScript

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

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/enterprises/<enterprise>/members/<username>",
    params={"access_token": "<token>"},
    json={"role": "developer"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "active": true,
  "role": "member",
  "url": "https://api.atomgit.com/api/v5/enterprises/litestabc/members/malongge5",
  "user": {
    "id": 953,
    "login": "malongge5",
    "url": "https://api.atomgit.com/api/v5/malongge5",
    "html_url": "https://api.atomgit.com/malongge5"
  }
}

Error codes

Error code Description
400 Parameter error or the request cannot be parsed
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
403 Forbidden (the current token is not allowed to perform this operation)
404 The request path does not exist
429 Too many requests; the rate limit was triggered
500 Internal system error

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