# Updating users' permissions on multiple spaces

The spaces may belong to different environments.

## Before you begin

* You must have Environment Administrator role in Talend Management Console.
* You must know the IDs of the spaces and users for which your are setting the permissions.

## About this task

You can access the Management Console API via [this link](https://api.talend.com/apis/). You'll find a list of the URLs corresponding to each data center in [Accessing Talend Cloud applications](https://help.qlik.com/talend/en-US/installation-guide-windows/Cloud/talend-cloud-application-url).

## Procedure

1. Use the GET /orchestration/workspaces endpoint to retrieve the IDs of the appropriate spaces.

   You can narrow the search to a single environment by using the query=environment.name=={environmentName} query parameter.
   ### Example
   ```
   GET https://api.us.cloud.talend.com/orchestration/workspaces?query=environment.name==default
   ```
2. Copy the appropriate space IDs from the response body.
3. In the User Management API, use the GET /account/users endpoint to retrieve the user IDs.

   You can narrow the search to a single environment or space by using the environment\_id or workspace\_id query parameters.
   ### Example
   ```
   GET https://api.us.cloud.talend.com/account/users?environment_id=5f2a756784fe57eeb4a3f1a
   ```
4. Copy the appropriate user IDs from the response body.
5. Use the POST (if the space is new) or PUT (if the space already has permissions) /orchestration/permissions/batch endpoint to assign permissions to the users of the space.

   Paste the copied information to the body of the request (space and user IDs).
   ### Example
   ```
   POST https://api.us.cloud.talend.com/security/permissions/batch
   [
       {
        "workspaceId": "5c9212a48c320343cbb5fc4b",
   "userId": "e8f79686-821b-491e-b796-86821b491eb2",
           "permissions": [
               "AUTHOR",
               "EXECUTE",
               "MANAGE",
               "PUBLISH",
               "VIEW"
           ]
       },
       {
             "workspaceId": "9d9212a67c320343chh5fc7l",
         "userId": "e8f79686-821b-491e-b796-86821b491eb2",
           "permissions": [
               "EXECUTE",
               "AUTHOR",
               "VIEW"
           ]
       },
       {
            "workspaceId": "9d9212a67c320343chh5fc7l",
         "userId": "3b7f0e11-4e93-4587-95b2-1ae6292fbb5b",
           "permissions": [
               "EXECUTE",
               "VIEW"
           ]
       }
   ]
   ```
6. To validate that permissions are set correctly, use the GET /security/permissions endpoint with the workspaceID query parameter for each space.

   If the modified spaces belong to the same environment, you can use the environmentID parameter to retrieve all spaces and their permission at the same time.
   ### Example
   ```
   GET https://api.us.cloud.talend.com/security/permissions?workspaceId=9d9212a67c320343chh5fc7l
   ```