Skip to content

View permission points of the current member's repository

GET /api/v5/repos/{owner}/{repo}/collaborators/self-permission

This endpoint queries the role and permission points of the current member in the specified repository. It returns role information and a permission matrix tree that shows the specific operations the member can perform on resources such as project, code, and members.

Supported access tokens

  • AtomGit user access tokens

Anonymous access

This endpoint allows 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)

Response parameters

Field Type Always returned Nullable Description
role_info object Yes — User role
resource_trees object[] Yes — Permission matrix tree of the user

role_info object

Field Type Always returned Nullable Description
role_info.role_uuid string Yes — Role ID
role_info.name string Yes — Role name
role_info.cn_name string Yes — Role name in Chinese
role_info.roles_type integer Yes — Role type
role_info.access_level integer Yes — Role level

resource_trees[] object

Field Type Always returned Nullable Description
resource_trees[].resource_id integer Yes — Resource ID
resource_trees[].name string Yes — Resource name
resource_trees[].cn_name string Yes — Resource name in Chinese
resource_trees[].scope string Yes — Resource identifier
resource_trees[].actions object[] Yes — Permission points
resource_trees[].path string Yes — Permission path
resource_trees[].is_own integer Yes — —
resource_trees[].order_num integer Yes — Sort field
resource_trees[].actions[] object
Field Type Always returned Nullable Description
resource_trees[].actions[].permission_id integer Yes — Permission point ID
resource_trees[].actions[].action string Yes — Permission point
resource_trees[].actions[].name string Yes — Permission point name
resource_trees[].actions[].cn_name string Yes — Permission point name in Chinese
resource_trees[].actions[].selected boolean Yes — Whether the permission is granted

Error responses

The reference documentation does not provide error response examples for this endpoint. The following are the generic error response shapes; the actual field names are those returned by the backend:

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Invalid parameters or the request could not be parsed"
}

401 Unauthenticated

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

HTTP status codes

Status code Description
200 Success (OK)
304 Not modified
401 Authentication required (Requires authentication)
403 Access denied (Forbidden)

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).

This endpoint allows anonymous access, so the examples below do not carry an access token. To view permissions as a specific member, append the query parameter ?access_token=<token>.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/self-permission' \
  -H 'Accept: application/json'

JavaScript

const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/self-permission", {
  headers: {
    "Accept": "application/json",
  },
});

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

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

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/collaborators/self-permission",
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "role_info": {
    "role_uuid": "45a9-276d8e546f1b05f9f98ce1ffdc6",
    "name": "Owner",
    "cn_name": "Administrator",
    "roles_type": 1,
    "access_level": 50
  },
  "resource_trees": [
    {
      "resource_id": 2,
      "name": "repo",
      "cn_name": "Project",
      "scope": "repo",
      "actions": [
        {
          "permission_id": 5,
          "action": "fork",
          "name": "fork",
          "cn_name": "fork",
          "selected": true
        },
        {
          "permission_id": 6,
          "action": "update",
          "name": "update",
          "cn_name": "Update",
          "selected": true
        },
        {
          "permission_id": 7,
          "action": "delete",
          "name": "delete",
          "cn_name": "Delete",
          "selected": true
        }
      ]
    },
    {
      "resource_id": 4,
      "name": "code",
      "cn_name": "Code",
      "scope": "code",
      "actions": [
        {
          "permission_id": 14,
          "action": "push",
          "name": "push",
          "cn_name": "Push",
          "selected": true
        },
        {
          "permission_id": 15,
          "action": "download",
          "name": "download",
          "cn_name": "Download",
          "selected": true
        }
      ]
    },
    {
      "resource_id": 5,
      "name": "member",
      "cn_name": "Member",
      "scope": "member",
      "actions": [
        {
          "permission_id": 16,
          "action": "create",
          "name": "create",
          "cn_name": "Invite",
          "selected": true
        },
        {
          "permission_id": 17,
          "action": "update",
          "name": "update",
          "cn_name": "Update",
          "selected": true
        },
        {
          "permission_id": 18,
          "action": "delete",
          "name": "delete",
          "cn_name": "Remove",
          "selected": true
        }
      ]
    }
  ]
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access token)
400 Invalid parameters or the request could not be parsed
404 Request path not found
405 Request method not supported
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