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

POST https://api.postman.com/packages
Content-Type: application/json

Creates a package and its index script as a Postman Package Library resource.

Reference: https://learning.postman.com/api-docs/api-reference/packages/create-package

## Authentication

- `x-api-key` header (required)

## Servers

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

## Request

### Query parameters

- `workspace` (string, required) — The workspace's ID.

### Body (application/json)

- `name` (string, required) — The package's import name. The service stores this value in lowercase.
- `description` (string, optional, default: ) — The package's description. This value may be empty and only supports printable ASCII characters.
- `script` (string, optional, default: ) — The package's initial index script content. This value may be empty.

## Response

### 201

Package Created

- `id` (string, required) — The package's ID.
- `name` (string, required) — The package's immutable, lowercase import name.
- `description` (string, required) — The package's description. This value may be empty and only supports printable ASCII characters.
- `script` (string, required) — The package's current index script content. This value may be empty.
- `createdBy` (integer, required) — The user ID of the user who created the package.
- `createdAt` (datetime, required) — The date and time at which the package was created.
- `updatedAt` (datetime, required) — The date and time at which the package or its script was last updated.

## Examples

### Package Created

**Request**

```json
undefined
```

**Response**

```json
{
  "id": "3b60f5f3-cd98-4e04-b560-3eb039fe85d8",
  "name": "my-math-package",
  "description": "This package contains utility functions to do math.",
  "script": "module.exports = { add: (a, b) => a + b };",
  "createdBy": 12345678,
  "createdAt": "2026-08-01T20:11:17.000Z",
  "updatedAt": "2026-08-01T20:11:17.000Z"
}
```

**SDK Code**

```python Package Created
import requests

url = "https://api.postman.com/packages"

querystring = {"workspace":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"}

headers = {"x-api-key": "<apiKey>"}

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

print(response.json())
```

```javascript Package Created
const url = 'https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9';
const options = {method: 'POST', headers: {'x-api-key': '<apiKey>'}};

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

```go Package Created
package main

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

func main() {

	url := "https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Package Created
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Package Created
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Package Created
using RestSharp;

var client = new RestClient("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Package Created
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")! 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 Package

**Request**

```json
{
  "name": "my-math-package",
  "description": "This package contains utility functions to do math.",
  "script": "module.exports = { add: (a, b) => a + b };"
}
```

**Response**

```json
{
  "id": "3b60f5f3-cd98-4e04-b560-3eb039fe85d8",
  "name": "my-math-package",
  "description": "This package contains utility functions to do math.",
  "script": "module.exports = { add: (a, b) => a + b };",
  "createdBy": 12345678,
  "createdAt": "2026-08-01T20:11:17.000Z",
  "updatedAt": "2026-08-01T20:11:17.000Z"
}
```

**SDK Code**

```python Create Package
import requests

url = "https://api.postman.com/packages"

querystring = {"workspace":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"}

payload = {
    "name": "my-math-package",
    "description": "This package contains utility functions to do math.",
    "script": "module.exports = { add: (a, b) => a + b };"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create Package
const url = 'https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"my-math-package","description":"This package contains utility functions to do math.","script":"module.exports = { add: (a, b) => a + b };"}'
};

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

```go Create Package
package main

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

func main() {

	url := "https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"

	payload := strings.NewReader("{\n  \"name\": \"my-math-package\",\n  \"description\": \"This package contains utility functions to do math.\",\n  \"script\": \"module.exports = { add: (a, b) => a + b };\"\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 Package
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")

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\": \"my-math-package\",\n  \"description\": \"This package contains utility functions to do math.\",\n  \"script\": \"module.exports = { add: (a, b) => a + b };\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"my-math-package\",\n  \"description\": \"This package contains utility functions to do math.\",\n  \"script\": \"module.exports = { add: (a, b) => a + b };\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9', [
  'body' => '{
  "name": "my-math-package",
  "description": "This package contains utility functions to do math.",
  "script": "module.exports = { add: (a, b) => a + b };"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Create Package
using RestSharp;

var client = new RestClient("https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"my-math-package\",\n  \"description\": \"This package contains utility functions to do math.\",\n  \"script\": \"module.exports = { add: (a, b) => a + b };\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create Package
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "my-math-package",
  "description": "This package contains utility functions to do math.",
  "script": "module.exports = { add: (a, b) => a + b };"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/packages?workspace=1f0df51a-8658-4ee8-a2a1-d2567dfa09a9")! 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()
```