|
| 1 | +--- |
| 2 | +page_title: /member-roles API reference for HCP Terraform |
| 3 | +description: >- |
| 4 | + Use the HCP Terraform API's group `/member-roles` endpoint to review group permissions for resources. |
| 5 | +tfc_only: true |
| 6 | +--- |
| 7 | + |
| 8 | +[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200 |
| 9 | + |
| 10 | +[201]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201 |
| 11 | + |
| 12 | +[202]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202 |
| 13 | + |
| 14 | +[204]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204 |
| 15 | + |
| 16 | +[400]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 |
| 17 | + |
| 18 | +[401]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 |
| 19 | + |
| 20 | +[403]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403 |
| 21 | + |
| 22 | +[404]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404 |
| 23 | + |
| 24 | +[409]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409 |
| 25 | + |
| 26 | +[412]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/412 |
| 27 | + |
| 28 | +[422]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422 |
| 29 | + |
| 30 | +[429]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 |
| 31 | + |
| 32 | +[500]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 |
| 33 | + |
| 34 | +[504]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504 |
| 35 | + |
| 36 | +[JSON API document]: /terraform/cloud-docs/api-docs#json-api-documents |
| 37 | + |
| 38 | +[JSON API error object]: https://jsonapi.org/format/#error-objects |
| 39 | + |
| 40 | +# Group member role API reference |
| 41 | + |
| 42 | +The group member role API returns the assigned roles for an HCP group on a given resource, such as an organization, project, or a workspace. |
| 43 | + |
| 44 | +<Note> |
| 45 | + |
| 46 | +This API is only available for HCP Europe organizations. If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HCP Europe organization. To learn more about HCP Europe, refer to the [HCP Europe documentation](/hcp/docs/hcp/europe). |
| 47 | + |
| 48 | +For other HCP Terraform organizations, refer to the [Team members](/terraform/cloud-docs/api-docs/team-members) API. |
| 49 | + |
| 50 | +</Note> |
| 51 | + |
| 52 | +## List all role assignments |
| 53 | + |
| 54 | +`GET /member-roles/:resource_type/:resource_id` |
| 55 | + |
| 56 | +| Parameter | Description | |
| 57 | +| -------------------- | ------------------------------------------------ | |
| 58 | +| `:resource_type` | The type of the resource. This can be organizations, projects, workspaces. | |
| 59 | +| `:resource_id` | The id of the respective resource. | |
| 60 | + |
| 61 | + |
| 62 | +### Query Parameters |
| 63 | + |
| 64 | +This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. |
| 65 | + |
| 66 | +| Parameter | Description | |
| 67 | +| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 68 | +| `q` | **Optional.** Allows querying a list of role assignments by group name. This search is case-insensitive. | |
| 69 | +| `page[number]` | **Optional.** If omitted, the endpoint will return the first page.
EA0E
| |
| 70 | +| `page[size]` | **Optional.** If omitted, the endpoint will return 20 role assignments per page. | |
| 71 | +| `sort` | **Optional.** Allows sorting by group names. The only valid value is `"name"`. Prepending a hyphen to the sort parameter will reverse the order (e.g. `"-name"`). | |
| 72 | + |
| 73 | +### Sample Request |
| 74 | + |
| 75 | +```shell |
| 76 | +$ curl \ |
| 77 | + --header "Authorization: Bearer $TOKEN" \ |
| 78 | + --header "Content-Type: application/vnd.api+json" \ |
| 79 | + --request GET \ |
| 80 | + https://app.terraform.io/api/v2/member-roles/organizations/5574ca0a-4d0b-4456-b1a6-54e8ae4c1b2a?page[number]=1&page[size]=10&sort= |
| 81 | +``` |
| 82 | + |
| 83 | +### Sample Response |
| 84 | + |
| 85 | +The response shows the ID and name of the HCP groups, as well as the HCP and HCP Terraform permissions that group has access to. The `resource-type` attribute determines at which resource level, such as organization, project, or workspace, that the role is coming from. |
| 86 | + |
| 87 | +```json |
| 88 | +{ |
| 89 | + "data": [ |
| 90 | + { |
| 91 | + "id": "726a300c45-groups-bbe82f8dcb41025f18c951", |
| 92 | + "type": "member-roles", |
| 93 | + "attributes": { |
| 94 | + "roles": [], |
| 95 | + "member-id": "iam.group:hFkn8zpNB6cRp8jnqPkH", |
| 96 | + "member-name": "group_D", |
| 97 | + "member-type": "groups" |
| 98 | + } |
| 99 | + }, |
| 100 | + { |
| 101 | + "id": "bee3018293f35b435662b8882e3fc024", |
| 102 | + "type": "member-roles", |
| 103 | + "attributes": { |
| 104 | + "roles": [ |
| 105 | + { |
| 106 | + "resource-type": "organizations", |
| 107 | + "role-id": "roles/terraform.legacy-organization-access-custom" |
| 108 | + }, |
| 109 | + { |
| 110 | + "resource-type": "organizations", |
| 111 | + "role-id": "roles/admin" |
| 112 | + } |
| 113 | + ], |
| 114 | + "member-id": "iam.group:HTwTGdftfghn9HHwKJ9w", |
| 115 | + "member-name": "group_C", |
| 116 | + "member-type": "groups" |
| 117 | + } |
| 118 | + }, |
| 119 | + { |
| 120 | + "id": "36ed391b9b65ad434576787d46c01af8b8", |
| 121 | + "type": "member-roles", |
| 122 | + "attributes": { |
| 123 | + "roles": [], |
| 124 | + "member-id": "iam.group:cTJfbKCJTThcq8pPQJTj", |
| 125 | + "member-name": "group_B", |
| 126 | + "member-type": "groups" |
| 127 | + } |
| 128 | + } |
| 129 | + ], |
| 130 | + "links": { |
| 131 | + "self": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20", |
| 132 | + "first": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20", |
| 133 | + "prev": null, |
| 134 | + "next": null, |
| 135 | + "last": "https://app.terraform.io/api/v2/member-roles/organizations/4741ca0a-4d0b-4177-b1a6-54e8ae4c1b2a?page%5Bnumber%5D=1&page%5Bsize%5D=20" |
| 136 | + }, |
| 137 | + "meta": { |
| 138 | + "pagination": { |
| 139 | + "current-page": 1, |
| 140 | + "page-size": 20, |
| 141 | + "prev-page": null, |
| 142 | + "next-page": null, |
| 143 | + "total-pages": 1, |
| 144 | + "total-count": 19 |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +## Show roles for a group |
| 151 | + |
| 152 | +`GET /member-roles/:resource_type/:resource_id` |
| 153 | + |
| 154 | +This endpoint fetches the HCP roles and relevant permissions for a single group on the specified resource. |
| 155 | + |
| 156 | +| Parameter | Description | |
| 157 | +| -------------------- | ------------------------------------------------ | |
| 158 | +| `:resource_type` | The resource level to view the roles for. This can be organizations, projects, workspaces. | |
| 159 | +| `:resource_id` | The id of the resource that is of the type resource_type. | |
| 160 | +| `filter[member_type]` | **Required.** Specifies the type of the member. As of now, the only acceptable value is groups. | |
| 161 | +| `filter[group_id]` | **Required.** The id of the group that you want to see the permissions for. | |
| 162 | + |
| 163 | + |
| 164 | +### Query Parameters |
| 165 | + |
| 166 | +This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters). Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs. |
| 167 | + |
| 168 | +| Parameter | Description | |
| 169 | +| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 170 | +| `page[number]` | **Optional.** If omitted, the endpoint will return the first page. | |
| 171 | +| `page[size]` | **Optional.** If omitted, the endpoint will return 10 teams per page. | |
| 172 | + |
| 173 | +### Sample Request |
| 174 | + |
| 175 | +```shell |
| 176 | +$ curl \ |
| 177 | + --header "Authorization: Bearer $TOKEN" \ |
| 178 | + --header "Content-Type: application/vnd.api+json" \ |
| 179 | + --request GET \ |
| 180 | + https://app.terraform.io/api/v2/member-roles/organizations/5574ca0a-4d0b-4456-b1a6-54e8ae4c1b2a?filter[member_type]=groups&filter[member_id]=iam.group%6ANzJbGbHIigBctKmRrTkz |
| 181 | +``` |
| 182 | + |
| 183 | +### Sample Response |
| 184 | + |
| 185 | +The response shows the hcp and terraform roles for a single member (e.g. group) on the specified resource. |
| 186 | + |
| 187 | +```json |
| 188 | +{ |
| 189 | + "data": [ |
| 190 | + { |
| 191 | + "id": "865a1f57998956c67ae86e745ea61654", |
| 192 | + "type": "member-roles", |
| 193 | + "attributes": { |
| 194 | + "roles": [ |
| 195 | + { |
| 196 | + "resource-type": "organizations", |
| 197 | + "role-id": "roles/admin" |
| 198 | + }, |
| 199 | + { |
| 200 | + "resource-type": "projects", |
| 201 | + "role-id": "roles/terraform.legacy-project-access-custom" |
| 202 | + } |
| 203 | + ], |
| 204 | + "member-id": "iam.group:NzJbGbYyLgBctKmDmTkz", |
| 205 | + "member-name": "group_A", |
| 206 | + "member-type": "groups" |
| 207 | + } |
| 208 | + } |
| 209 | + ], |
| 210 | + "links": { |
| 211 | + "self": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", |
| 212 | + "first": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20", |
| 213 | + "prev": null, |
| 214 | + "next": null, |
| 215 | + "last": "https://app.terraform.io/api/v2/member-roles/projects/e78425e5-af7a-40ec-b62c-9a97331b1cd0?filter%5Bmember_id%5D=iam.group%3ANzJbGbHbLgBctKmDmTkz\u0026filter%5Bmember_type%5D=groups\u0026page%5Bnumber%5D=1\u0026page%5Bsize%5D=20" |
| 216 | + }, |
| 217 | + "meta": { |
| 218 | + "pagination": { |
| 219 | + "current-page": 1, |
| 220 | + "page-size": 20, |
| 221 | + "prev-page": null, |
| 222 | + "next-page": null, |
| 223 | + "total-pages": 1, |
| 224 | + "total-count": 1 |
| 225 | + } |
| 226 | + } |
| 227 | +} |
| 228 | +``` |
0 commit comments