> 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 a collection's roles

PATCH https://api.getpostman.com/collections/{collectionId}/roles
Content-Type: application/json

Updates the roles of users, groups, or teams in a collection. On success, this returns an HTTP `204 No Content` response.

**Note:**

- Only users assigned the Editor [role](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#collection-roles) in the collection can use this endpoint.
- This endpoint does not support the external [Partner or Guest roles](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#team-roles).


Reference: https://learning.postman.com/api-docs/api-reference/collections/update-collection-roles

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /collections/{collectionId}/roles:
    patch:
      operationId: updateCollectionRoles
      summary: Update a collection's roles
      description: >
        Updates the roles of users, groups, or teams in a collection. On
        success, this returns an HTTP `204 No Content` response.


        **Note:**


        - Only users assigned the Editor
        [role](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#collection-roles)
        in the collection can use this endpoint.

        - This endpoint does not support the external [Partner or Guest
        roles](https://learning.postman.com/docs/collaborating-in-postman/roles-and-permissions/#team-roles).
      tags:
        - collections
      parameters:
        - name: collectionId
          in: path
          description: The collection's ID.
          required: true
          schema:
            $ref: '#/components/schemas/collectionId'
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '204':
          description: No Content
          content:
            application/json:
              schema:
                type: object
                properties: {}
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateCollectionRolesRequestUnauthorizedError
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateCollectionRolesRequestForbiddenError
        '404':
          description: Instance Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitle'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/UpdateCollectionRolesRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateCollectionRoles'
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:
    collectionId:
      type: string
      title: collectionId
    UpdateCollectionRolesRolesItemsOp:
      type: string
      enum:
        - update
      description: The operation to perform on the path.
      title: UpdateCollectionRolesRolesItemsOp
    UpdateCollectionRolesRolesItemsPath:
      type: string
      enum:
        - /user
        - /group
        - /team
      description: The resource to perform the action on.
      title: UpdateCollectionRolesRolesItemsPath
    UpdateCollectionRolesRolesItemsValueItemsRole:
      type: string
      enum:
        - VIEWER
        - EDITOR
      description: |-
        The role type:
        - `VIEWER` — Can view, fork, and export collections.
        - `EDITOR` — Can edit collections directly.
      title: UpdateCollectionRolesRolesItemsValueItemsRole
    UpdateCollectionRolesRolesItemsValueItems:
      type: object
      properties:
        id:
          type: number
          format: double
          description: The user, group, or team's ID.
        role:
          $ref: '#/components/schemas/UpdateCollectionRolesRolesItemsValueItemsRole'
          description: |-
            The role type:
            - `VIEWER` — Can view, fork, and export collections.
            - `EDITOR` — Can edit collections directly.
      required:
        - id
        - role
      description: Information about the updated role.
      title: UpdateCollectionRolesRolesItemsValueItems
    UpdateCollectionRolesRolesItems:
      type: object
      properties:
        op:
          $ref: '#/components/schemas/UpdateCollectionRolesRolesItemsOp'
          description: The operation to perform on the path.
        path:
          $ref: '#/components/schemas/UpdateCollectionRolesRolesItemsPath'
          description: The resource to perform the action on.
        value:
          type: array
          items:
            $ref: '#/components/schemas/UpdateCollectionRolesRolesItemsValueItems'
      required:
        - op
        - path
        - value
      title: UpdateCollectionRolesRolesItems
    updateCollectionRoles:
      type: object
      properties:
        roles:
          type: array
          items:
            $ref: '#/components/schemas/UpdateCollectionRolesRolesItems'
      required:
        - roles
      title: updateCollectionRoles
    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
    UpdateCollectionRolesRequestUnauthorizedError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateCollectionRolesRequestUnauthorizedError
    UpdateCollectionRolesRequestForbiddenError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateCollectionRolesRequestForbiddenError
    commonErrorTypeTitle:
      type: object
      properties:
        title:
          type: string
          description: A short summary of the problem.
        type:
          type: string
          description: The type of error.
      title: commonErrorTypeTitle
    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
    UpdateCollectionRolesRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: UpdateCollectionRolesRequestInternalServerError
  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



**Request**

```json
{
  "roles": [
    {
      "op": "update",
      "path": "/user",
      "value": [
        {
          "id": 12345678,
          "role": "EDITOR"
        },
        {
          "id": 87654321,
          "role": "VIEWER"
        }
      ]
    },
    {
      "op": "update",
      "path": "/team",
      "value": [
        {
          "id": 123,
          "role": "VIEWER"
        },
        {
          "id": 543,
          "role": "VIEWER"
        }
      ]
    },
    {
      "op": "update",
      "path": "/group",
      "value": [
        {
          "id": 12345,
          "role": "EDITOR"
        },
        {
          "id": 123,
          "role": "EDITOR"
        }
      ]
    }
  ]
}
```

**SDK Code**

```python Update Collection Roles
import requests

url = "https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles"

payload = { "roles": [
        {
            "op": "update",
            "path": "/user",
            "value": [
                {
                    "id": 12345678,
                    "role": "EDITOR"
                },
                {
                    "id": 87654321,
                    "role": "VIEWER"
                }
            ]
        },
        {
            "op": "update",
            "path": "/team",
            "value": [
                {
                    "id": 123,
                    "role": "VIEWER"
                },
                {
                    "id": 543,
                    "role": "VIEWER"
                }
            ]
        },
        {
            "op": "update",
            "path": "/group",
            "value": [
                {
                    "id": 12345,
                    "role": "EDITOR"
                },
                {
                    "id": 123,
                    "role": "EDITOR"
                }
            ]
        }
    ] }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Collection Roles
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"roles":[{"op":"update","path":"/user","value":[{"id":12345678,"role":"EDITOR"},{"id":87654321,"role":"VIEWER"}]},{"op":"update","path":"/team","value":[{"id":123,"role":"VIEWER"},{"id":543,"role":"VIEWER"}]},{"op":"update","path":"/group","value":[{"id":12345,"role":"EDITOR"},{"id":123,"role":"EDITOR"}]}]}'
};

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

```go Update Collection Roles
package main

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

func main() {

	url := "https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles"

	payload := strings.NewReader("{\n  \"roles\": [\n    {\n      \"op\": \"update\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": 12345678,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 87654321,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/team\",\n      \"value\": [\n        {\n          \"id\": 123,\n          \"role\": \"VIEWER\"\n        },\n        {\n          \"id\": 543,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/group\",\n      \"value\": [\n        {\n          \"id\": 12345,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 123,\n          \"role\": \"EDITOR\"\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")

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

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

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

}
```

```ruby Update Collection Roles
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/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'
request.body = "{\n  \"roles\": [\n    {\n      \"op\": \"update\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": 12345678,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 87654321,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/team\",\n      \"value\": [\n        {\n          \"id\": 123,\n          \"role\": \"VIEWER\"\n        },\n        {\n          \"id\": 543,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/group\",\n      \"value\": [\n        {\n          \"id\": 12345,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 123,\n          \"role\": \"EDITOR\"\n        }\n      ]\n    }\n  ]\n}"

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

```java Update Collection Roles
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"roles\": [\n    {\n      \"op\": \"update\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": 12345678,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 87654321,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/team\",\n      \"value\": [\n        {\n          \"id\": 123,\n          \"role\": \"VIEWER\"\n        },\n        {\n          \"id\": 543,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/group\",\n      \"value\": [\n        {\n          \"id\": 12345,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 123,\n          \"role\": \"EDITOR\"\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Update Collection Roles
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles', [
  'body' => '{
  "roles": [
    {
      "op": "update",
      "path": "/user",
      "value": [
        {
          "id": 12345678,
          "role": "EDITOR"
        },
        {
          "id": 87654321,
          "role": "VIEWER"
        }
      ]
    },
    {
      "op": "update",
      "path": "/team",
      "value": [
        {
          "id": 123,
          "role": "VIEWER"
        },
        {
          "id": 543,
          "role": "VIEWER"
        }
      ]
    },
    {
      "op": "update",
      "path": "/group",
      "value": [
        {
          "id": 12345,
          "role": "EDITOR"
        },
        {
          "id": 123,
          "role": "EDITOR"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Collection Roles
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/roles");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"roles\": [\n    {\n      \"op\": \"update\",\n      \"path\": \"/user\",\n      \"value\": [\n        {\n          \"id\": 12345678,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 87654321,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/team\",\n      \"value\": [\n        {\n          \"id\": 123,\n          \"role\": \"VIEWER\"\n        },\n        {\n          \"id\": 543,\n          \"role\": \"VIEWER\"\n        }\n      ]\n    },\n    {\n      \"op\": \"update\",\n      \"path\": \"/group\",\n      \"value\": [\n        {\n          \"id\": 12345,\n          \"role\": \"EDITOR\"\n        },\n        {\n          \"id\": 123,\n          \"role\": \"EDITOR\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Collection Roles
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["roles": [
    [
      "op": "update",
      "path": "/user",
      "value": [
        [
          "id": 12345678,
          "role": "EDITOR"
        ],
        [
          "id": 87654321,
          "role": "VIEWER"
        ]
      ]
    ],
    [
      "op": "update",
      "path": "/team",
      "value": [
        [
          "id": 123,
          "role": "VIEWER"
        ],
        [
          "id": 543,
          "role": "VIEWER"
        ]
      ]
    ],
    [
      "op": "update",
      "path": "/group",
      "value": [
        [
          "id": 12345,
          "role": "EDITOR"
        ],
        [
          "id": 123,
          "role": "EDITOR"
        ]
      ]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/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()
```