> 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 part of a collection

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

Updates specific collection information, such as its name, events, or its variables. For more information, see the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).


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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /collections/{collectionId}:
    patch:
      operationId: patchCollection
      summary: Update part of a collection
      description: >
        Updates specific collection information, such as its name, events, or
        its variables. For more information, see the [Postman Collection Format
        documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).
      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:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/patchCollectionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatchCollectionRequestBadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatchCollectionRequestUnauthorizedError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatchCollectionRequestForbiddenError'
        '404':
          description: Instance Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorNameMessageDetails'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatchCollectionRequestInternalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/patchCollection'
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
    PatchCollectionCollectionInfo:
      type: object
      properties:
        name:
          type: string
          description: The collection's updated name.
        description:
          type: string
          description: The collection's updated description.
      description: An object that contains the collection's updated name and description.
      title: PatchCollectionCollectionInfo
    Variable2Value:
      oneOf:
        - type: string
        - type: boolean
        - type: integer
      description: The key's value.
      title: Variable2Value
    variable-2:
      type: object
      properties:
        id:
          type: string
          description: The variable's ID. Doesn't apply to collection-level variables.
        key:
          type: string
          description: The variable's key (name).
        description:
          type: string
          description: The variable's description.
        value:
          $ref: '#/components/schemas/Variable2Value'
          description: The key's value.
        disabled:
          type: boolean
          default: false
          description: >-
            If true, the variable is not enabled. Doesn't apply to path
            parameter variables.
      description: Information about the variable.
      title: variable-2
    variable-list-2:
      type: array
      items:
        $ref: '#/components/schemas/variable-2'
      description: >-
        A list of the collection's
        [variables](https://learning.postman.com/docs/sending-requests/variables/variables/).
        Make certain not to include sensitive information in variables.
      title: variable-list-2
    Auth2Type:
      type: string
      enum:
        - basic
        - bearer
        - apikey
        - digest
        - oauth1
        - oauth2
        - hawk
        - awsv4
        - ntlm
        - edgegrid
        - jwt
        - asap
      description: The authorization type.
      title: Auth2Type
    AuthAttributeValueOneOf1Items:
      type: object
      properties: {}
      title: AuthAttributeValueOneOf1Items
    AuthAttributeValue1:
      type: array
      items:
        $ref: '#/components/schemas/AuthAttributeValueOneOf1Items'
      title: AuthAttributeValue1
    AuthAttributeValue:
      oneOf:
        - type: string
        - $ref: '#/components/schemas/AuthAttributeValue1'
      description: The key's value.
      title: AuthAttributeValue
    AuthAttributeType:
      type: string
      enum:
        - string
        - boolean
        - number
        - array
        - object
        - any
      description: The value's type.
      title: AuthAttributeType
    auth-attribute:
      type: object
      properties:
        key:
          type: string
          description: The auth method's key value.
        value:
          $ref: '#/components/schemas/AuthAttributeValue'
          description: The key's value.
        type:
          $ref: '#/components/schemas/AuthAttributeType'
          description: The value's type.
      required:
        - key
      description: >-
        Information about the supported Postman [authorization
        type](https://learning.postman.com/docs/sending-requests/authorization/authorization-types/).
      title: auth-attribute
    auth-2:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/Auth2Type'
          description: The authorization type.
        apikey:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: The API key's authentication information.
        awsv4:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for [AWS
            Signature](https://learning.postman.com/docs/sending-requests/authorization/aws-signature/)
            authentication.
        basic:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for [Basic
            Auth](https://learning.postman.com/docs/sending-requests/authorization/authorization-types/#basic-auth).
        bearer:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for [Bearer
            Token](https://learning.postman.com/docs/sending-requests/authorization/authorization-types/#bearer-token)
            authentication.
        digest:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for
            [Digest](https://learning.postman.com/docs/sending-requests/authorization/digest-auth/)
            access authentication.
        edgegrid:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for [Akamai
            Edgegrid](https://learning.postman.com/docs/sending-requests/authorization/akamai-edgegrid/)
            authentication.
        hawk:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for
            [Hawk](https://learning.postman.com/docs/sending-requests/authorization/hawk-authentication/)
            authentication.
        ntlm:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for
            [NTLM](https://learning.postman.com/docs/sending-requests/authorization/ntlm-authentication/)
            authentication.
        oauth1:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for
            [OAuth1](https://learning.postman.com/docs/sending-requests/authorization/oauth-10/)
            authentication.
        oauth2:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for
            [OAuth2](https://learning.postman.com/docs/sending-requests/authorization/oauth-20/)
            authentication.
        jwt:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for JWT (JSON Web Token). Includes the `payload`,
            `secret`, `algorithm`, `addTokenTo`, and `headerPrefix` properties.
        asap:
          type: array
          items:
            $ref: '#/components/schemas/auth-attribute'
          description: >-
            The attributes for ASAP (Atlassian S2S Authentication Protocol).
            Includes the `kid`, `aud`, `iss`, `alg`, `privateKey`, and `claims`
            properties.
      required:
        - type
      description: >-
        The [authorization type supported by
        Postman](https://learning.postman.com/docs/sending-requests/authorization/authorization-types/).
      title: auth-2
    Event2Listen:
      type: string
      enum:
        - test
        - prerequest
      description: The `prerequest` (pre-request) or `test` (post-response) value.
      title: Event2Listen
    script-2:
      type: object
      properties:
        id:
          type: string
          description: The script's ID.
        type:
          type: string
          description: The type of script. For example, `text/javascript`.
        exec:
          type: array
          items:
            type: string
          description: >-
            A list of script strings, where each line represents a line of code.
            Separate lines makes it easy to track script changes.
      description: >-
        Information about the Javascript code that can be used to to perform
        setup or teardown operations in a response.
      title: script-2
    event-2:
      type: object
      properties:
        id:
          type: string
          description: The event's ID.
        listen:
          $ref: '#/components/schemas/Event2Listen'
          description: The `prerequest` (pre-request) or `test` (post-response) value.
        script:
          $ref: '#/components/schemas/script-2'
      required:
        - listen
      description: Information about the collection's events.
      title: event-2
    event-list-2:
      type: array
      items:
        $ref: '#/components/schemas/event-2'
      description: >-
        A list of scripts configured to run when specific events occur. These
        scripts can be referenced in the collection by their ID.
      title: event-list-2
    PatchCollectionCollection:
      type: object
      properties:
        info:
          $ref: '#/components/schemas/PatchCollectionCollectionInfo'
          description: >-
            An object that contains the collection's updated name and
            description.
        variable:
          $ref: '#/components/schemas/variable-list-2'
        auth:
          $ref: '#/components/schemas/auth-2'
        events:
          $ref: '#/components/schemas/event-list-2'
      title: PatchCollectionCollection
    patchCollection:
      type: object
      properties:
        collection:
          $ref: '#/components/schemas/PatchCollectionCollection'
      title: patchCollection
    PatchCollectionResponseCollection:
      type: object
      properties:
        id:
          type: string
          description: The collection's ID.
        name:
          type: string
          description: The collection's updated name.
        description:
          type: string
          description: The collection's updated description.
      title: PatchCollectionResponseCollection
    patchCollectionResponse:
      type: object
      properties:
        collection:
          $ref: '#/components/schemas/PatchCollectionResponseCollection'
      title: patchCollectionResponse
    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
    CommonErrorNameMessageDetailsErrorDetails:
      oneOf:
        - type: object
          additionalProperties:
            description: Any type
        - type: array
          items:
            type: string
      description: Information about the error.
      title: CommonErrorNameMessageDetailsErrorDetails
    CommonErrorNameMessageDetailsError:
      type: object
      properties:
        name:
          type: string
          description: The error name.
        message:
          type: string
          description: The error message.
        details:
          $ref: '#/components/schemas/CommonErrorNameMessageDetailsErrorDetails'
          description: Information about the error.
      title: CommonErrorNameMessageDetailsError
    commonErrorNameMessageDetails:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/CommonErrorNameMessageDetailsError'
      title: commonErrorNameMessageDetails
    PatchCollectionRequestBadRequestError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorNameMessage'
        - $ref: '#/components/schemas/commonErrorNameMessageDetails'
      title: PatchCollectionRequestBadRequestError
    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
    PatchCollectionRequestUnauthorizedError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: PatchCollectionRequestUnauthorizedError
    PatchCollectionRequestForbiddenError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: PatchCollectionRequestForbiddenError
    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
    PatchCollectionRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: PatchCollectionRequestInternalServerError
  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

### Collection Updated



**Request**

```json
undefined
```

**Response**

```json
{
  "collection": {
    "id": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "name": "Test Collection v2",
    "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
  }
}
```

**SDK Code**

```python Collection Updated
import requests

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

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

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

print(response.json())
```

```javascript Collection Updated
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Collection Updated
package main

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

func main() {

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

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

	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 Collection Updated
require 'uri'
require 'net/http'

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

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'

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

```java Collection Updated
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")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2', [
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Collection Updated
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Collection Updated
import Foundation

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

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

### Update Auth



**Request**

```json
{
  "collection": {
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "key": "value",
          "value": "{{apiKey}}"
        },
        {
          "key": "key",
          "value": "X-Api-Key"
        },
        {
          "key": "in",
          "value": "header"
        }
      ]
    }
  }
}
```

**Response**

```json
{
  "collection": {
    "id": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "name": "Test Collection v2",
    "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
  }
}
```

**SDK Code**

```python Update Auth
import requests

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

payload = { "collection": { "auth": {
            "type": "apikey",
            "apikey": [
                {
                    "key": "value",
                    "value": "{{apiKey}}"
                },
                {
                    "key": "key",
                    "value": "X-Api-Key"
                },
                {
                    "key": "in",
                    "value": "header"
                }
            ]
        } } }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Auth
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"collection":{"auth":{"type":"apikey","apikey":[{"key":"value","value":"{{apiKey}}"},{"key":"key","value":"X-Api-Key"},{"key":"in","value":"header"}]}}}'
};

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

```go Update Auth
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"collection\": {\n    \"auth\": {\n      \"type\": \"apikey\",\n      \"apikey\": [\n        {\n          \"key\": \"value\",\n          \"value\": \"{{apiKey}}\"\n        },\n        {\n          \"key\": \"key\",\n          \"value\": \"X-Api-Key\"\n        },\n        {\n          \"key\": \"in\",\n          \"value\": \"header\"\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 Auth
require 'uri'
require 'net/http'

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

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  \"collection\": {\n    \"auth\": {\n      \"type\": \"apikey\",\n      \"apikey\": [\n        {\n          \"key\": \"value\",\n          \"value\": \"{{apiKey}}\"\n        },\n        {\n          \"key\": \"key\",\n          \"value\": \"X-Api-Key\"\n        },\n        {\n          \"key\": \"in\",\n          \"value\": \"header\"\n        }\n      ]\n    }\n  }\n}"

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

```java Update Auth
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")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"collection\": {\n    \"auth\": {\n      \"type\": \"apikey\",\n      \"apikey\": [\n        {\n          \"key\": \"value\",\n          \"value\": \"{{apiKey}}\"\n        },\n        {\n          \"key\": \"key\",\n          \"value\": \"X-Api-Key\"\n        },\n        {\n          \"key\": \"in\",\n          \"value\": \"header\"\n        }\n      ]\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2', [
  'body' => '{
  "collection": {
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "key": "value",
          "value": "{{apiKey}}"
        },
        {
          "key": "key",
          "value": "X-Api-Key"
        },
        {
          "key": "in",
          "value": "header"
        }
      ]
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Auth
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"collection\": {\n    \"auth\": {\n      \"type\": \"apikey\",\n      \"apikey\": [\n        {\n          \"key\": \"value\",\n          \"value\": \"{{apiKey}}\"\n        },\n        {\n          \"key\": \"key\",\n          \"value\": \"X-Api-Key\"\n        },\n        {\n          \"key\": \"in\",\n          \"value\": \"header\"\n        }\n      ]\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Auth
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["collection": ["auth": [
      "type": "apikey",
      "apikey": [
        [
          "key": "value",
          "value": "{{apiKey}}"
        ],
        [
          "key": "key",
          "value": "X-Api-Key"
        ],
        [
          "key": "in",
          "value": "header"
        ]
      ]
    ]]] 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")! 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 Events



**Request**

```json
{
  "collection": {
    "events": [
      {
        "listen": "prerequest",
        "script": {
          "id": "e74ce0d0-5acd-44b6-a3ae-95f617c1546e",
          "type": "text/javascript",
          "exec": [
            ""
          ]
        }
      },
      {
        "listen": "test",
        "script": {
          "id": "28dc4f71-73bd-49cb-a6bd-8b41a06a3b36",
          "type": "text/javascript",
          "exec": [
            ""
          ]
        }
      }
    ]
  }
}
```

**Response**

```json
{
  "collection": {
    "id": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "name": "Test Collection v2",
    "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
  }
}
```

**SDK Code**

```python Update Events
import requests

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

payload = { "collection": { "events": [
            {
                "listen": "prerequest",
                "script": {
                    "id": "e74ce0d0-5acd-44b6-a3ae-95f617c1546e",
                    "type": "text/javascript",
                    "exec": [""]
                }
            },
            {
                "listen": "test",
                "script": {
                    "id": "28dc4f71-73bd-49cb-a6bd-8b41a06a3b36",
                    "type": "text/javascript",
                    "exec": [""]
                }
            }
        ] } }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Events
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"collection":{"events":[{"listen":"prerequest","script":{"id":"e74ce0d0-5acd-44b6-a3ae-95f617c1546e","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"28dc4f71-73bd-49cb-a6bd-8b41a06a3b36","type":"text/javascript","exec":[""]}}]}}'
};

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

```go Update Events
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"collection\": {\n    \"events\": [\n      {\n        \"listen\": \"prerequest\",\n        \"script\": {\n          \"id\": \"e74ce0d0-5acd-44b6-a3ae-95f617c1546e\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      },\n      {\n        \"listen\": \"test\",\n        \"script\": {\n          \"id\": \"28dc4f71-73bd-49cb-a6bd-8b41a06a3b36\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\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 Events
require 'uri'
require 'net/http'

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

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  \"collection\": {\n    \"events\": [\n      {\n        \"listen\": \"prerequest\",\n        \"script\": {\n          \"id\": \"e74ce0d0-5acd-44b6-a3ae-95f617c1546e\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      },\n      {\n        \"listen\": \"test\",\n        \"script\": {\n          \"id\": \"28dc4f71-73bd-49cb-a6bd-8b41a06a3b36\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      }\n    ]\n  }\n}"

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

```java Update Events
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")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"collection\": {\n    \"events\": [\n      {\n        \"listen\": \"prerequest\",\n        \"script\": {\n          \"id\": \"e74ce0d0-5acd-44b6-a3ae-95f617c1546e\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      },\n      {\n        \"listen\": \"test\",\n        \"script\": {\n          \"id\": \"28dc4f71-73bd-49cb-a6bd-8b41a06a3b36\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      }\n    ]\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2', [
  'body' => '{
  "collection": {
    "events": [
      {
        "listen": "prerequest",
        "script": {
          "id": "e74ce0d0-5acd-44b6-a3ae-95f617c1546e",
          "type": "text/javascript",
          "exec": [
            ""
          ]
        }
      },
      {
        "listen": "test",
        "script": {
          "id": "28dc4f71-73bd-49cb-a6bd-8b41a06a3b36",
          "type": "text/javascript",
          "exec": [
            ""
          ]
        }
      }
    ]
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Events
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"collection\": {\n    \"events\": [\n      {\n        \"listen\": \"prerequest\",\n        \"script\": {\n          \"id\": \"e74ce0d0-5acd-44b6-a3ae-95f617c1546e\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      },\n      {\n        \"listen\": \"test\",\n        \"script\": {\n          \"id\": \"28dc4f71-73bd-49cb-a6bd-8b41a06a3b36\",\n          \"type\": \"text/javascript\",\n          \"exec\": [\n            \"\"\n          ]\n        }\n      }\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Events
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["collection": ["events": [
      [
        "listen": "prerequest",
        "script": [
          "id": "e74ce0d0-5acd-44b6-a3ae-95f617c1546e",
          "type": "text/javascript",
          "exec": [""]
        ]
      ],
      [
        "listen": "test",
        "script": [
          "id": "28dc4f71-73bd-49cb-a6bd-8b41a06a3b36",
          "type": "text/javascript",
          "exec": [""]
        ]
      ]
    ]]] 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")! 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 Info



**Request**

```json
{
  "collection": {
    "info": {
      "name": "Test Collection v2",
      "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
    }
  }
}
```

**Response**

```json
{
  "collection": {
    "id": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "name": "Test Collection v2",
    "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
  }
}
```

**SDK Code**

```python Update Info
import requests

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

payload = { "collection": { "info": {
            "name": "Test Collection v2",
            "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
        } } }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Info
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"collection":{"info":{"name":"Test Collection v2","description":"This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."}}}'
};

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

```go Update Info
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"collection\": {\n    \"info\": {\n      \"name\": \"Test Collection v2\",\n      \"description\": \"This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client.\"\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 Info
require 'uri'
require 'net/http'

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

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  \"collection\": {\n    \"info\": {\n      \"name\": \"Test Collection v2\",\n      \"description\": \"This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client.\"\n    }\n  }\n}"

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

```java Update Info
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")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"collection\": {\n    \"info\": {\n      \"name\": \"Test Collection v2\",\n      \"description\": \"This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client.\"\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2', [
  'body' => '{
  "collection": {
    "info": {
      "name": "Test Collection v2",
      "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Info
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"collection\": {\n    \"info\": {\n      \"name\": \"Test Collection v2\",\n      \"description\": \"This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client.\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Info
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["collection": ["info": [
      "name": "Test Collection v2",
      "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
    ]]] 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")! 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 Variables



**Request**

```json
{
  "collection": {
    "variable": [
      {
        "key": "userId",
        "description": "The user's ID.",
        "value": "12345678",
        "disabled": true
      }
    ]
  }
}
```

**Response**

```json
{
  "collection": {
    "id": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "name": "Test Collection v2",
    "description": "This is a sample collection that makes a request to the Postman Echo service. It returns a list of request headers sent by an HTTP client."
  }
}
```

**SDK Code**

```python Update Variables
import requests

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

payload = { "collection": { "variable": [
            {
                "key": "userId",
                "description": "The user's ID.",
                "value": "12345678",
                "disabled": True
            }
        ] } }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Variables
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"collection":{"variable":[{"key":"userId","description":"The user\'s ID.","value":"12345678","disabled":true}]}}'
};

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

```go Update Variables
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"collection\": {\n    \"variable\": [\n      {\n        \"key\": \"userId\",\n        \"description\": \"The user's ID.\",\n        \"value\": \"12345678\",\n        \"disabled\": true\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 Variables
require 'uri'
require 'net/http'

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

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  \"collection\": {\n    \"variable\": [\n      {\n        \"key\": \"userId\",\n        \"description\": \"The user's ID.\",\n        \"value\": \"12345678\",\n        \"disabled\": true\n      }\n    ]\n  }\n}"

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

```java Update Variables
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")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"collection\": {\n    \"variable\": [\n      {\n        \"key\": \"userId\",\n        \"description\": \"The user's ID.\",\n        \"value\": \"12345678\",\n        \"disabled\": true\n      }\n    ]\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2', [
  'body' => '{
  "collection": {
    "variable": [
      {
        "key": "userId",
        "description": "The user\'s ID.",
        "value": "12345678",
        "disabled": true
      }
    ]
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Variables
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"collection\": {\n    \"variable\": [\n      {\n        \"key\": \"userId\",\n        \"description\": \"The user's ID.\",\n        \"value\": \"12345678\",\n        \"disabled\": true\n      }\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Variables
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["collection": ["variable": [
      [
        "key": "userId",
        "description": "The user's ID.",
        "value": "12345678",
        "disabled": true
      ]
    ]]] 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")! 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()
```