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

# Get an environment's forks

GET https://api.postman.com/environments/{environmentId}/forks

Gets all of an environment's forked environments.

Reference: https://learning.postman.com/api-docs/api-reference/environments/get-environment-forks

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

- `environmentId` (string, required) — The environment's unique ID.

### Query parameters

- `cursor` (string, optional) — The pointer to the first record of the set of paginated results. To view the next response, use the `nextCursor` value for this parameter.
- `direction` (enum, optional) — Sort results in ascending (`asc`) or descending (`desc`) order.
  - Allowed values: `asc`, `desc`
- `limit` (integer, optional, default: 10) — The maximum number of rows to return in the response.
- `sort` (enum, optional) — Sort the results by the date and time of creation.
  - Allowed values: `createdAt`

## Response

### 200

Successful Response

- `data` (list of environmentForkInfo, optional) — A list of the environment's forks.
- `meta` (environmentForksMeta, optional) — The response's meta information for paginated results.

## Errors

### 400 Bad Request Error

Bad Request

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

### 401 Unauthorized Error

Unauthorized

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

### 404 Not Found Error

Not Found

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

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

## Types

### environmentForkInfo

Information about the forked environment.

- `forkId` (string, optional) — The forked environment's unique ID.
- `forkName` (string, optional) — The forked environment's label.
- `createdAt` (datetime, optional) — The date and time at which the fork was created.
- `createdBy` (string, optional) — The user who created the environment fork.
- `updatedAt` (datetime, optional) — The date and time at which the fork was last updated.

### environmentForksMeta

The response's meta information for paginated results.

- `total` (double, optional) — The total number of forked environments.
- `nextCursor` (string, optional, nullable) — The pagination cursor that points to the next record in the results set.

### CommonErrorTypeTitleDetailDetail

Information about the error.

- string
- map from string to any

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

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

### CommonErrorNameMessageError

Information about the error.

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

## Examples

**Response**

```json
{
  "data": [
    {
      "forkId": "12345678-0fcea3ba-abcf-49c3-9f48-669c208fef25",
      "forkName": "Test Fork",
      "createdAt": "2024-01-30T16:42:22.000Z",
      "createdBy": "12345678",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "12345678-b7f0ded7-d614-4f74-baef-1006f6ab8a7b",
      "forkName": "Test Fork #2",
      "createdAt": "2024-01-30T16:39:25.000Z",
      "createdBy": "12345678",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "87654321-ed71be39-27b8-4886-bb74-77cb047d4fa6",
      "forkName": "My fork",
      "createdAt": "2024-01-30T16:39:17.000Z",
      "createdBy": "87654321",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "872905-c439ede2-4c40-4f25-82b2-a1a1219ead94",
      "forkName": "Alex Cruz's fork",
      "createdAt": "2024-01-30T16:39:09.000Z",
      "createdBy": "87654321",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "12345678-65c0a895-1428-45ea-bff0-f0f48e87f044",
      "forkName": "Taylor Lee's Fork",
      "createdAt": "2024-01-30T16:39:02.000Z",
      "createdBy": "12345678",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "87654321-3ad67987-91c4-4bd6-b624-348a5ea14e69",
      "forkName": "Test 1",
      "createdAt": "2024-01-30T16:38:52.000Z",
      "createdBy": "87654321",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "56781234-c7e91b68-c39e-4735-a103-da47c98a5f01",
      "forkName": "Test #2",
      "createdAt": "2024-01-30T16:38:27.000Z",
      "createdBy": "56781234",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "12345678-00dcac5b-e81a-4250-bb9a-7878df2a7a03",
      "forkName": "Test Fork #3",
      "createdAt": "2024-01-30T16:38:18.000Z",
      "createdBy": "12345678",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "87654321-6dd33d0c-36eb-4542-a5f2-bb2a70303f63",
      "forkName": "Alex Cruz's fork 1",
      "createdAt": "2024-01-30T16:38:10.000Z",
      "createdBy": "87654321",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "56781234-27eed2fc-8f05-4083-b8d4-55074bc49631",
      "forkName": "Test 2",
      "createdAt": "2024-01-30T16:38:01.000Z",
      "createdBy": "56781234",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "12345678-f96f3b83-3fc4-49a6-bd0b-6bf4162ac9f9",
      "forkName": "Taylor Lee's Fork 2",
      "createdAt": "2024-01-30T16:37:51.000Z",
      "createdBy": "12345678",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    },
    {
      "forkId": "56781234-69068628-c150-4b0e-a191-1e58a6be46c6",
      "forkName": "My fork 3",
      "createdAt": "2024-01-30T16:24:19.000Z",
      "createdBy": "56781234",
      "updatedAt": "2024-03-21T15:51:42.000Z"
    }
  ],
  "meta": {
    "total": 12,
    "nextCursor": "NTg3NjgtNTg3NTctNTg3NjgtNTAtY3JlYXRlZEF0LWRlc2MtZmFsc2UtLS0xLTEtMTItW1s1ODc2OCw1ODc1N11d"
  }
}
```

**SDK Code**

```python Successful Response
import requests

url = "https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks"

querystring = {"cursor":"RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk=","direction":"asc","limit":"10","sort":"createdAt"}

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

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

print(response.json())
```

```javascript Successful Response
const url = 'https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt';
const options = {method: 'GET', 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 Successful Response
package main

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

func main() {

	url := "https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt"

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

url = URI("https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt")

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

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

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.get("https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Successful Response
using RestSharp;

var client = new RestClient("https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Successful Response
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/environments/12345678-5daabc50-8451-43f6-922d-96b403b4f28e/forks?cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D&direction=asc&limit=10&sort=createdAt")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```