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

# Transform collection to OpenAPI

GET https://api.getpostman.com/collections/{collectionId}/transformations

Transforms an existing Postman Collection into a stringified OpenAPI definition.

**Note:**

This does not create an API.


Reference: https://learning.postman.com/api-docs/api-reference/collections/transform-collection-to-open-api

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /collections/{collectionId}/transformations:
    get:
      operationId: transformCollectionToOpenAPI
      summary: Transform collection to OpenAPI
      description: >
        Transforms an existing Postman Collection into a stringified OpenAPI
        definition.


        **Note:**


        This does not create an API.
      tags:
        - collections
      parameters:
        - name: collectionId
          in: path
          description: The collection's ID.
          required: true
          schema:
            $ref: '#/components/schemas/collectionId'
        - name: format
          in: query
          description: Return the OpenAPI definition in the given format.
          required: false
          schema:
            $ref: '#/components/schemas/collectionTransformFormat'
            default: json
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/transformCollectionToOpenAPI'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatusInstance'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatusInstance'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatusInstance'
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
    collectionTransformFormat:
      type: string
      enum:
        - json
        - yaml
      default: json
      title: collectionTransformFormat
    transformCollectionToOpenAPI:
      type: object
      properties:
        output:
          type: string
          description: >-
            The collection's transformed output, in a stringified OpenAPI JSON
            or YAML format.
      title: transformCollectionToOpenAPI
    commonErrorTypeTitleDetailStatusInstance:
      type: object
      properties:
        type:
          type: string
          format: uri-reference
          description: >-
            The [URI reference](https://www.rfc-editor.org/rfc/rfc3986) that
            identifies the type of problem.
        title:
          type: string
          description: A short summary of the problem.
        detail:
          type: string
          description: An explanation about the problem.
        status:
          type: integer
          description: The HTTP status code generated by the origin server.
        instance:
          type: string
          description: >-
            The URI reference that identifies the specific occurrence of the
            problem.
      title: commonErrorTypeTitleDetailStatusInstance
  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 JSON Response



**Response**

```json
{
  "output": "{\n  \"openapi\": \"3.0.3\",\n  \"info\": {\n    \"title\": \"Sample API\",\n    \"description\": \"Buy or rent spacecrafts\\n\\nContact Support:\\n Name: Jon\",\n    \"version\": \"1.0.0\",\n    \"contact\": {}\n  },\n  \"servers\": [\n    {\n      \"url\": \"example.com\"\n    }\n  ],\n  \"paths\": {\n    \"/spacecrafts/{spacecraftId}\": {\n      \"get\": {\n        \"tags\": [\n          \"spacecrafts\",\n          \"{spacecraftId}\"\n        ],\n        \"summary\": \"Read a spacecraft\",\n        \"description\": \"Read a spacecraft\",\n        \"operationId\": \"readASpacecraft\",\n        \"responses\": {\n          \"200\": {\n            \"description\": \"The spacecraft corresponding to the provided `spacecraftId`\",\n            \"content\": {\n              \"application/json\": {\n                \"schema\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"description\": {\n                      \"type\": \"string\",\n                      \"example\": \"<string>\"\n                    },\n                    \"id\": {\n                      \"type\": \"string\",\n                      \"example\": \"<string>\"\n                    },\n                    \"name\": {\n                      \"type\": \"string\",\n                      \"example\": \"<string>\"\n                    },\n                    \"type\": {\n                      \"type\": \"string\",\n                      \"example\": \"satellite\"\n                    }\n                  }\n                },\n                \"examples\": {\n                  \"The spacecraft corresponding to the provided `spacecraftId`\": {\n                    \"value\": {\n                      \"description\": \"<string>\",\n                      \"id\": \"<string>\",\n                      \"name\": \"<string>\",\n                      \"type\": \"satellite\"\n                    }\n                  }\n                }\n              }\n            }\n          },\n          \"404\": {\n            \"description\": \"No spacecraft found for the provided `spacecraftId`\",\n            \"content\": {\n              \"application/json\": {\n                \"schema\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"message\": {\n                      \"type\": \"string\",\n                      \"example\": \"<string>\"\n                    }\n                  }\n                },\n                \"examples\": {\n                  \"No spacecraft found for the provided `spacecraftId`\": {\n                    \"value\": {\n                      \"message\": \"<string>\"\n                    }\n                  }\n                }\n              }\n            }\n          },\n          \"500\": {\n            \"description\": \"Unexpected error\",\n            \"content\": {\n              \"application/json\": {\n                \"schema\": {\n                  \"type\": \"object\",\n                  \"properties\": {\n                    \"message\": {\n                      \"type\": \"string\",\n                      \"example\": \"<string>\"\n                    }\n                  }\n                },\n                \"examples\": {\n                  \"Unexpected error\": {\n                    \"value\": {\n                      \"message\": \"<string>\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      },\n      \"parameters\": [\n        {\n          \"name\": \"spacecraftId\",\n          \"in\": \"path\",\n          \"required\": true,\n          \"schema\": {\n            \"type\": \"string\",\n            \"example\": \"<string>\"\n          },\n          \"description\": \"(Required) The unique identifier of the spacecraft\"\n        }\n      ]\n    }\n  },\n  \"components\": {\n    \"securitySchemes\": {\n      \"apiKey\": {\n        \"type\": \"apiKey\",\n        \"name\": \"X-Api-Key\",\n        \"in\": \"header\"\n      }\n    }\n  },\n  \"security\": [\n    {\n      \"apiKey\": []\n    }\n  ],\n  \"tags\": [\n    {\n      \"name\": \"spacecrafts\"\n    },\n    {\n      \"name\": \"{spacecraftId}\"\n    }\n  ]\n}"
}
```

**SDK Code**

```python Successful JSON Response
import requests

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

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

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

print(response.json())
```

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

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

func main() {

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

	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 JSON Response
require 'uri'
require 'net/http'

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

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

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Successful JSON Response
using RestSharp;

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

```swift Successful JSON Response
import Foundation

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

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

### Successful YAML Response



**Response**

```json
{
  "output": "openapi: 3.0.3\ninfo:\n  title: Sample API\n  description: |-\n    Buy or rent spacecrafts\n\n    Contact Support:\n     Name: Jon\n  version: 1.0.0\n  contact: {}\nservers:\n  - url: example.com\npaths:\n  /spacecrafts/{spacecraftId}:\n    get:\n      tags:\n        - spacecrafts\n        - \"{spacecraftId}\"\n      summary: Read a spacecraft\n      description: Read a spacecraft\n      operationId: readASpacecraft\n      responses:\n        \"200\":\n          description: The spacecraft corresponding to the provided `spacecraftId`\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  description:\n                    type: string\n                    example: <string>\n                  id:\n                    type: string\n                    example: <string>\n                  name:\n                    type: string\n                    example: <string>\n                  type:\n                    type: string\n                    example: satellite\n              examples:\n                The spacecraft corresponding to the provided `spacecraftId`:\n                  value:\n                    description: <string>\n                    id: <string>\n                    name: <string>\n                    type: satellite\n        \"404\":\n          description: No spacecraft found for the provided `spacecraftId`\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  message:\n                    type: string\n                    example: <string>\n              examples:\n                No spacecraft found for the provided `spacecraftId`:\n                  value:\n                    message: <string>\n        \"500\":\n          description: Unexpected error\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  message:\n                    type: string\n                    example: <string>\n              examples:\n                Unexpected error:\n                  value:\n                    message: <string>\n    parameters:\n      - name: spacecraftId\n        in: path\n        required: true\n        schema:\n          type: string\n          example: <string>\n        description: (Required) The unique identifier of the spacecraft\ncomponents:\n  securitySchemes:\n    apiKey:\n      type: apiKey\n      name: X-Api-Key\n      in: header\nsecurity:\n  - apiKey: []\ntags:\n  - name: spacecrafts\n  - name: \"{spacecraftId}\"\n"
}
```

**SDK Code**

```python Successful YAML Response
import requests

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

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

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

print(response.json())
```

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

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

func main() {

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

	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 YAML Response
require 'uri'
require 'net/http'

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

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

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Successful YAML Response
using RestSharp;

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

```swift Successful YAML Response
import Foundation

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

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