Postman Tutorial for Beginners: API Testing Step by Step
Postman is the tool most testers open first when a developer says “the API is ready”. It lets you send any request in seconds, save it, share it with the team and later turn it into automated tests. In this Postman tutorial you’ll go from installation to a complete, reusable collection for a real API, with environments, variables, authentication and request chaining, using the free SQA Tools practice API at every step.
{{baseUrl}}, {{token}}), an Authorization tab (Basic, API key, Bearer, OAuth 2.0), scripts for assertions and chaining, the Collection Runner for data-driven runs, and Newman for running collections in CI.Why Testers Use Postman
- No code needed to start: fill in method, URL and body, click Send.
- Organised: collections and folders mirror the API structure; everyone uses the same requests.
- Reusable: variables and environments mean one collection works on dev, QA and staging.
- Testable: JavaScript test scripts turn requests into automated checks.
- Shareable: export collections as JSON, share workspaces, generate documentation.
- CI-ready: Newman runs collections from the command line in Jenkins or GitHub Actions.
Install Postman and Understand the Interface
- Download the desktop app from postman.com (Windows, macOS, Linux) or use the web version. A free account syncs your work.
- Create a workspace (personal or team) for your project.
| Area | What it’s for |
|---|---|
| Sidebar | Collections, Environments, History, APIs, Flows |
| Request tabs | Method dropdown, URL bar, Send button |
| Request sub-tabs | Params, Authorization, Headers, Body, Scripts (Pre-request / Post-response), Settings |
| Response panel | Body (Pretty/Raw/Preview), Cookies, Headers, Test Results, status, time and size |
| Environment selector | Top right: choose the active environment |
| Console (bottom) | Raw request/response log: your best debugging friend |
Send Your First Request
- Click New → HTTP (or the + tab).
- Method: GET. URL:
https://sqatools.in/wp-json/sqa-api/v1/users - Click Send. Check status 200 OK, time and size in the response panel.
- Open the Headers tab of the response: find
X-Total-Count: 12and theLinkheader.
Here’s the same request in your browser to compare:
https://sqatools.in/wp-json/sqa-api/v1/users?role=admincurl -i \
"https://sqatools.in/wp-json/sqa-api/v1/users?role=admin"Query parameters with the Params tab
Instead of typing ?role=admin&sort=age, add rows in Params: key role value admin, key sort value age. Postman builds and encodes the URL. Untick a row to disable it temporarily: handy for negative tests.
POST with a JSON Body
- New request, method POST, URL
https://sqatools.in/wp-json/sqa-api/v1/objects - Body → raw → JSON, then paste:
{ "name": "Postman test object", "data": { "color": "blue", "qty": 3 }, "ttl": 300 } - Send. Expect 201 Created. Postman added
Content-Type: application/jsonautomatically (see the hidden headers in the Headers tab). - Copy the
idfrom the response; you’ll use it next with PUT, PATCH and DELETE.
Collections: Organise Your Requests
A collection is a folder of saved requests, with shared variables, auth and scripts.
- Click Collections → + and name it “SQA Practice API”.
- Add folders: Users, Products, Objects CRUD, Auth, Negative tests.
- Save each request (Ctrl/Cmd + S) into a folder with a clear name, e.g. “POST create object – 201”.
Shortcut: the API Testing Practice page has a Postman collection button that downloads a ready-made collection for this API. In Postman click Import and drop the file in.
Variables and Environments
Hardcoding https://sqatools.in/wp-json/sqa-api/v1 into 50 requests is painful when the team moves to a staging server. Use variables.
Create an environment
- Environments → +, name it “SQA Practice”.
- Add variable
baseUrl=https://sqatools.in/wp-json/sqa-api/v1. - Add
username=adminandpassword=admin@123; set the password type to secret. - Select the environment in the top-right dropdown.
- Change your request URLs to
{{baseUrl}}/users,{{baseUrl}}/objects…
baseUrl, client ids and test users. The same collection runs against any of them by switching the dropdown, with no edits to requests.Variable scopes (narrowest wins)
| Scope | Lives in | Use for |
|---|---|---|
| Global | Whole workspace | Rarely; quick experiments |
| Collection | One collection | Values fixed for this API (api version, page size) |
| Environment | Selected environment | Per-server values: baseUrl, users, keys |
| Data | CSV/JSON file in a run | Data-driven testing |
| Local | One request execution | Temporary values from scripts |
If the same name exists in several scopes, the narrower one (local, then data, then environment, then collection, then global) wins.
Authorization Tab
Set auth once at the collection level and let requests Inherit auth from parent.
| Practice endpoint | Postman Authorization type | Values |
|---|---|---|
/basic/profile | Basic Auth | sqa_user / sqa@123 |
/apikey/profile | API Key | Key X-API-Key, value sqa-key-12345, add to Header |
/auth/me | Bearer Token | {{access_token}} |
| OAuth 2.0 APIs | OAuth 2.0 | Grant type, token URL, client id/secret, scope; “Get New Access Token” |
Postman shows the header it generates (e.g. Authorization: Basic c3FhX3VzZXI6c3FhQDEyMw==) under the Headers tab’s hidden headers.
Request Chaining: Use Data from One Response in the Next
Real flows need values from earlier responses: a token from login, an id from create. In the Scripts → Post-response tab of the login request:
const body = pm.response.json();
pm.environment.set('access_token', body.access_token);
And in “POST create object”:
pm.collectionVariables.set('objectId', pm.response.json().id);
Then GET {{baseUrl}}/objects/{{objectId}}, PATCH {{baseUrl}}/objects/{{objectId}} and DELETE {{baseUrl}}/objects/{{objectId}} just work, in order. Run the folder with the Collection Runner and you have an end-to-end CRUD flow.
Dynamic variables
Postman has built-in random data: {{$randomFirstName}}, {{$randomEmail}}, {{$randomInt}}, {{$guid}}, {{$timestamp}}. Use them so every run creates unique data:
{ "name": "{{$randomProductName}}", "data": { "ref": "{{$guid}}" }, "ttl": 120 }
A Quick Look at Tests (Assertions)
Add checks in Scripts → Post-response:
pm.test('status is 201', () => pm.response.to.have.status(201));
pm.test('has Location header', () => pm.response.to.have.header('Location'));
pm.test('name echoed back', () => {
pm.expect(pm.response.json().name).to.eql('Postman test object');
});
Results appear in the Test Results tab. Writing powerful scripts, schema validation, data-driven runs and Newman are covered in the next lesson: Postman Tests, Scripts and Newman.
Useful Postman Features Testers Forget
- Console (View → Show Postman Console): the exact request sent, after variables were resolved. Check here first when something “doesn’t work”.
- Code snippet (
</>icon): converts a request into cURL, Python, JavaScript and more. Paste cURL into bug reports. - Import cURL: paste a developer’s cURL command into Import to get a ready request.
- Import OpenAPI: generates a whole collection from a Swagger file.
- Settings per request: disable “Automatically follow redirects” to test 3xx codes; set request timeout.
- Mock servers: fake an API from saved examples so front-end and tests can start early.
- Postbot (AI assistant): generates test scripts and documentation from responses. Review what it writes.
Postman Practice Exercises
- Build a collection with folders Users, Products, Objects, Auth using
{{baseUrl}}. - GET page 2 of users with 5 per page; confirm ids 6 to 10.
- Filter products by
category=books; then trycategory=toys(expect 400). - Create an object, save its id with a script, then PATCH, GET and DELETE it in a chained run.
- Call
/basic/profile,/apikey/profileand/auth/mewith each auth type; then each with wrong credentials. - Turn off “follow redirects” and GET
/redirect: confirm 302 and the Location header. - Create a second environment “SQA Practice – broken” with a wrong baseUrl and see how errors look.
Interview Questions: Postman
What is Postman used for in API testing?
Sending HTTP requests and inspecting responses, organising requests into collections, managing environments and variables, writing JavaScript test scripts, chaining requests, running data-driven collections, mocking APIs, generating documentation and running collections in CI with Newman.
What is a collection in Postman?
A group of saved requests organised in folders, with shared variables, authorization and scripts. It can be run with the Collection Runner or Newman and exported as JSON.
What is the difference between environment and global variables?
Environment variables belong to a selected environment such as DEV or QA and change when you switch environments. Global variables are available across the whole workspace regardless of environment. Environment variables are preferred for server-specific values.
What are the variable scopes in Postman and their precedence?
Global, collection, environment, data and local. When names clash, the narrowest scope wins: local, then data, then environment, then collection, then global.
How do you pass data from one request to another?
In the first request’s post-response script, read the value with pm.response.json() and store it with pm.environment.set or pm.collectionVariables.set, then reference it as {{variableName}} in later requests.
How do you handle authentication in Postman?
Use the Authorization tab with the right type (Basic, API Key, Bearer Token, OAuth 2.0), usually set at collection level and inherited by requests. Tokens are often obtained by a login request whose script stores the token in a variable.
How do you test redirects in Postman?
Disable “Automatically follow redirects” in the request settings, then assert the 3xx status and the Location header.
How do you share a Postman collection with your team?
Use a shared team workspace, or export the collection and environment as JSON files and store them in the project’s Git repository. Never share environments with real secrets.
What is the Postman Console used for?
It shows the exact raw requests and responses, including resolved variables, headers and script logs. It’s the first place to debug unexpected results.
What are Postman dynamic variables?
Built-in random data generators such as {{$guid}}, {{$timestamp}}, {{$randomEmail}} and {{$randomInt}}, used to create unique test data on every run.