> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Update workspace roles

PATCH https://api.getpostman.com/workspaces/{workspaceId}/roles
Content-Type: application/json-patch+json

Updates the roles of users, [user groups](https://learning.postman.com/docs/collaborating-in-postman/user-groups/), or partners in a workspace. To get a list of roles, use the GET `/workspace-roles` endpoint. To get a group ID, use the GET `/groups` endpoint.

**Note:**

- User groups are available on Postman [**Enterprise** plans](https://www.postman.com/pricing).
- To use SCIM IDs for users and user groups, include the `identifierType=scim` header when you call this endpoint. To get SCIM user IDs, include the `include=scim` query parameter when calling the GET `/workspaces/{workspaceId}` or GET `/workspaces` endpoints.
- You can't set roles for users in personal workspaces.
- This endpoint doesn't support the external [Guest role](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#team-roles).
- The partner **Editor** and **Editor and Partner Lead** roles aren't supported in multi-partner workspaces.
- You can't update partner and user roles in the same operation.
- This endpoint is restricted to 50 operations per call.
- The request body must contain one unique action per user, user group, or partner. For example, you cannot add and remove multiple roles for a user in the same request body.


Reference: https://learning.postman.com/api-docs/api-reference/workspaces/update-workspace-roles

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /workspaces/{workspaceId}/roles:
    patch:
      operationId: updateWorkspaceRoles
      summary: Update workspace roles
      description: >
        Updates the roles of users, [user
        groups](https://learning.postman.com/docs/collaborating-in-postman/user-groups/),
        or partners in a workspace. To get a list of roles, use the GET
        `/workspace-roles` endpoint. To get a group ID, use the GET `/groups`
        endpoint.


        **Note:**


        - User groups are available on Postman [**Enterprise**
        plans](https://www.postman.com/pricing).

        - To use SCIM IDs for users and user groups, include the
        `identifierType=scim` header when you call this endpoint. To get SCIM
        user IDs, include the `include=scim` query parameter when calling the
        GET `/workspaces/{workspaceId}` or GET `/workspaces` endpoints.

        - You can't set roles for users in personal workspaces.

        - This endpoint doesn't support the external [Guest
        role](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#team-roles).

        - The partner **Editor** and **Editor and Partner Lead** roles aren't
        supported in multi-partner workspaces.

        - You can't update partner and user roles in the same operation.

        - This endpoint is restricted to 50 operations per call.

        - The request body must contain one unique action per user, user group,
        or partner. For example, you cannot add and remove multiple roles for a
        user in the same request body.
      tags:
        - workspaces
      parameters:
        - name: workspaceId
          in: path
          description: The workspace's ID.
          required: true
          schema:
            $ref: '#/components/schemas/workspaceId'
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
        - name: identifierType
          in: header
          description: Use SCIM user IDs instead of Postman user IDs.
          required: false
          schema:
            $ref: '#/components/schemas/identifierType'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/updateWorkspaceRolesResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateWorkspaceRolesRequestUnauthorizedError
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateWorkspaceRolesRequestForbiddenError'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        '422':
          description: Unprocessable Content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workspaceRoles422Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateWorkspaceRolesRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateWorkspaceRoles'
servers:
  - url: https://api.getpostman.com
    description: https://api.getpostman.com
  - url: https://api.eu.postman.com
    description: https://api.eu.postman.com
components:
  schemas:
    workspaceId:
      type: string
      title: workspaceId
    identifierType:
      type: string
      title: identifierType
    UpdateWorkspaceRolesRolesItemsPath:
      type: string
      enum:
        - /user
        - /usergroup
        - /partner
      description: The resource to perform the action on.
      title: UpdateWorkspaceRolesRolesItemsPath
    UpdateWorkspaceRolesRolesItemsValueItems:
      type: object
      properties:
        id:
          type: string
          description: >-
            The user, user group, or partner's ID. To use SCIM IDs for users or
            user groups, include the `identifierType=scim` header in the
            request.
        role:
          type: string
          description: >
            The user or user group's role ID:

            - `1` — Viewer.  Can view and collaborate on all resources.

            - `2` — Editor. Can create and edit all resources.

            - `3` — Admin. Can manage people and all resources.


            For partner roles:

            - `4` — Viewer. Can send requests and view workspace resources.

            - `5` — Editor. Can create, edit and fork workspace resources.

            - `6` — Viewer and Partner Lead. Can view, fork and export workspace
            resources, and invite partners.

            - `7` — Editor and Partner Lead. Can create and edit workspace
            resources, and invite partners with Editor or Viewer access to the
            workspace.
      required:
        - id
        - role
      description: Information about the user, user group, or partner role.
      title: UpdateWorkspaceRolesRolesItemsValueItems
    UpdateWorkspaceRolesRolesItems:
      type: object
      properties:
        op:
          type: string
          description: The operation to perform on the path.
        path:
          $ref: '#/components/schemas/UpdateWorkspaceRolesRolesItemsPath'
          description: The resource to perform the action on.
        value:
          type: array
          items:
            $ref: '#/components/schemas/UpdateWorkspaceRolesRolesItemsValueItems'
          description: Information about the updated workspace role.
      required:
        - op
        - path
        - value
      title: UpdateWorkspaceRolesRolesItems
    updateWorkspaceRoles:
      type: object
      properties:
        roles:
          type: array
          items:
            $ref: '#/components/schemas/UpdateWorkspaceRolesRolesItems'
      title: updateWorkspaceRoles
    UpdateWorkspaceRolesResponseRolesItems:
      type: object
      properties:
        id:
          type: string
          description: The role's ID.
        user:
          type: array
          items:
            type: string
          description: A list of user IDs assigned to the role.
        group:
          type: array
          items:
            type: string
          description: A list of user group IDs assigned to the role.
        displayName:
          type: string
          description: The role's display name.
      title: UpdateWorkspaceRolesResponseRolesItems
    updateWorkspaceRolesResponse:
      type: object
      properties:
        roles:
          type: array
          items:
            $ref: '#/components/schemas/UpdateWorkspaceRolesResponseRolesItems'
      title: updateWorkspaceRolesResponse
    CommonErrorTypeTitleDetailStatusType:
      oneOf:
        - type: string
          format: uri-reference
        - type: string
      title: CommonErrorTypeTitleDetailStatusType
    commonErrorTypeTitleDetailStatus:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailStatusType'
        title:
          type: string
          description: A short summary of the problem.
        detail:
          type: string
          description: Information about the error.
        status:
          type: integer
          description: The error's HTTP status code.
      title: commonErrorTypeTitleDetailStatus
    CommonErrorNameMessageError:
      type: object
      properties:
        name:
          type: string
          description: The error name.
        message:
          type: string
          description: The error message.
      description: Information about the error.
      title: CommonErrorNameMessageError
    commonErrorNameMessage:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/CommonErrorNameMessageError'
          description: Information about the error.
      title: commonErrorNameMessage
    UpdateWorkspaceRolesRequestUnauthorizedError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateWorkspaceRolesRequestUnauthorizedError
    UpdateWorkspaceRolesRequestForbiddenError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateWorkspaceRolesRequestForbiddenError
    workspaceRoles422Error:
      type: object
      properties:
        detail:
          type: string
          description: Information about the error.
        link:
          type: string
          description: The error type.
        status:
          type: number
          format: double
          description: The error's HTTP status code.
        title:
          type: string
          description: A short summary of the problem.
      title: workspaceRoles422Error
    CommonErrorTypeTitleDetailDetail:
      oneOf:
        - type: string
        - type: object
          additionalProperties:
            description: Any type
      description: Information about the error.
      title: CommonErrorTypeTitleDetailDetail
    commonErrorTypeTitleDetail:
      type: object
      properties:
        type:
          type: string
          description: The type of error.
        title:
          type: string
          description: A short summary of the problem.
        detail:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailDetail'
          description: Information about the error.
      title: commonErrorTypeTitleDetail
    UpdateWorkspaceRolesRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateWorkspaceRolesRequestInternalServerError
  securitySchemes:
    PostmanApiKey:
      type: apiKey
      in: header
      name: x-api-key
    scimApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        A valid [SCIM API
        key](https://learning.postman.com/docs/administration/scim-provisioning/scim-provisioning-overview/#generating-scim-api-key)
        for calls to SCIM endpoints.
    basicAuth:
      type: http
      scheme: basic

```

## Examples

### Update User Role



**Request**

```json
{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "12345678",
          "role": "1"
        },
        {
          "id": "87654321",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/user",
      "value": [
        {
          "id": "87612345",
          "role": "1"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "123",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "312",
          "role": "3"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "1",
      "user": [
        "12345678"
      ],
      "group": [
        "123"
      ],
      "displayName": "Viewer"
    },
    {
      "id": "2",
      "user": [
        "87654321"
      ],
      "group": [
        "123"
      ],
      "displayName": "Editor"
    },
    {
      "id": "3",
      "user": [
        "13428756"
      ],
      "group": [
        "132"
      ],
      "displayName": "Admin"
    }
  ]
}
```

**SDK Code**

```python Update User Role
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"12345678\",\n          \"role\": \"1\"\n        },\n        {\n          \"id\": \"87654321\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"87612345\",\n          \"role\": \"1\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"123\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"312\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Update User Role
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "add",\n      "path": "/user",\n      "value": [\n        {\n          "id": "12345678",\n          "role": "1"\n        },\n        {\n          "id": "87654321",\n          "role": "2"\n        }\n      ]\n    },\n    {\n      "op": "remove",\n      "path": "/user",\n      "value": [\n        {\n          "id": "87612345",\n          "role": "1"\n        }\n      ]\n    },\n    {\n      "op": "add",\n      "path": "/usergroup",\n      "value": [\n        {\n          "id": "123",\n          "role": "2"\n        }\n      ]\n    },\n    {\n      "op": "remove",\n      "path": "/usergroup",\n      "value": [\n        {\n          "id": "312",\n          "role": "3"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Update User Role
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"12345678\",\n          \"role\": \"1\"\n        },\n        {\n          \"id\": \"87654321\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"87612345\",\n          \"role\": \"1\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"123\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"312\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Update User Role
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"12345678\",\n          \"role\": \"1\"\n        },\n        {\n          \"id\": \"87654321\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"87612345\",\n          \"role\": \"1\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"123\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"312\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Update User Role
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"12345678\",\n          \"role\": \"1\"\n        },\n        {\n          \"id\": \"87654321\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"87612345\",\n          \"role\": \"1\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"123\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"312\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Update User Role
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "12345678",
          "role": "1"
        },
        {
          "id": "87654321",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/user",
      "value": [
        {
          "id": "87612345",
          "role": "1"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "123",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "312",
          "role": "3"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Update User Role
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"12345678\",\n          \"role\": \"1\"\n        },\n        {\n          \"id\": \"87654321\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"87612345\",\n          \"role\": \"1\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"123\",\n          \"role\": \"2\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"312\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update User Role
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "12345678",
          "role": "1"
        },
        {
          "id": "87654321",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/user",
      "value": [
        {
          "id": "87612345",
          "role": "1"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "123",
          "role": "2"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "312",
          "role": "3"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Update Role with SCIM ID



**Request**

```json
{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "1"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "1",
      "user": [
        "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99"
      ],
      "displayName": "Viewer"
    }
  ]
}
```

**SDK Code**

```python Update Role with SCIM ID
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"1\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Update Role with SCIM ID
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "add",\n      "path": "/user",\n      "value": [\n        {\n          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",\n          "role": "1"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Update Role with SCIM ID
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"1\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Update Role with SCIM ID
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"1\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Update Role with SCIM ID
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"1\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Update Role with SCIM ID
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "1"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Update Role with SCIM ID
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"1\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Role with SCIM ID
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "1"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Update Role and Group with SCIM IDs



**Request**

```json
{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "3"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00",
          "role": "3"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "3",
      "user": [
        "e982929dadd02cf627e8c111925fc37a93dbc86f510840db"
      ],
      "group": [
        "561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00"
      ],
      "displayName": "Admin"
    }
  ]
}
```

**SDK Code**

```python Update Role and Group with SCIM IDs
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"3\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Update Role and Group with SCIM IDs
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "add",\n      "path": "/user",\n      "value": [\n        {\n          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",\n          "role": "3"\n        }\n      ]\n    },\n    {\n      "op": "add",\n      "path": "/usergroup",\n      "value": [\n        {\n          "id": "561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00",\n          "role": "3"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Update Role and Group with SCIM IDs
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"3\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Update Role and Group with SCIM IDs
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"3\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Update Role and Group with SCIM IDs
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"3\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Update Role and Group with SCIM IDs
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "3"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00",
          "role": "3"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Update Role and Group with SCIM IDs
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": \"405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99\",\n          \"role\": \"3\"\n        }\n      ]\n    },\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Role and Group with SCIM IDs
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "add",
      "path": "/user",
      "value": [
        {
          "id": "405775fe15ed41872a8eea4c8aa2b38cda9749812cc55c99",
          "role": "3"
        }
      ]
    },
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "561631fq14ed41872a8eea4c8aa2b38cda9749812cc55c00",
          "role": "3"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Add or Remove Workspace Group Role



**Request**

```json
undefined
```

**Response**

```json
{
  "roles": [
    {
      "id": "1",
      "user": [
        "12345678"
      ],
      "displayName": "Viewer"
    },
    {
      "id": "3",
      "group": [
        "56781234"
      ],
      "displayName": "Admin"
    },
    {
      "id": "5",
      "displayName": "Editor",
      "partner": [
        "43215678"
      ]
    }
  ]
}
```

**SDK Code**

```python Add or Remove Workspace Group Role
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, headers=headers)

print(response.json())
```

```javascript Add or Remove Workspace Group Role
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add or Remove Workspace Group Role
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	req, _ := http.NewRequest("PATCH", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add or Remove Workspace Group Role
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'

response = http.request(request)
puts response.read_body
```

```java Add or Remove Workspace Group Role
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .asString();
```

```php Add or Remove Workspace Group Role
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Add or Remove Workspace Group Role
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
IRestResponse response = client.Execute(request);
```

```swift Add or Remove Workspace Group Role
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Add and Remove Partner Roles



**Request**

```json
{
  "roles": [
    {
      "op": "add",
      "path": "/partner",
      "value": [
        {
          "id": "87654321",
          "role": "4"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/partner",
      "value": [
        {
          "id": "43215678",
          "role": "4"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "4",
      "displayName": "Viewer",
      "partner": [
        "87654321"
      ]
    }
  ]
}
```

**SDK Code**

```python Add and Remove Partner Roles
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"87654321\",\n          \"role\": \"4\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"43215678\",\n          \"role\": \"4\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Add and Remove Partner Roles
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "add",\n      "path": "/partner",\n      "value": [\n        {\n          "id": "87654321",\n          "role": "4"\n        }\n      ]\n    },\n    {\n      "op": "remove",\n      "path": "/partner",\n      "value": [\n        {\n          "id": "43215678",\n          "role": "4"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add and Remove Partner Roles
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"87654321\",\n          \"role\": \"4\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"43215678\",\n          \"role\": \"4\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add and Remove Partner Roles
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"87654321\",\n          \"role\": \"4\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"43215678\",\n          \"role\": \"4\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Add and Remove Partner Roles
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"87654321\",\n          \"role\": \"4\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"43215678\",\n          \"role\": \"4\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Add and Remove Partner Roles
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "add",
      "path": "/partner",
      "value": [
        {
          "id": "87654321",
          "role": "4"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/partner",
      "value": [
        {
          "id": "43215678",
          "role": "4"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Add and Remove Partner Roles
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"87654321\",\n          \"role\": \"4\"\n        }\n      ]\n    },\n    {\n      \"op\": \"remove\",\n      \"path\": \"/partner\",\n      \"value\": [\n        {\n          \"id\": \"43215678\",\n          \"role\": \"4\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Add and Remove Partner Roles
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "add",
      "path": "/partner",
      "value": [
        {
          "id": "87654321",
          "role": "4"
        }
      ]
    },
    {
      "op": "remove",
      "path": "/partner",
      "value": [
        {
          "id": "43215678",
          "role": "4"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Add Workspace Group Role



**Request**

```json
{
  "roles": [
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "1",
      "user": [
        "12345678"
      ],
      "group": [
        "123"
      ],
      "displayName": "Viewer"
    },
    {
      "id": "2",
      "user": [
        "87654321"
      ],
      "group": [
        "123"
      ],
      "displayName": "Editor"
    },
    {
      "id": "3",
      "user": [
        "13428756"
      ],
      "group": [
        "132"
      ],
      "displayName": "Admin"
    }
  ]
}
```

**SDK Code**

```python Add Workspace Group Role
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Add Workspace Group Role
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "add",\n      "path": "/usergroup",\n      "value": [\n        {\n          "id": "1234",\n          "role": "3"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add Workspace Group Role
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add Workspace Group Role
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Add Workspace Group Role
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Add Workspace Group Role
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Add Workspace Group Role
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"add\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Add Workspace Group Role
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "add",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Remove Workspace Group Role



**Request**

```json
{
  "roles": [
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "roles": [
    {
      "id": "1",
      "user": [
        "12345678"
      ],
      "group": [
        "123"
      ],
      "displayName": "Viewer"
    },
    {
      "id": "2",
      "user": [
        "87654321"
      ],
      "group": [
        "123"
      ],
      "displayName": "Editor"
    },
    {
      "id": "3",
      "user": [
        "13428756"
      ],
      "group": [
        "132"
      ],
      "displayName": "Admin"
    }
  ]
}
```

**SDK Code**

```python Remove Workspace Group Role
import requests

url = "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

payload = "{\n  \"roles\": [\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Remove Workspace Group Role
const url = 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json-patch+json'},
  body: '{\n  "roles": [\n    {\n      "op": "remove",\n      "path": "/usergroup",\n      "value": [\n        {\n          "id": "1234",\n          "role": "3"\n        }\n      ]\n    }\n  ]\n}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Remove Workspace Group Role
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json-patch+json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Remove Workspace Group Role
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Remove Workspace Group Role
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json-patch+json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Remove Workspace Group Role
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles', [
  'body' => '{
  "roles": [
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Remove Workspace Group Role
using RestSharp;

var client = new RestClient("https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json-patch+json");
request.AddParameter("application/json-patch+json", "{\n  \"roles\": [\n    {\n      \"op\": \"remove\",\n      \"path\": \"/usergroup\",\n      \"value\": [\n        {\n          \"id\": \"1234\",\n          \"role\": \"3\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Remove Workspace Group Role
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json-patch+json"
]

let postData = NSData(data: "{
  "roles": [
    {
      "op": "remove",
      "path": "/usergroup",
      "value": [
        {
          "id": "1234",
          "role": "3"
        }
      ]
    }
  ]
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/workspaces/1f0df51a-8658-4ee8-a2a1-d2567dfa09a9/roles")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```