Modify enterprise member permissions¶
PUT /api/v8/enterprises/{enterprise}/members/{username}
Call this endpoint to modify the access permission (role) of a member in the specified enterprise.
Supported access tokens¶
- AtomGit user access tokens
Anonymous access allowed¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
enterprise |
path | string | Yes | Enterprise ID (also accepts the address path of an enterprise, organization, or user) |
username |
path | string | Yes | Username (username/login) |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body can be sent as application/json (fields in snake_case) or as an application/x-www-form-urlencoded / multipart/form-data form.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"role": {
"description": "Enterprise role; enum: `viewer` (viewer), `tester` (tester), `developer` (developer), `maintainer` (maintainer), `admin` (administrator), `customized` (custom role)",
"type": "string",
"enum": ["viewer", "tester", "developer", "maintainer", "admin", "customized"]
},
"role_id": {
"description": "Role ID; required when `role` is `customized`",
"type": "string"
}
},
"required": ["role"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
active |
boolean | Yes | Yes | Whether the member is in a valid state (derived by comparing the membership expiry with the current time) |
organization |
object | No | Yes | Enterprise (organization) information |
organization_url |
string | No | Yes | Enterprise (organization) URL |
remark |
string | Yes | Yes | Remark; currently returns null |
role |
string | Yes | Yes | Member role name (such as member / admin) |
url |
string | Yes | No | URL of the member within the current enterprise |
user |
object | Yes | No | Member user information |
organization object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
organization.id |
integer | No | Yes | Enterprise (organization) ID |
organization.login |
string | No | Yes | Enterprise (organization) login name |
organization.name |
string | No | Yes | Enterprise (organization) name |
organization.url |
string | No | Yes | Enterprise (organization) URL |
organization.avatar_url |
string | No | Yes | Enterprise (organization) avatar URL |
organization.repos_url |
string | No | Yes | Enterprise (organization) repository list URL |
organization.events_url |
string | No | Yes | Enterprise (organization) activity URL |
organization.members_url |
string | No | Yes | Enterprise (organization) member list URL |
organization.description |
string | No | Yes | Enterprise (organization) description |
organization.follow_count |
integer | No | Yes | Number of followers |
user object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
user.id |
integer | Yes | No | User ID |
user.login |
string | Yes | No | Username (username/login) |
user.name |
string | No | Yes | User nickname |
user.avatar_url |
string | No | Yes | User avatar URL |
user.url |
string | Yes | No | User URL |
user.html_url |
string | Yes | No | User profile URL |
user.remark |
string | Yes | Yes | Remark; currently returns null |
Error response¶
400 Invalid parameters
Returned when the role value is not one of viewer / tester / developer / maintainer / admin / customized.
404 User does not exist
Returned when the user corresponding to the specified username does not exist.
401 Unauthenticated
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Invalid parameters (Bad Request) |
401 |
Authentication required (Requires authentication) |
404 |
Resource does not exist (Not Found) |
Request example¶
Parameter notes¶
Replace
<enterprise>with the enterprise ID (or the address path of an enterprise, organization, or user); replace<username>with the username (username/login) of the target member; replace<token>with your AtomGit user access token.
cURL¶
curl -X PUT 'https://api.atomgit.com/api/v8/enterprises/<enterprise>/members/<username>?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{"role": "maintainer", "role_id": ""}'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch(
"https://api.atomgit.com/api/v8/enterprises/<enterprise>/members/<username>?access_token=<token>",
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
role: "maintainer",
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/v8/enterprises/<enterprise>/members/<username>",
params={"access_token": "<token>"},
json={
"role": "maintainer",
"role_id": "",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"active": true,
"role": "admin",
"url": "https://api.atomgit.com/api/v8/enterprises/litestabc/members/malongge5",
"user": {
"id": 953,
"login": "malongge5",
"name": "Ma Longge",
"avatar_url": "https://api.atomgit.com/avatar.png",
"url": "https://api.atomgit.com/api/v5/malongge5",
"html_url": "https://api.atomgit.com/malongge5"
}
}
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 or user 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