Postman CLI dataset commands (postman dataset)
Postman CLI dataset commands (postman dataset)
This topic covers dataset commands for the Postman CLI.
Datasets enable you to define reusable data sources and views for use in Postman workflows. You can use dataset commands to create and manage datasets, configure data sources, run SQL queries, and run saved views.
Each dataset command works with either a local dataset file or a cloud dataset stored in a Postman workspace:
- Local — Specify the path to a
.dataset.yamlfile. - Cloud — Specify the dataset’s ID.
A dataset stores a definition, not your data: where the data lives, what each source is named, and the SQL that shapes your views. It doesn’t copy your rows into the manifest, which is why a .dataset.yaml file stays small.
- A view stores only its query. Rows are recomputed from the source each time you run it.
- A source is a pointer to your data: a database connection or a file path. Two cases store a copy instead:
- Adding a local file copies it into a
.resources/folder next to the dataset. - Uploading a file to a cloud dataset stores the file in Postman.
- Adding a local file copies it into a
To run a collection with a dataset or a saved view, use the --iteration-data-dataset, --iteration-data-view, and --dataset options with the postman collection run command. To learn more, see Collection commands.
Commands that work with a cloud dataset authenticate with your postman login session by default. To authenticate a single command with a specific Postman API key instead, pass the --api-key <key> option:
A Postman API key used to authenticate a cloud dataset command, instead of your postman login session.
postman dataset create
Creates a new dataset.
To use this command with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
Usage
To create a local dataset file, provide the path where you want to create it. To create a cloud dataset, omit this argument and use the -w, --workspace option instead.
Options
The dataset name.
A description for the dataset.
(Local only) Unique identifier for the dataset. If not provided, a random v4 UUID is generated. A cloud dataset assigns its own ID.
The Postman workspace ID in which to create a cloud dataset.
Overwrites an existing dataset file.
Examples
postman dataset list
Lists datasets.
To use this command with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
Usage
To list local datasets, provide the path to a dataset file or a directory that contains one or more dataset files. To list cloud datasets, omit this argument and use the -w, --workspace option instead.
Options
The Postman workspace ID whose cloud datasets you want to list.
Displays results in JSON format.
Examples
postman dataset get
Displays metadata and a structure summary for a dataset.
To use this command with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
Usage
Path to a local dataset file or a cloud dataset ID.
Options
(Cloud only) Skips fetching the dataset’s data sources and views, returning only its top-level metadata. If you don’t need the full structure, this can help make the command faster.
Displays results in JSON format.
Examples
postman dataset query
Runs a SQL query against a dataset.
To use this command with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
Usage
Path to a local dataset file or a cloud dataset ID.
Options
The SQL query to run.
Provides a value for a positional placeholder in the query. The first -p value fills $1, the second fills $2, and so on. Repeat the option to pass multiple values, for example -p value1 -p value2.
Displays query results in JSON format.
Shows detailed debug output for the query.
Examples
postman dataset jdbc
Inspect a JDBC driver before you attach it to a dataset.
postman dataset jdbc inspect
Reports what a JDBC driver JAR contains, so you know what to pass when you add a custom data source. The command detects your Java runtime, lists every driver class in the JAR, suggests a URL template, lists that template’s variables, and lists the connection properties the driver accepts.
Java 8 or newer must be installed on the computer running the command.
Usage
Path to one or more JDBC driver JAR files to inspect. List a dependency JAR’s path after the primary driver JAR when the driver needs it to resolve classes.
Options
Inspects this driver class instead of selecting one automatically. Use it when the JAR contains more than one driver class.
Reports variables for this URL template instead of the one inferred from the JAR file name.
The Java runtime to use. This value stays on your computer and is never written to a dataset. Also read from the POSTMAN_JDBC_JAVA_PATH environment variable.
Returns the result as JSON instead of prose.
Examples
Inspect a driver JAR:
Inspect a driver that has several dependency JAR files:
The report maps directly onto the options you pass to postman dataset source add:
postman dataset source
Manage the data sources associated with a dataset.
A dataset can contain multiple data sources. You specify the dataset with the -d, --dataset option, and commands that act on a specific source also take its name or ID as an argument.
To use these commands with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
postman dataset source list
Lists the data sources associated with a dataset.
Usage
Options
Path to a local dataset file or a cloud dataset ID.
Displays results in JSON format.
Examples
postman dataset source add
Adds a data source to a dataset.
Usage
Options
Path to a local dataset file or a cloud dataset ID.
The data source name. This becomes the SQL table name. Not required, and ignored, for a spreadsheet source: see --file.
(Local only) Unique identifier for the data source. If not provided, a random v4 UUID is generated. A cloud dataset assigns its own source ID.
Specifies the source type. If not provided, the type is inferred from --file for a local source or from --driver-jar for a JDBC source.
Path to a local file to add as a source: CSV, JSON, or a spreadsheet (.xlsx, .xls, or .ods). For a cloud dataset, the file is registered as a local file source unless you also pass --upload.
A spreadsheet adds every worksheet in the workbook as its own source, each named source_<worksheet>, and -n, --name is ignored. A single-sheet workbook still produces one source.
Overrides the format the CLI infers for the data source. By default, the format comes from the file extension (.csv, .json, .xlsx, .xls, or .ods) or the source type.
(Cloud only) Uploads the file from --file to Postman and stores it as a cloud file source. Without --upload, the file stays on your computer and is registered as a local file source instead.
(Local only) References the source file in place without copying it into the dataset resources directory.
(Local only) Overwrites a file of the same name that’s already in the dataset’s resources directory. Use this when you’re replacing a source file you added before. Without it, the copy fails because the file already exists.
The following options configure a database source and apply with --type mysql, --type postgresql, or --type sqlserver.
Database host name.
Database port number. Defaults to 1433 for SQL Server.
Database user name.
Database password.
Database name.
Database table name. Required for SQL Server.
Database schema. Applies to PostgreSQL and SQL Server. Defaults to dbo for SQL Server.
The following options apply to SQL Server sources (--type sqlserver) and configure the TLS connection.
Whether to use TLS encryption for the SQL Server connection.
The minimum TLS version to use for the SQL Server connection.
Path to the CA or server certificate file for the SQL Server connection.
Overrides the host name expected in the SQL Server certificate.
Whether to skip verification of the SQL Server certificate. Skipping verification is insecure. Use it only for trusted local testing.
The following options configure a custom JDBC data source and apply with --type jdbc. You supply the driver, and the machine running the command needs Java 8 or newer. To find a driver’s classes, properties, and a suggested URL template before you add the source, use postman dataset jdbc inspect.
Path to a JDBC driver JAR file. Repeat the option, or pass several paths after one flag, to add dependency JAR files. Java resolves classes in the order the files are listed.
Postman saves these paths in the dataset. Later commands that query the data source look for the driver at the saved path, so keep the file where it is or update the source with postman dataset source update.
The fully qualified driver class name. Resolved automatically when the JAR contains exactly one driver class.
Label for this driver type in the dataset.
The JDBC URL with {{placeholder}} variables, such as jdbc:postgresql://{{host}}:{{port}}/{{database}}.
A value for a {{placeholder}} in the URL template. Repeatable. Use vault:<vault-id>/<secret-id> to reference a Shared Vault secret instead of a literal value.
A driver connection property. Repeatable, and accepts the same vault: syntax as --var.
Path to a JSON file of --var values, or - to read them from stdin. Each value can be a literal, or a {"$vaultId": "<vault-id>", "$secretId": "<secret-id>"} object to reference a Shared Vault secret. This keeps secrets out of the command line entirely.
Reuses the driver JAR, driver class, and URL template from another source in the same dataset.
The Java runtime to use. This value stays on your computer and is never written to the dataset. Also read from the POSTMAN_JDBC_JAVA_PATH environment variable.
Skips the connection test that runs before the source is written. Resolving the driver class still starts Java, so on a computer without Java, pass --driver-class or --from-source as well.
A literal value passed to --var or --prop is visible in your shell history and in ps output, and it’s stored as plain text in the dataset file (for a local dataset) or sent in the request body (for a cloud dataset). Use a vault: reference or --vars-file for credentials.
To connect to a database through an SSH bastion host (an SSH tunnel), use the following options.
The SSH bastion host.
The SSH bastion port.
The SSH bastion user.
Path to the SSH private key. The key contents are read locally when the command runs and aren’t stored in the dataset configuration.
The SSH bastion’s public host key.
The Shared Vault ID that contains the SSH public host key.
The Shared Vault secret ID that contains the SSH public host key.
Turns off SSH host-key verification. This is insecure. Use it only for trusted local testing.
Passing --user or --password on the command line stores the value as plain text in the dataset file (for a local dataset) or sends it in the request body (for a cloud dataset), and exposes it in your shell history and process list. Because these credentials aren’t protected, use a database account limited to read-only access to only the data this source needs, rather than a privileged account.
Examples
postman dataset source update
Updates an existing data source. Only the options you provide are updated.
Usage
The data source name or unique identifier.
Options
Path to a local dataset file or a cloud dataset ID.
To update the source configuration, this command supports the same options as postman dataset source add. You can update connection details for a database source, or change the file for a file-based source.
Examples
postman dataset source remove
Removes a data source from a dataset.
Usage
The data source name or unique identifier.
Options
Path to a local dataset file or a cloud dataset ID.
Examples
postman dataset view
Dataset view commands enable you to create, manage, and run saved SQL queries. A dataset can contain multiple views. You specify the dataset with the -d, --dataset option, and commands that act on a specific view also take the view’s name or ID as an argument. To learn more, see Example dataset views in Postman.
To use these commands with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
postman dataset view list
Lists saved views in a dataset.
Usage
Options
Path to a local dataset file or a cloud dataset ID.
Displays results in JSON format.
Examples
postman dataset view create
Saves a view to a dataset.
Usage
Options
Path to a local dataset file or a cloud dataset ID.
The view name.
The SQL query.
(Local only) Unique identifier for the view. If not provided, a random v4 UUID is generated. A cloud dataset assigns its own view ID.
Examples
postman dataset view update
Updates a saved view. Only the options you provide are updated.
Usage
The view name or unique identifier.
Options
Path to a local dataset file or a cloud dataset ID.
A new name for the view.
A new SQL query for the view.
Examples
postman dataset view delete
Deletes a saved view from a dataset.
Usage
The view name or unique identifier.
Options
Path to a local dataset file or a cloud dataset ID.
Examples
postman dataset view run
Runs a saved view against a dataset and displays the rows.
Usage
The view name or unique identifier.
Options
Path to a local dataset file or a cloud dataset ID.
Provides a value for a positional placeholder in the view’s query. The first -p value fills $1, the second fills $2, and so on. Repeat the option to pass multiple values, for example -p value1 -p value2.
Displays query results in JSON format.
Shows detailed debug output for the view run.
Examples
postman dataset delete
Deletes a dataset.
To use this command with a cloud dataset, sign in to Postman with the postman login command, or pass the --api-key <key> option to use a specific API key.
Usage
Path to a local dataset file or a cloud dataset ID.
Options
Skips the confirmation prompt.
(Local only) Deletes the dataset file but preserves the associated resources directory, which holds your copied source files. Use this when you want to remove the dataset definition but keep its data, or when another dataset in the same directory shares those files.