> 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.

# Duplicate a collection

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

Creates a duplicate of the given collection in another workspace.

Use the GET `/collection-duplicate-tasks/{taskId}` endpoint to get the duplication task's current status.


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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /collections/{collectionId}/duplicates:
    post:
      operationId: duplicateCollection
      summary: Duplicate a collection
      description: >
        Creates a duplicate of the given collection in another workspace.


        Use the GET `/collection-duplicate-tasks/{taskId}` endpoint to get the
        duplication task's current status.
      tags:
        - collections
      parameters:
        - name: collectionId
          in: path
          description: The collection's unique ID.
          required: true
          schema:
            $ref: '#/components/schemas/collectionUid'
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/duplicateCollectionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DuplicateCollectionRequestBadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/DuplicateCollectionRequestUnauthorizedError
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DuplicateCollectionRequestForbiddenError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/DuplicateCollectionRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/duplicateCollection'
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:
    collectionUid:
      type: string
      format: uid
      title: collectionUid
    duplicateCollection:
      type: object
      properties:
        workspace:
          type: string
          description: The workspace ID in which to duplicate the collection.
        suffix:
          type: string
          description: An optional suffix to append to the duplicated collection's name.
      required:
        - workspace
      title: duplicateCollection
    DuplicateCollectionResponseTaskStatus:
      type: string
      enum:
        - processing
        - completed
        - failed
      description: The status of the collection duplication task.
      title: DuplicateCollectionResponseTaskStatus
    DuplicateCollectionResponseTask:
      type: object
      properties:
        id:
          type: string
          description: The duplication task's ID.
        status:
          $ref: '#/components/schemas/DuplicateCollectionResponseTaskStatus'
          description: The status of the collection duplication task.
        reason:
          type:
            - string
            - 'null'
          description: If the task failed, the reason why it failed to complete.
      title: DuplicateCollectionResponseTask
    duplicateCollectionResponse:
      type: object
      properties:
        task:
          $ref: '#/components/schemas/DuplicateCollectionResponseTask'
      title: duplicateCollectionResponse
    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
    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
    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
    DuplicateCollectionRequestBadRequestError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessageDetails'
      title: DuplicateCollectionRequestBadRequestError
    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
    DuplicateCollectionRequestUnauthorizedError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: DuplicateCollectionRequestUnauthorizedError
    DuplicateCollectionRequestForbiddenError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: DuplicateCollectionRequestForbiddenError
    DuplicateCollectionRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: DuplicateCollectionRequestInternalServerError
  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

### Successful Response



**Request**

```json
undefined
```

**Response**

```json
{
  "task": {
    "id": "694899-358b6bdb-bfb8-4715-a8e5-eca2a375e232",
    "status": "processing"
  }
}
```

**SDK Code**

```python Successful Response
import requests

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

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

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

print(response.json())
```

```javascript Successful Response
const url = 'https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates';
const options = {
  method: 'POST',
  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 Successful Response
package main

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

func main() {

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

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

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

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'

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

```java Successful Response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Successful Response
using RestSharp;

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

```swift Successful Response
import Foundation

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

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

### Duplicate Collection



**Request**

```json
{
  "workspace": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "suffix": "Copy"
}
```

**Response**

```json
{
  "task": {
    "id": "694899-358b6bdb-bfb8-4715-a8e5-eca2a375e232",
    "status": "processing"
  }
}
```

**SDK Code**

```python Duplicate Collection
import requests

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

payload = {
    "workspace": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
    "suffix": "Copy"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Duplicate Collection
const url = 'https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"workspace":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9","suffix":"Copy"}'
};

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

```go Duplicate Collection
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"workspace\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"suffix\": \"Copy\"\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 Duplicate Collection
require 'uri'
require 'net/http'

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

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  \"workspace\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"suffix\": \"Copy\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"workspace\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"suffix\": \"Copy\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates', [
  'body' => '{
  "workspace": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "suffix": "Copy"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Duplicate Collection
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2/duplicates");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"workspace\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"suffix\": \"Copy\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Duplicate Collection
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "workspace": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "suffix": "Copy"
] as [String : Any]

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

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