Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions en/automation/automation-list-roles-for-environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "List all roles for an environment"
slug: automation-list-roles-for-environment
---


This article will show you how to retrieve all the available roles for a given environment.

## Before you begin

- You will need a valid API key
- You must have access to the target environment
- You must have the environment ID for the target environment

## API call

```bourne
curl --request GET \
--url https://{endpoint-url}/api/v2/roles?default_scope=ENV&environment_id={environment-id} \
--header 'Content-Type: application/json' \
--header 'MC-Api-Key: {api-key}'
```

## Result

- The response will contain all environment roles available in the specified environment
- You may now search through the response to identify the desired role in the `data/name` and `data/id` fields

## Discussion

To find the environment ID, log into the Web UI and navigate to the service which contains the target environment. In the list of environments, identify the target environment, click on the Hidden Actions menu at the far right, and select **Copy environment ID**.

The environment ID can also be retrieved via the API.

1 change: 1 addition & 0 deletions layout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ categories:
articles:
- automation-cloudops-api.md
- api-credentials.md
- automation-list-roles-for-environment.md
- deploy-virtual-machine-using-terraform.md
- deploy-a-kubernetes-cluster-with-rancher-2-x.md
Loading