# Group and project access requests API > 原文:[https://docs.gitlab.com/ee/api/access_requests.html](https://docs.gitlab.com/ee/api/access_requests.html) * [Valid access levels](#valid-access-levels) * [List access requests for a group or project](#list-access-requests-for-a-group-or-project) * [Request access to a group or project](#request-access-to-a-group-or-project) * [Approve an access request](#approve-an-access-request) * [Deny an access request](#deny-an-access-request) # Group and project access requests API[](#group-and-project-access-requests-api "Permalink") **注意:**此功能是在 GitLab 8.11 中引入的 ## Valid access levels[](#valid-access-levels "Permalink") 访问级别在`Gitlab::Access`模块中定义. 当前,这些级别被认可: * 无法访问( `0` ) * 宾客( `10` ) * 记者( `20` ) * 显影剂( `30` ) * 养护者( `40` ) * 所有者( `50` )-仅对组有效 ## List access requests for a group or project[](#list-access-requests-for-a-group-or-project "Permalink") 获取认证用户可见的访问请求列表. ``` GET /groups/:id/access_requests GET /projects/:id/access_requests ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | 请求示例: ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/:id/access_requests" curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/:id/access_requests" ``` 响应示例: ``` [ { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" }, { "id": 2, "username": "john_doe", "name": "John Doe", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" } ] ``` ## Request access to a group or project[](#request-access-to-a-group-or-project "Permalink") 请求已验证用户访问组或项目. ``` POST /groups/:id/access_requests POST /projects/:id/access_requests ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | 请求示例: ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/:id/access_requests" curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/:id/access_requests" ``` 响应示例: ``` { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "requested_at": "2012-10-22T14:13:35Z" } ``` ## Approve an access request[](#approve-an-access-request "Permalink") 批准给定用户的访问请求. ``` PUT /groups/:id/access_requests/:user_id/approve PUT /projects/:id/access_requests/:user_id/approve ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `user_id` | integer | yes | 访问请求者的用户标识 | | `access_level` | integer | no | 有效的访问级别(默认值: `30` ,开发人员访问级别) | 请求示例: ``` curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/:id/access_requests/:user_id/approve?access_level=20" curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/:id/access_requests/:user_id/approve?access_level=20" ``` 响应示例: ``` { "id": 1, "username": "raymond_smith", "name": "Raymond Smith", "state": "active", "created_at": "2012-10-22T14:13:35Z", "access_level": 20 } ``` ## Deny an access request[](#deny-an-access-request "Permalink") 拒绝给定用户的访问请求. ``` DELETE /groups/:id/access_requests/:user_id DELETE /projects/:id/access_requests/:user_id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `user_id` | integer | yes | 访问请求者的用户标识 | 请求示例: ``` curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/:id/access_requests/:user_id" curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/:id/access_requests/:user_id" ```