2020-10-28 15:08:49 +00:00
---
2020-12-14 21:09:47 +00:00
stage: Manage
group: Access
2020-11-26 06:09:20 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-28 15:08:49 +00:00
---
2021-09-16 00:11:46 +00:00
# Group and project members API **(FREE)**
2016-06-23 15:14:31 +00:00
2020-07-09 18:10:09 +00:00
## Valid access levels
2016-06-23 15:14:31 +00:00
The access levels are defined in the `Gitlab::Access` module. Currently, these levels are recognized:
2020-06-08 21:09:17 +00:00
- No access (`0`)
2020-12-14 21:09:47 +00:00
- Minimal access (`5`) ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/220203) in GitLab 13.5.)
2020-06-08 21:09:17 +00:00
- Guest (`10`)
- Reporter (`20`)
- Developer (`30`)
- Maintainer (`40`)
- Owner (`50`) - Only valid to set for groups
2020-12-04 21:09:29 +00:00
WARNING:
2020-06-08 21:09:17 +00:00
Due to [an issue ](https://gitlab.com/gitlab-org/gitlab/-/issues/219299 ),
2020-11-19 21:09:07 +00:00
projects in personal namespaces don't show owner (`50`) permission
2020-06-08 21:09:17 +00:00
for owner.
2016-06-23 15:14:31 +00:00
2020-07-24 18:09:45 +00:00
## Limitations
The `group_saml_identity` attribute is only visible to a group owner for [SSO enabled groups ](../user/group/saml_sso/index.md ).
2021-08-06 18:09:57 +00:00
The `email` attribute is only visible for users with public emails.
2020-07-24 18:09:45 +00:00
2016-06-23 15:14:31 +00:00
## List all members of a group or project
Gets a list of group or project members viewable by the authenticated user.
2018-09-28 10:45:43 +00:00
Returns only direct members and not inherited members through ancestors groups.
2016-06-23 15:14:31 +00:00
2020-03-03 00:08:11 +00:00
This function takes pagination parameters `page` and `per_page` to restrict the list of users.
2020-02-27 09:09:01 +00:00
```plaintext
2016-06-23 15:14:31 +00:00
GET /groups/:id/members
GET /projects/:id/members
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-06-23 15:14:31 +00:00
| `query` | string | no | A query string to search for members |
2019-10-16 18:08:01 +00:00
| `user_ids` | array of integers | no | Filter the results on the given user IDs |
2016-06-23 15:14:31 +00:00
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members"
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members"
2016-06-23 15:14:31 +00:00
```
Example response:
```json
[
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
2018-07-25 21:45:42 +00:00
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 30,
"group_saml_identity": null
2016-06-23 15:14:31 +00:00
},
{
"id": 2,
"username": "john_doe",
"name": "John Doe",
"state": "active",
2018-07-25 21:45:42 +00:00
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 30,
2020-05-26 18:08:20 +00:00
"email": "john@example.com",
2020-02-24 00:09:02 +00:00
"group_saml_identity": {
"extern_uid":"ABC-1234567890",
"provider": "group_saml",
"saml_provider_id": 10
}
2018-07-25 21:45:42 +00:00
}
]
```
## List all members of a group or project including inherited members
2020-09-18 00:09:39 +00:00
Gets a list of group or project members viewable by the authenticated user, including inherited members and permissions through ancestor groups.
2021-04-05 12:09:17 +00:00
If a user is a member of this group or project and also of one or more ancestor groups,
only its membership with the highest `access_level` is returned.
2021-09-16 00:11:46 +00:00
([Improved](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56677) in GitLab 13.11.)
2021-03-30 15:11:08 +00:00
This represents the effective permission of the user.
2018-07-25 21:45:42 +00:00
2020-03-03 00:08:11 +00:00
This function takes pagination parameters `page` and `per_page` to restrict the list of users.
2020-02-27 09:09:01 +00:00
```plaintext
2018-07-25 21:45:42 +00:00
GET /groups/:id/members/all
GET /projects/:id/members/all
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2018-07-25 21:45:42 +00:00
| `query` | string | no | A query string to search for members |
2019-10-16 18:08:01 +00:00
| `user_ids` | array of integers | no | Filter the results on the given user IDs |
2018-07-25 21:45:42 +00:00
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/all"
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members/all"
2018-07-25 21:45:42 +00:00
```
Example response:
```json
[
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 30,
"group_saml_identity": null
2018-07-25 21:45:42 +00:00
},
{
"id": 2,
"username": "john_doe",
"name": "John Doe",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2021-04-29 12:09:58 +00:00
"access_level": 30,
2020-05-26 18:08:20 +00:00
"email": "john@example.com",
2020-02-24 00:09:02 +00:00
"group_saml_identity": {
"extern_uid":"ABC-1234567890",
"provider": "group_saml",
"saml_provider_id": 10
}
2018-07-25 21:45:42 +00:00
},
{
"id": 3,
"username": "foo_bar",
"name": "Foo bar",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-11-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 30,
"group_saml_identity": null
2016-06-23 15:14:31 +00:00
}
]
```
## Get a member of a group or project
2019-10-16 18:08:01 +00:00
Gets a member of a group or project. Returns only direct members and not inherited members through ancestor groups.
2016-06-23 15:14:31 +00:00
2020-02-27 09:09:01 +00:00
```plaintext
2016-06-23 15:14:31 +00:00
GET /groups/:id/members/:user_id
GET /projects/:id/members/:user_id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-06-23 15:14:31 +00:00
| `user_id` | integer | yes | The user ID of the member |
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/:user_id"
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members/:user_id"
2016-06-23 15:14:31 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
2018-07-25 21:45:42 +00:00
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
2016-08-18 14:49:32 +00:00
"access_level": 30,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-10-15 21:09:12 +00:00
"created_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"expires_at": null,
"group_saml_identity": null
2016-06-23 15:14:31 +00:00
}
```
2019-10-16 18:08:01 +00:00
## Get a member of a group or project, including inherited members
2020-02-06 15:09:11 +00:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/17744) in GitLab 12.4.
2019-10-16 18:08:01 +00:00
Gets a member of a group or project, including members inherited through ancestor groups. See the corresponding [endpoint to list all inherited members ](#list-all-members-of-a-group-or-project-including-inherited-members ) for details.
2020-02-27 09:09:01 +00:00
```plaintext
2019-10-16 18:08:01 +00:00
GET /groups/:id/members/all/:user_id
GET /projects/:id/members/all/:user_id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-10-16 18:08:01 +00:00
| `user_id` | integer | yes | The user ID of the member |
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/all/:user_id"
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members/all/:user_id"
2019-10-16 18:08:01 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"access_level": 30,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-02-24 00:09:02 +00:00
"expires_at": null,
"group_saml_identity": null
2019-10-16 18:08:01 +00:00
}
```
2020-09-30 09:10:11 +00:00
## List all billable members of a group
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217384) in GitLab 13.5.
2020-10-09 15:09:18 +00:00
Gets a list of group members that count as billable. The list includes members in the subgroup or subproject.
2021-03-05 09:09:07 +00:00
This API endpoint works on top-level groups only. It does not work on subgroups.
2020-10-09 15:09:18 +00:00
NOTE:
Unlike other API endpoints, billable members is updated once per day at 12:00 UTC.
2020-09-30 09:10:11 +00:00
2021-06-28 15:08:03 +00:00
This function takes [pagination ](index.md#pagination ) parameters `page` and `per_page` to restrict the list of users.
2020-09-30 09:10:11 +00:00
2020-12-07 00:09:53 +00:00
[Introduced ](https://gitlab.com/gitlab-org/gitlab/-/issues/262875 ) in GitLab 13.7, the `search` and
`sort` parameters allow you to search for billable group members by name and sort the results,
respectively.
2020-09-30 09:10:11 +00:00
```plaintext
GET /groups/:id/billable_members
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2020-12-07 00:09:53 +00:00
| `search` | string | no | A query string to search for group members by name, username, or email. |
| `sort` | string | no | A query string containing parameters that specify the sort attribute and order. See supported values below.|
The supported values for the `sort` attribute are:
2021-06-28 18:08:39 +00:00
| Value | Description |
| ----------------------- | ---------------------------- |
| `access_level_asc` | Access level, ascending |
| `access_level_desc` | Access level, descending |
| `last_joined` | Last joined |
| `name_asc` | Name, ascending |
| `name_desc` | Name, descending |
| `oldest_joined` | Oldest joined |
| `oldest_sign_in` | Oldest sign in |
| `recent_sign_in` | Recent sign in |
| `last_activity_on_asc` | Last active date, ascending |
| `last_activity_on_desc` | Last active date, descending |
2020-09-30 09:10:11 +00:00
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/billable_members"
```
Example response:
```json
[
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
2021-05-11 15:10:20 +00:00
"last_activity_on": "2021-01-27",
2021-05-12 18:10:35 +00:00
"membership_type": "group_member",
2021-08-02 09:10:09 +00:00
"removable": true,
"created_at": "2021-01-03T12:16:02.000Z"
2020-09-30 09:10:11 +00:00
},
{
"id": 2,
"username": "john_doe",
"name": "John Doe",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
2021-02-01 09:09:28 +00:00
"email": "john@example.com",
2021-05-11 15:10:20 +00:00
"last_activity_on": "2021-01-25",
2021-05-12 18:10:35 +00:00
"membership_type": "group_member",
2021-08-02 09:10:09 +00:00
"removable": true,
"created_at": "2021-01-04T18:46:42.000Z"
2020-09-30 09:10:11 +00:00
},
{
"id": 3,
"username": "foo_bar",
"name": "Foo bar",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
2021-02-01 09:09:28 +00:00
"web_url": "http://192.168.1.8:3000/root",
2021-05-11 15:10:20 +00:00
"last_activity_on": "2021-01-20",
2021-05-12 18:10:35 +00:00
"membership_type": "group_invite",
2021-08-02 09:10:09 +00:00
"removable": false,
"created_at": "2021-01-09T07:12:31.000Z"
2020-09-30 09:10:11 +00:00
}
]
```
2021-04-14 18:09:18 +00:00
## List memberships for a billable member of a group
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/321560) in GitLab 13.11.
Gets a list of memberships for a billable member of a group.
Lists all projects and groups a user is a member of. Only projects and groups within the group hierarchy are included.
For instance, if the requested group is `Root Group` , and the requested user is a direct member of both `Root Group / Sub Group One` and `Other Group / Sub Group Two` , then only `Root Group / Sub Group One` will be returned, because `Other Group / Sub Group Two` is not within the `Root Group` hierarchy.
The response represents only direct memberships. Inherited memberships are not included.
This API endpoint works on top-level groups only. It does not work on subgroups.
2021-09-22 15:12:06 +00:00
This API endpoint requires permission to administer memberships for the group.
2021-04-14 18:09:18 +00:00
2021-06-28 15:08:03 +00:00
This API endpoint takes [pagination ](index.md#pagination ) parameters `page` and `per_page` to restrict the list of memberships.
2021-04-14 18:09:18 +00:00
```plaintext
GET /groups/:id/billable_members/:user_id/memberships
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2021-04-14 18:09:18 +00:00
| `user_id` | integer | yes | The user ID of the billable member |
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/billable_members/:user_id/memberships"
```
Example response:
```json
[
{
"id": 168,
"source_id": 131,
"source_full_name": "Root Group / Sub Group One",
"source_members_url": "https://gitlab.example.com/groups/root-group/sub-group-one/-/group_members",
"created_at": "2021-03-31T17:28:44.812Z",
"expires_at": "2022-03-21",
"access_level": {
"string_value": "Developer",
"integer_value": 30
}
},
{
"id": 169,
"source_id": 63,
"source_full_name": "Root Group / Sub Group One / My Project",
"source_members_url": "https://gitlab.example.com/root-group/sub-group-one/my-project/-/project_members",
"created_at": "2021-03-31T17:29:14.934Z",
"expires_at": null,
"access_level": {
"string_value": "Maintainer",
"integer_value": 40
}
}
]
```
2021-03-09 15:08:59 +00:00
## Remove a billable member from a group
Removes a billable member from a group and its subgroups and projects.
The user does not need to be a group member to qualify for removal.
For example, if the user was added directly to a project within the group, you can
still use this API to remove them.
```plaintext
DELETE /groups/:id/billable_members/:user_id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2021-03-09 15:08:59 +00:00
| `user_id` | integer | yes | The user ID of the member |
```shell
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/billable_members/:user_id"
```
2016-06-23 15:14:31 +00:00
## Add a member to a group or project
Adds a member to a group or project.
2020-02-27 09:09:01 +00:00
```plaintext
2016-06-23 15:14:31 +00:00
POST /groups/:id/members
POST /projects/:id/members
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2020-10-13 12:08:41 +00:00
| `user_id` | integer/string | yes | The user ID of the new member or multiple IDs separated by commas |
2016-06-23 15:14:31 +00:00
| `access_level` | integer | yes | A valid access level |
2021-01-29 18:09:17 +00:00
| `expires_at` | string | no | A date string in the format `YEAR-MONTH-DAY` |
2021-05-27 12:10:56 +00:00
| `invite_source` | string | no | The source of the invitation that starts the member creation process. See [this issue ](https://gitlab.com/gitlab-org/gitlab/-/issues/327120 ). |
2021-07-22 21:09:40 +00:00
| `areas_of_focus` | string | no | Areas the inviter wants the member to focus upon. |
2016-06-23 15:14:31 +00:00
2020-01-30 15:09:15 +00:00
```shell
2021-06-02 15:09:59 +00:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
--data "user_id=1& access_level=30" "https://gitlab.example.com/api/v4/groups/:id/members"
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
--data "user_id=1& access_level=30" "https://gitlab.example.com/api/v4/projects/:id/members"
2016-06-23 15:14:31 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
2018-07-25 21:45:42 +00:00
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 30,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-02-24 00:09:02 +00:00
"group_saml_identity": null
2016-06-23 15:14:31 +00:00
}
```
## Edit a member of a group or project
Updates a member of a group or project.
2020-02-27 09:09:01 +00:00
```plaintext
2016-06-23 15:14:31 +00:00
PUT /groups/:id/members/:user_id
PUT /projects/:id/members/:user_id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-06-23 15:14:31 +00:00
| `user_id` | integer | yes | The user ID of the member |
| `access_level` | integer | yes | A valid access level |
2021-01-29 18:09:17 +00:00
| `expires_at` | string | no | A date string in the format `YEAR-MONTH-DAY` |
2016-06-23 15:14:31 +00:00
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/:user_id?access_level=40"
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members/:user_id?access_level=40"
2016-06-23 15:14:31 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
2018-07-25 21:45:42 +00:00
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
2020-02-24 00:09:02 +00:00
"access_level": 40,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-02-24 00:09:02 +00:00
"group_saml_identity": null
2016-06-23 15:14:31 +00:00
}
```
2020-04-23 21:09:31 +00:00
### Set override flag for a member of a group
2020-07-02 15:09:08 +00:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/4875) in GitLab 13.0.
2020-04-23 21:09:31 +00:00
By default, the access level of LDAP group members is set to the value specified
by LDAP through Group Sync. You can allow access level overrides by calling this endpoint.
```plaintext
POST /groups/:id/members/:user_id/override
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2020-04-23 21:09:31 +00:00
| `user_id` | integer | yes | The user ID of the member |
2020-05-21 03:08:00 +00:00
```shell
2021-01-11 06:10:29 +00:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/:user_id/override"
2020-04-23 21:09:31 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
"expires_at": "2012-10-22T14:13:35Z",
"access_level": 40,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-04-23 21:09:31 +00:00
"override": true
}
```
### Remove override for a member of a group
2020-07-02 15:09:08 +00:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/4875) in GitLab 13.0.
2020-04-23 21:09:31 +00:00
Sets the override flag to false and allows LDAP Group Sync to reset the access
level to the LDAP-prescribed value.
```plaintext
DELETE /groups/:id/members/:user_id/override
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2020-04-23 21:09:31 +00:00
| `user_id` | integer | yes | The user ID of the member |
2020-05-21 03:08:00 +00:00
```shell
2021-01-11 06:10:29 +00:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/:user_id/override"
2020-04-23 21:09:31 +00:00
```
Example response:
```json
{
"id": 1,
"username": "raymond_smith",
"name": "Raymond Smith",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80& d=identicon",
"web_url": "http://192.168.1.8:3000/root",
2021-09-01 18:08:49 +00:00
"expires_at": "2012-10-22",
2020-04-23 21:09:31 +00:00
"access_level": 40,
2020-07-20 15:09:10 +00:00
"email": "john@example.com",
2020-04-23 21:09:31 +00:00
"override": false
}
```
2016-06-23 15:14:31 +00:00
## Remove a member from a group or project
Removes a user from a group or project.
2020-02-27 09:09:01 +00:00
```plaintext
2016-06-23 15:14:31 +00:00
DELETE /groups/:id/members/:user_id
DELETE /projects/:id/members/:user_id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-06-28 15:08:03 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project or group ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-06-23 15:14:31 +00:00
| `user_id` | integer | yes | The user ID of the member |
2021-04-05 12:09:17 +00:00
| `skip_subresources` | boolean | false | Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Default is `false` . |
2021-03-23 12:09:33 +00:00
| `unassign_issuables` | boolean | false | Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Default is `false` . |
Example request:
2016-06-23 15:14:31 +00:00
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/:id/members/:user_id"
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/:id/members/:user_id"
2016-06-23 15:14:31 +00:00
```
2018-06-01 05:02:52 +00:00
## Give a group access to a project
2020-06-08 03:08:17 +00:00
See [share project with group ](projects.md#share-project-with-group )