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

# Create a folder

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

Creates a folder in a collection. For a complete list of properties, refer to the **Folder** entry in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).

You can use this endpoint to to import requests and responses into a newly-created folder. To do this, include the `requests` field and the list of request objects in the request body. For more information, see the provided example.

**Note:**

It is recommended that you pass the `name` property in the request body. If you do not, the system uses a null value. As a result, this creates a folder with a blank name.


Reference: https://learning.postman.com/api-docs/api-reference/collection-items/create-collection-folder

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /collections/{collectionId}/folders:
    post:
      operationId: createCollectionFolder
      summary: Create a folder
      description: >
        Creates a folder in a collection. For a complete list of properties,
        refer to the **Folder** entry in the [Postman Collection Format
        documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).


        You can use this endpoint to to import requests and responses into a
        newly-created folder. To do this, include the `requests` field and the
        list of request objects in the request body. For more information, see
        the provided example.


        **Note:**


        It is recommended that you pass the `name` property in the request body.
        If you do not, the system uses a null value. As a result, this creates a
        folder with a blank name.
      tags:
        - collectionItems
      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/createCollectionFolderResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorNameMessageDetails'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorNameMessageDetails'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/CreateCollectionFolderRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createCollectionFolder'
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
    createCollectionFolder:
      type: object
      properties:
        name:
          type: string
          description: >-
            The folder's name. It is recommended that you pass the `name`
            property in the request body. If you do not, the system uses a null
            value. As a result, this creates a folder with a blank name.
        folder:
          type: string
          format: uid
          description: The ID of a folder in which to create the folder.
      description: >
        Information about the collection folder. For a complete list of
        properties, refer to the [Postman Collection Format
        documentation](https://schema.postman.com/collection/json/v1.0.0/draft-07/collection.json).


        **Note:**


        It is recommended that you pass the `name` property in the request body.
        If you do not, the system uses a null value. As a result, this creates a
        folder with a blank name.
      title: createCollectionFolder
    CreateCollectionFolderResponseData:
      type: object
      properties:
        id:
          type: string
          description: The folder's ID.
        name:
          type: string
          description: The folder's name.
        order:
          type: array
          items:
            type: string
          description: A list of request IDs and their order in the created folder.
        owner:
          type: string
          description: The user ID of the folder's owner.
        folder:
          type:
            - string
            - 'null'
          description: Information about the folder.
        folders:
          type: array
          items:
            type: string
          description: A list of folders.
        requests:
          type: array
          items:
            type: string
          description: A list of requests.
        createdAt:
          type: string
          format: date-time
          description: The folder's creation date and time.
        updatedAt:
          type: string
          format: date-time
          description: The date and time at which the folder was last updated.
        collection:
          type: string
          description: The collection ID that the folder belongs to.
        description:
          type: string
          description: The folder's description.
        folders_order:
          type: array
          items:
            type: string
          description: A list of folder IDs and their order in the collection.
        lastUpdatedBy:
          type: string
          description: The user ID of the user that last updated the folder.
      description: >-
        Information about the collection folder. For a complete list of
        properties, refer to the [Postman Collection Format
        documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).
      title: CreateCollectionFolderResponseData
    createCollectionFolderResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/CreateCollectionFolderResponseData'
          description: >-
            Information about the collection folder. For a complete list of
            properties, refer to the [Postman Collection Format
            documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).
        meta:
          type: object
          additionalProperties:
            description: Any type
          description: >-
            A Postman-specific response that contains information about the
            internal performed operation.
        model_id:
          type: string
          description: The folder's ID.
        revision:
          type: number
          format: double
          description: >-
            An internal revision ID. Its value increments each time the resource
            changes. You can use this ID to track whether there were changes
            since the last time you fetched the resource.
      title: createCollectionFolderResponse
    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
    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
    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
    CreateCollectionFolderRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: CreateCollectionFolderRequestInternalServerError
  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

### Folder Created



**Request**

```json
undefined
```

**Response**

```json
{
  "data": {
    "id": "65a99e60-8e0a-4b6e-b79c-7d8264cc5caa",
    "name": "Test Folder",
    "order": [],
    "owner": "12345678",
    "folder": null,
    "folders": [],
    "requests": [],
    "createdAt": "2022-08-29T16:49:19.964Z",
    "updatedAt": "2022-08-29T16:49:19.964Z",
    "collection": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "description": "This is a test collection folder.",
    "folders_order": [],
    "lastUpdatedBy": "12345678"
  },
  "meta": {
    "action": "import",
    "model": "folder"
  },
  "model_id": "65a99e60-8e0a-4b6e-b79c-7d8264cc5caa",
  "revision": 24994132707
}
```

**SDK Code**

```python Folder Created
import requests

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

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

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

print(response.json())
```

```javascript Folder Created
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/folders';
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 Folder Created
package main

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

func main() {

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

	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 Folder Created
require 'uri'
require 'net/http'

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

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 Folder Created
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Folder Created
using RestSharp;

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

```swift Folder Created
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/folders")! 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()
```

### Create Folder



**Request**

```json
{
  "name": "Test Folder",
  "description": "This is a test collection folder."
}
```

**Response**

```json
{
  "data": {
    "id": "65a99e60-8e0a-4b6e-b79c-7d8264cc5caa",
    "name": "Test Folder",
    "order": [],
    "owner": "12345678",
    "folder": null,
    "folders": [],
    "requests": [],
    "createdAt": "2022-08-29T16:49:19.964Z",
    "updatedAt": "2022-08-29T16:49:19.964Z",
    "collection": "12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "description": "This is a test collection folder.",
    "folders_order": [],
    "lastUpdatedBy": "12345678"
  },
  "meta": {
    "action": "import",
    "model": "folder"
  },
  "model_id": "65a99e60-8e0a-4b6e-b79c-7d8264cc5caa",
  "revision": 24994132707
}
```

**SDK Code**

```python Create Folder
import requests

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

payload = {
    "name": "Test Folder",
    "description": "This is a test collection folder."
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create Folder
const url = 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/folders';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Test Folder","description":"This is a test collection folder."}'
};

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

```go Create Folder
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"name\": \"Test Folder\",\n  \"description\": \"This is a test collection folder.\"\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 Create Folder
require 'uri'
require 'net/http'

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

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  \"name\": \"Test Folder\",\n  \"description\": \"This is a test collection folder.\"\n}"

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

```java Create Folder
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/folders")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Test Folder\",\n  \"description\": \"This is a test collection folder.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/folders', [
  'body' => '{
  "name": "Test Folder",
  "description": "This is a test collection folder."
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Create Folder
using RestSharp;

var client = new RestClient("https://api.getpostman.com/collections/12ece9e1-2abf-4edc-8e34-de66e74114d2/folders");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Test Folder\",\n  \"description\": \"This is a test collection folder.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create Folder
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Test Folder",
  "description": "This is a test collection folder."
] 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/folders")! 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()
```