PageRenderTime 28ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/api/members.md

https://gitlab.com/innerwhisper/gitlab-ce
Markdown | 248 lines | 203 code | 45 blank | 0 comment | 0 complexity | 06f9e5834fb9ec8fde5075dc37a68ad5 MD5 | raw file
  1. # Group and project members API
  2. **Valid access levels**
  3. The access levels are defined in the `Gitlab::Access` module. Currently, these levels are recognized:
  4. ```
  5. 10 => Guest access
  6. 20 => Reporter access
  7. 30 => Developer access
  8. 40 => Maintainer access
  9. 50 => Owner access # Only valid for groups
  10. ```
  11. ## List all members of a group or project
  12. Gets a list of group or project members viewable by the authenticated user.
  13. Returns only direct members and not inherited members through ancestors groups.
  14. ```
  15. GET /groups/:id/members
  16. GET /projects/:id/members
  17. ```
  18. | Attribute | Type | Required | Description |
  19. | --------- | ---- | -------- | ----------- |
  20. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  21. | `query` | string | no | A query string to search for members |
  22. ```bash
  23. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/:id/members
  24. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/members
  25. ```
  26. Example response:
  27. ```json
  28. [
  29. {
  30. "id": 1,
  31. "username": "raymond_smith",
  32. "name": "Raymond Smith",
  33. "state": "active",
  34. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  35. "web_url": "http://192.168.1.8:3000/root",
  36. "expires_at": "2012-10-22T14:13:35Z",
  37. "access_level": 30
  38. },
  39. {
  40. "id": 2,
  41. "username": "john_doe",
  42. "name": "John Doe",
  43. "state": "active",
  44. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  45. "web_url": "http://192.168.1.8:3000/root",
  46. "expires_at": "2012-10-22T14:13:35Z",
  47. "access_level": 30
  48. }
  49. ]
  50. ```
  51. ## List all members of a group or project including inherited members
  52. Gets a list of group or project members viewable by the authenticated user, including inherited members through ancestor groups.
  53. When a user is a member of the project/group and of one or more ancestor groups the user is returned only once with the project access_level (if exists)
  54. or the access_level for the user in the first group which he belongs to in the project groups ancestors chain.
  55. **Note:** We plan to [change](https://gitlab.com/gitlab-org/gitlab-ce/issues/62284) this behavior to return highest access_level instead.
  56. ```
  57. GET /groups/:id/members/all
  58. GET /projects/:id/members/all
  59. ```
  60. | Attribute | Type | Required | Description |
  61. | --------- | ---- | -------- | ----------- |
  62. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  63. | `query` | string | no | A query string to search for members |
  64. ```bash
  65. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/:id/members/all
  66. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/members/all
  67. ```
  68. Example response:
  69. ```json
  70. [
  71. {
  72. "id": 1,
  73. "username": "raymond_smith",
  74. "name": "Raymond Smith",
  75. "state": "active",
  76. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  77. "web_url": "http://192.168.1.8:3000/root",
  78. "expires_at": "2012-10-22T14:13:35Z",
  79. "access_level": 30
  80. },
  81. {
  82. "id": 2,
  83. "username": "john_doe",
  84. "name": "John Doe",
  85. "state": "active",
  86. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  87. "web_url": "http://192.168.1.8:3000/root",
  88. "expires_at": "2012-10-22T14:13:35Z",
  89. "access_level": 30
  90. },
  91. {
  92. "id": 3,
  93. "username": "foo_bar",
  94. "name": "Foo bar",
  95. "state": "active",
  96. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  97. "web_url": "http://192.168.1.8:3000/root",
  98. "expires_at": "2012-11-22T14:13:35Z",
  99. "access_level": 30
  100. }
  101. ]
  102. ```
  103. ## Get a member of a group or project
  104. Gets a member of a group or project.
  105. ```
  106. GET /groups/:id/members/:user_id
  107. GET /projects/:id/members/:user_id
  108. ```
  109. | Attribute | Type | Required | Description |
  110. | --------- | ---- | -------- | ----------- |
  111. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  112. | `user_id` | integer | yes | The user ID of the member |
  113. ```bash
  114. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/:id/members/:user_id
  115. curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/members/:user_id
  116. ```
  117. Example response:
  118. ```json
  119. {
  120. "id": 1,
  121. "username": "raymond_smith",
  122. "name": "Raymond Smith",
  123. "state": "active",
  124. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  125. "web_url": "http://192.168.1.8:3000/root",
  126. "access_level": 30,
  127. "expires_at": null
  128. }
  129. ```
  130. ## Add a member to a group or project
  131. Adds a member to a group or project.
  132. ```
  133. POST /groups/:id/members
  134. POST /projects/:id/members
  135. ```
  136. | Attribute | Type | Required | Description |
  137. | --------- | ---- | -------- | ----------- |
  138. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  139. | `user_id` | integer | yes | The user ID of the new member |
  140. | `access_level` | integer | yes | A valid access level |
  141. | `expires_at` | string | no | A date string in the format YEAR-MONTH-DAY |
  142. ```bash
  143. 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
  144. 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
  145. ```
  146. Example response:
  147. ```json
  148. {
  149. "id": 1,
  150. "username": "raymond_smith",
  151. "name": "Raymond Smith",
  152. "state": "active",
  153. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  154. "web_url": "http://192.168.1.8:3000/root",
  155. "expires_at": "2012-10-22T14:13:35Z",
  156. "access_level": 30
  157. }
  158. ```
  159. ## Edit a member of a group or project
  160. Updates a member of a group or project.
  161. ```
  162. PUT /groups/:id/members/:user_id
  163. PUT /projects/:id/members/:user_id
  164. ```
  165. | Attribute | Type | Required | Description |
  166. | --------- | ---- | -------- | ----------- |
  167. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  168. | `user_id` | integer | yes | The user ID of the member |
  169. | `access_level` | integer | yes | A valid access level |
  170. | `expires_at` | string | no | A date string in the format YEAR-MONTH-DAY |
  171. ```bash
  172. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/:id/members/:user_id?access_level=40
  173. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/members/:user_id?access_level=40
  174. ```
  175. Example response:
  176. ```json
  177. {
  178. "id": 1,
  179. "username": "raymond_smith",
  180. "name": "Raymond Smith",
  181. "state": "active",
  182. "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon",
  183. "web_url": "http://192.168.1.8:3000/root",
  184. "expires_at": "2012-10-22T14:13:35Z",
  185. "access_level": 40
  186. }
  187. ```
  188. ## Remove a member from a group or project
  189. Removes a user from a group or project.
  190. ```
  191. DELETE /groups/:id/members/:user_id
  192. DELETE /projects/:id/members/:user_id
  193. ```
  194. | Attribute | Type | Required | Description |
  195. | --------- | ---- | -------- | ----------- |
  196. | `id` | integer/string | yes | The ID or [URL-encoded path of the project or group](README.md#namespaced-path-encoding) owned by the authenticated user |
  197. | `user_id` | integer | yes | The user ID of the member |
  198. ```bash
  199. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/:id/members/:user_id
  200. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/members/:user_id
  201. ```
  202. ## Give a group access to a project
  203. Look at [share project with group](projects.md#share-project-with-group)