> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/postman-codegen.md).

# postman-codegen

You can use the `demisto-sdk postman-codegen` command to generate an integration (YAML file) from a Postman Collection v2.1. Note the generated integration is in the YAML format.

<details>

<summary>Generate the Integration</summary>

You can generate the integration either as a two-step process or a single step.

* Single step - Use this method to generate directly an integration YAML file.
* Two steps - Use this method if you need more configuration and customization of the generated integration and code.
  * Generate an integration config file.
  * Update the config file as needed.
  * Generate the integration from the config file using the `demisto-sdk generate-integration` command.

</details>

<details>

<summary>Arguments</summary>

| `-h`, `--help`                    | Show command help.                                                                                                                  |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `-i`, `--input`                   | Postman collection 2.1 JSON file.                                                                                                   |
| `-o`, `--output`                  | (Optional) The output directory. Default is the current directory.                                                                  |
| `-n`, `--name`                    | (Optional) Sets the integration name.                                                                                               |
| `-op`, `--output-prefix`          | (Optional) Sets the global integration output prefix. Default is the integration name without spaces and special characters.        |
| `-cp`, `--command-prefix`         | (Optional) The prefix for every command in the integration. Default is the integration name in lowercase.                           |
| `--config-out`                    | (Optional) If passed, generates a config JSON file for further integration customization.                                           |
| `-clt`, `--console-log-threshold` | Minimum logging threshold for the console logger. Default value is `INFO`. Possible values are `DEBUG`, `INFO`, `WARNING`, `ERROR`. |
| `-flt`, `--file-log-threshold`    | Minimum logging threshold for the file logger. Default value is `DEBUG`. Possible values are `DEBUG`, `INFO`, `WARNING`, `ERROR`.   |
| `-lp`, `--log-file-path`          | Path to the log file. Default path is `<CONTENT_PATH>/demisto_sdk_debug.log`.                                                       |

</details>

<details>

<summary>How the command converts the Postman collection</summary>

* Collection name converts to integration name.
* Collection name converts to command prefix (if command prefix is not passed).

  Example: `Virus Total` becomes `virus-total`
* Collection name converts to prefix of each command output.

  Example: `Virus&& Total` becomes `VirusTotal.Scan.scan_id`
* Collection request name converts to integration command.

  Example: `Get Hosts` becomes `get-hosts`
* Authentication
  * Base authentication type converts to `username`/`password` parameter.
  * API Key authentication type converts to `apikey` encrypted parameter.
  * Bearer token authentication type converts to `apikey` encrypted parameter.
* Request name converts to command name.

  Example: `Get Events` becomes `get-events`
* Request URL variables convert to command arguments and are passed as part of the request URL.

  Example: `https://virustotal.com/vtapi/v2/ip/{{ip}}` becomes the created `ip` argument `https://virustotal.com/vtapi/v2/ip/8.8.8.8`.
* Request query parameters convert to command arguments.

  Example: `https://virustotal.com/vtapi/v2/ip?resource=8.8.8.8` becomes the created `resource` argument.
* Path URL variable converts to a command argument and passed as a part of the request URL.

  Example: `https://virustotal.com/vtapi/v2/ip/:ip` becomes the `ip` argument `https://virustotal.com/vtapi/v2/ip/8.8.8.8` if `:ip` path variable equals `8.8.8.8`.
* Request body. Each leaf value converts to a command argument and `body_format` which allows further body customization.

  Example: `{"key1":"val1","key2":{"key3":"val3"}}` becomes created `key1` and `key3` arguments and `body_format` with the following value `{"key1":"{{key1}}","key2":{"key3":"{{key3}}"}}`
* Response JSON output converts to command outputs.

</details>

<details>

<summary>Postman collection requirements</summary>

#### Mandatory requirements

* Collection v2.1 is supported.
* Each request should be saved and contain at least one successful response, which is also saved.
* If a URL contains variables such as `https://virustotal.com/vtapi/v2/ip/8.8.8.8`, set it as variable such as `https://virustotal.com/vtapi/v2/ip/{{ip}}` .
* Define the authentication method under Collection edit page > `Authorization` section.
  * Under collection settings, we recommend setting the `Authorization` section.
  * Requests must contain `Authorization` header.

#### Optional requirements

* Collection description.
* Short request names `Get Endpoints` converts to `get-endpoints`  .
* Set description to request.

</details>

<details>

<summary>Examples</summary>

{% code overflow="wrap" %}

```programlisting
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' --command-prefix vt
```

{% endcode %}

This command does the following:

* Sets the name of the integration to `Virus Total`.
* Sets the `command` prefix to `vt` (`vt-get-url`, `vt-scan-url`).
* Generates the `integration-VirusTotal.yml` file in the current directory.

{% code overflow="wrap" %}

```programlisting
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' -o /output/path --config-out
```

{% endcode %}

This command does the following:

* Generates `config-VirusTotal.json` file under the `/output/path` directory.
* Sets the name of the integration to `Virus Total`.

</details>

<details>

<summary>File examples</summary>

* [URLScan Postman Collection v2.1](https://github.com/demisto/demisto-sdk/blob/master/demisto_sdk/commands/postman_codegen/resources/urlscan.io.postman_collection.json)
* [URLScan generated config file](https://github.com/demisto/demisto-sdk/blob/master/demisto_sdk/commands/postman_codegen/resources/config-urlscanio.json)
* [URLScan generated integration yml](https://github.com/demisto/demisto-sdk/blob/master/demisto_sdk/commands/postman_codegen/resources/integration-urlscanio.yml)

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/postman-codegen.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
