Referer, a custom User-Agent, a cookie), pass a headers dictionary to get, post, or put.
What happens when you pass headers
As soon as you pass aheaders argument, the SDK automatically sets custom_headers=True in the request params for you, so you don’t need to add that yourself. This tells ZenRows to use your headers for the target request instead of its own defaults.
Overriding the default User-Agent
The SDK sends its ownUser-Agent (zenrows/<version> python) on every request so ZenRows can identify SDK traffic. If you include a User-Agent key in your headers dictionary, it replaces this default:
Combining with params
headers and params are independent arguments, so you can use both together:
If a request keeps failing after you add custom headers, try removing them first to confirm whether they’re the cause. ZenRows’ defaults are usually the safer starting point.
Troubleshooting
- Success rate drops after adding custom headers: This is expected per the warning above. Remove your custom
headersfirst to confirm whether they’re the cause; ZenRows’ defaults are usually the safer starting point. - Header doesn’t seem to reach the target site: Confirm you’re using the SDK’s
headersargument (forwarded to the target) and not accidentally modifying request options meant for ZenRows itself, likeparams. - Cookies aren’t persisting across requests: Each SDK call is a separate, stateless request. Pass the
Cookieheader explicitly on every call if you need to maintain a session. custom_headersshows up unexpectedly in logs/requests: This is set automatically whenever you pass a non-emptyheadersdictionary; it’s not something you need to remove.
Pricing
Custom headers don’t change the cost multiplier on their own. Cost still depends onjs_render and premium_proxy:
| Configuration | Cost multiplier vs. basic |
|---|---|
| Basic request | 1x |
js_render=True | 5x |
premium_proxy=True | 10x |
js_render=True + premium_proxy=True | 25x |
FAQ (Frequently Asked Questions)
Do I need to set custom_headers myself?
Do I need to set custom_headers myself?
No. Passing a non-empty
headers dictionary to get, post, or put sets custom_headers=True automatically.Will my custom headers always be used exactly as sent?
Will my custom headers always be used exactly as sent?
Yes, ZenRows forwards them to the target as provided. This is precisely why overriding them can lower success rates on protected sites; you lose ZenRows’ tuned defaults.
Can I set headers meant for ZenRows itself (like an API version header)?
Can I set headers meant for ZenRows itself (like an API version header)?
No.
headers is forwarded to the target website, not to ZenRows’ API. ZenRows-specific options belong in params.