> This page is for Postman API Docs.

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Create a pull request

POST https://api.postman.com/collections/{collectionId}/pull-requests
Content-Type: application/json

Creates a pull request for a forked collection into its parent collection.

Reference: https://learning.postman.com/api-docs/api-reference/collections/create-collection-pull-request

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.postman.com` (https://api.postman.com, default)
- `https://api.eu.postman.com` (https://api.eu.postman.com)

## Request

### Path parameters

- `collectionId` (string, required) — The collection's unique ID.

### Body (application/json)

This endpoint expects a pullRequestCreate.

- `title` (string, required) — The title of the pull request.
- `reviewers` (list of string, required) — A list of reviewers to assign to the pull request.
- `destinationId` (string, required) — The collection ID to merge the pull request into.
- `description` (string, optional) — The pull request's description.

## Response

### 200

Successful Response

- `createdAt` (string, optional) — The date and time at which the pull request was created.
- `createdBy` (string, optional) — The ID of the user who created the pull request.
- `description` (string, optional) — The pull request's description.
- `destinationId` (string, optional) — The pull request's merge destination ID.
- `id` (string, optional) — The pull request's ID.
- `sourceId` (string, optional) — The pull request's source (parent) ID.
- `status` (string, optional) — The pull request's current status.
- `title` (string, optional) — The pull request's title.
- `updatedAt` (string, optional) — The date and time at which the pull request was updated.

## Errors

### 400 Bad Request Error

Bad Request

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### 403 Forbidden Error

Forbidden

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### 500 Internal Server Error

Internal Server Error

- `CreateCollectionPullRequestRequestInternalServerError`
  - Error (Type, Title, Detail): commonErrorTypeTitleDetail
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

## Types

### CommonErrorTypeTitleDetailStatusType

The type of error.

- string
- string

### commonErrorTypeTitleDetail

- `type` (string, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (CommonErrorTypeTitleDetailDetail, optional) — Information about the error.

### commonErrorTypeTitleDetailStatus

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### commonErrorNameMessage

- `error` (CommonErrorNameMessageError, optional) — Information about the error.

### CommonErrorTypeTitleDetailDetail

Information about the error.

- string
- map from string to any

### CommonErrorNameMessageError

Information about the error.

- `name` (string, optional) — The error name.
- `message` (string, optional) — The error message.

## Examples

**Request**

```json
{
  "title": "Test PR",
  "reviewers": [
    "87654321",
    "56781234"
  ],
  "destinationId": "12345678-ec548788-unftw-rgn8-83b8-0b59798648e4",
  "description": "This is a test pull request."
}
```

**Response**

```json
{
  "createdAt": "2024-02-20T09:55:46.000Z",
  "createdBy": "12345678",
  "description": "This is a test pull request.",
  "destinationId": "12345678-ec548788-unftw-rgn8-83b8-0b59798648e4",
  "id": "4e1a6609-1a29-4037-a411-89ecc14c6cd8",
  "sourceId": "87654321-3b79068c-dbe5-41d5-a826-51be4bf646ef",
  "status": "open",
  "title": "Test PR",
  "updatedAt": "2024-02-20T09:58:57.000Z"
}
```

**SDK Code**

```python Collections_createCollectionPullRequest_example
import requests

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

payload = {
    "title": "Test PR",
    "reviewers": ["87654321", "56781234"],
    "destinationId": "12345678-ec548788-unftw-rgn8-83b8-0b59798648e4",
    "description": "This is a test pull request."
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Collections_createCollectionPullRequest_example
const url = 'https://api.postman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/pull-requests';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"title":"Test PR","reviewers":["87654321","56781234"],"destinationId":"12345678-ec548788-unftw-rgn8-83b8-0b59798648e4","description":"This is a test pull request."}'
};

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

```go Collections_createCollectionPullRequest_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"title\": \"Test PR\",\n  \"reviewers\": [\n    \"87654321\",\n    \"56781234\"\n  ],\n  \"destinationId\": \"12345678-ec548788-unftw-rgn8-83b8-0b59798648e4\",\n  \"description\": \"This is a test pull request.\"\n}")

	req, _ := http.NewRequest("POST", 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 Collections_createCollectionPullRequest_example
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"title\": \"Test PR\",\n  \"reviewers\": [\n    \"87654321\",\n    \"56781234\"\n  ],\n  \"destinationId\": \"12345678-ec548788-unftw-rgn8-83b8-0b59798648e4\",\n  \"description\": \"This is a test pull request.\"\n}"

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

```java Collections_createCollectionPullRequest_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/pull-requests")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"title\": \"Test PR\",\n  \"reviewers\": [\n    \"87654321\",\n    \"56781234\"\n  ],\n  \"destinationId\": \"12345678-ec548788-unftw-rgn8-83b8-0b59798648e4\",\n  \"description\": \"This is a test pull request.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/pull-requests', [
  'body' => '{
  "title": "Test PR",
  "reviewers": [
    "87654321",
    "56781234"
  ],
  "destinationId": "12345678-ec548788-unftw-rgn8-83b8-0b59798648e4",
  "description": "This is a test pull request."
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Collections_createCollectionPullRequest_example
using RestSharp;

var client = new RestClient("https://api.postman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/pull-requests");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"title\": \"Test PR\",\n  \"reviewers\": [\n    \"87654321\",\n    \"56781234\"\n  ],\n  \"destinationId\": \"12345678-ec548788-unftw-rgn8-83b8-0b59798648e4\",\n  \"description\": \"This is a test pull request.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Collections_createCollectionPullRequest_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "title": "Test PR",
  "reviewers": ["87654321", "56781234"],
  "destinationId": "12345678-ec548788-unftw-rgn8-83b8-0b59798648e4",
  "description": "This is a test pull request."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/pull-requests")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```