API and browser load tests often depend on request metadata as much as the URL or payload. In JMeter, the HTTP Header Manager supplies those request headers so HTTP samplers can send JSON content types, accepted media types, authorization values, or application-specific flags at the right scope.
The manager is a configuration element rather than a request sampler. Place it under a Thread Group when several child HTTP samplers need the same headers, or place it directly under one HTTP Request sampler when only that request should receive them.
Multiple HTTP Header Manager elements can apply to the same sampler. JMeter merges their rows for the outgoing request, and a later row with the same header name replaces the earlier value, which makes a shared default plus a sampler-specific override safer than copying every row into every request.
Steps to add a JMeter HTTP Header Manager:
- Open the test plan in the JMeter GUI.
- Select the scope that should send the headers.
Select the Thread Group for shared API headers. Select one HTTP Request sampler for request-specific headers.
- Add the header manager from Add → Config Element → HTTP Header Manager.
- Name the manager for the request group it controls.
- Add the required header rows.
Name: Content-Type Value: application/json Name: Accept Value: application/json Name: X-Test-Scenario Value: checkout-smoke
Use the exact header names expected by the target application. Header names are case-insensitive on the wire, but consistent casing keeps the test plan easier to review.
- Keep secret header values in variables instead of literal rows.
Name: Authorization Value: Bearer ${api_token}Do not save live bearer tokens, session cookies, or private API keys in a shared .jmx file. Load them from a variable source or command-line property when the plan runs.
Related: How to add a bearer token header in JMeter - Add request-specific overrides under the sampler that needs them.
If two applicable header managers define the same header name, the matching row replaces the previous value during the merge. An empty value still sends the header with an empty value; it does not remove the earlier row.
- Save the test plan.
header-manager-add.jmx
- Run a one-user non-GUI smoke test.
$ jmeter -n -t header-manager-add.jmx -l header-manager-results.jtl Creating summariser <summary> Created the tree successfully using header-manager-add.jmx ##### snipped ##### Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445 summary = 1 in 00:00:00 = 11.5/s Avg: 16 Min: 16 Max: 16 Err: 0 (0.00%) Tidying up ... ... end of run
- Check the result file for a successful sample.
$ cat header-manager-results.jtl timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect 1782776110247,16,POST /checkout,200,OK,Checkout API smoke users 1-1,text,true,,107,254,1,1,https://api.example.net/checkout,13,0,11
- Check the target server log or request inspector for the received headers.
$ cat header-echo-server.log method=POST path=/checkout content_type=application/json accept=application/json x_test_scenario=checkout-smoke status=200
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.