? Working with Headers in Postman
? Quick Overview
HTTP headers are key-value pairs sent along with requests and responses. In Postman, headers such as Content-Type, Authorization, and Custom Headers help define how data is sent, secured, and interpreted by servers.
? Key Concepts
- Content-Type – Defines the media type of the request body
- Authorization – Carries credentials or tokens
- Custom Headers – Application-specific metadata
- Headers are case-insensitive
- Multiple headers can be sent in a single request
? Syntax / Theory
In HTTP, headers follow a simple format:
Header-Name: Header-Value
Postman automatically manages some headers, but you can add or override them manually in the Headers tab.
? Code Example(s)
? View Code Example
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
X-Custom-Client: PostmanDemo
? Live Output / Explanation
What Happens?
- Content-Type tells the server to expect JSON data
- Authorization sends a Bearer token for secured APIs
- X-Custom-Client is a user-defined header for tracking or logic
?️ Interactive Example
Use the inputs below to simulate adding headers to a request.
GET /api/v1/users HTTP/1.1
Host: api.example.com
// Headers you add will appear here...
? View Code Example
const headers = {
"Content-Type": "application/json",
"Authorization": "Bearer demo_token",
"X-App-Version": "1.0.0"
};
console.log(headers);
? Use Cases
- Sending JSON or XML data to REST APIs
- Authenticating requests using tokens or API keys
- Passing versioning or client information
- Feature toggles and A/B testing via headers
? Tips & Best Practices
- Let Postman auto-generate headers when possible
- Avoid sending sensitive data in custom headers unnecessarily
- Use environment variables for tokens
- Keep header names meaningful and consistent
? Try It Yourself
- Create a new request in Postman
- Add
Content-Type: application/json
- Add a dummy
Authorization token
- Send the request to a public API like
https://httpbin.org/headers
- Observe the headers echoed back in the response