Request commands
This topic covers request testing commands for the Postman CLI.
postman request
Use the postman request command to test and debug HTTP requests from the command line with the Postman CLI. Use many of Postman’s features for sending requests, including authentication, environment variables, test assertions, and more. The command accepts the request’s method (GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS) as the first argument, defaulting to GET if a method isn’t provided. The command accepts the target URL as the second argument.
In Postman, you can also convert an API request into a Postman CLI code snippet. Copy the generated code snippet, add options to help you test your request, then send the request with the Postman CLI.
Usage
The HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS).
The target URL for the request.
Options
Specifies the authentication type and parameters. Supports the following authentication types: basic, bearer, digest, oauth1, oauth2, hawk, aws, ntlm, and apikey. For example: --auth-basic-username user --auth-basic-password pass or --auth-apikey-key "X-API-Key" --auth-apikey-value "abc123" --auth-apikey-in header
Specifies request body content. Supports inline string or @filepath syntax for files. For example: --body '{"name": "John"}' or --body @data.json
Shows detailed information in debug mode, including retry attempts, redirects, and timing breakdowns.
Specifies an environment file path or UUID. Resolves variables in the URL, headers, and body.
Specifies multipart/form-data in key=value format. Use @filepath syntax for files. Can be used multiple times. For example: -f "name=John" or -f "avatar=@photo.jpg"
Specifies a header in key-value format. Can be used multiple times. For example: -H Content-Type:application/json
Saves the complete response to a JSON file, including status, headers, body, and more. Use for debugging or further processing.
Suppresses all output except the response body. This is useful for piping to other commands.
Preserves the original HTTP method when 3xx redirect responses. Redirects are followed with the GET method by default.
Prevents the Postman CLI from automatically following 3xx redirect responses. Redirects are followed by default.
Specifies the maximum number of 3xx redirect responses to follow. There is no limit by default. Useful for preventing redirect loops.
Removes the Referer header when following 3xx redirect responses. The Referer header is sent with redirects by default.
Specifies the number of retry attempts for failed requests, like a 400 Bad Request code. Useful for unreliable endpoints or rate limited APIs.
Specifies the time (in milliseconds) to wait to retry the request.
Adds JavaScript that runs after the request runs. Supports inline JavaScript or @filepath syntax for files. Learn more about writing post-response scripts. For example: --script-post-request "console.log(pm.response.json());"
Adds JavaScript that runs before the request runs. Supports inline JavaScript or @filepath syntax for files. Learn more about writing pre-request scripts. For example: --script-pre-request "pm.environment.set('timestamp', Date.now());"
Specifies the time (in milliseconds) to wait for the request to complete.
Shows detailed information for the request and response, including headers, body, and metadata.