For the complete documentation index, see llms.txt. This page is also available as Markdown.
Cortex XSOAR 6.xCortex XSOAR 8 (SaaS)Cortex XSOAR 8.x (On-premCortex XSIAM

postman-codegen

The postman-codegen command generates an integration file (YAML) from a Postman Collection.

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.

Generate the Integration

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.

Arguments

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

How the command converts the Postman collection
  • 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.

Postman collection requirements

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.

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

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.

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

This command does the following:

  • Generates config-VirusTotal.json file under the /output/path directory.

  • Sets the name of the integration to Virus Total.

File examples

Last updated

Was this helpful?