The command
curl -A "my-app/1.4 (ops@example.com)" https://httpbin.org/user-agent
Opens the request console with this request filled in. It is sent from api-tester.com's server rather than from your machine, so it shows what the endpoint returns, not how your own network or curl build behaves.
What the flags do
| Flag | What it does |
|---|---|
-A string | Set the User-Agent. Long form: --user-agent. |
-H "User-Agent: string" | Does the same thing through the generic header flag. |
-A "" | Send no User-Agent header at all. |
The default and how to change it
Out of the box curl sends User-Agent: curl/ followed by its version number. -A replaces that for one command. To change it for every command, put a user-agent = "..." line in ~/.curlrc.
For your own scripts and bots, identify the software and give a way to contact you. Operators are far more willing to raise a limit or whitelist a client that says who it is than one pretending to be Chrome.
curl https://httpbin.org/user-agent # {"user-agent": "curl/8.x.x"}
curl -A "inventory-sync/2.1 (+https://example.com/bot)" https://httpbin.org/user-agent
curl -A "" -v -o /dev/null https://httpbin.org/get # no User-Agent line
Testing what a browser would get
Servers sometimes return different markup, redirects or even status codes depending on the User-Agent: a mobile layout, a bot-detection page, a 403. Sending a browser's string reproduces that branch from the terminal.
It only goes so far. Bot detection also looks at header order, TLS handshake details and whether JavaScript runs, none of which a User-Agent string changes. If a site still refuses a request that carries a browser string, the User-Agent was not what it was checking.
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36" \
-I https://example.com/
Common mistakes
- The User-Agent is not authentication. Anyone can send any string; never gate access on it.
- With
-Lthe same User-Agent is sent on every hop, including to other hosts. - Some APIs require one. A request with an empty or missing User-Agent can be rejected with
403.
Related curl examples
Curl Send Header Example
-H adds a header line to the request.
Curl GET Request Example
GET is what curl does when you give it nothing but a URL.
Curl Send Cookies Example
Curl ignores cookies unless told otherwise.
Curl Follow Redirect Example
Curl does not follow redirects unless asked.
All Curl Examples
49 worked examples, grouped by what you are trying to do.
More under Headers
References
- curl man page: -A — Setting the User-Agent string.
- MDN: User-Agent — The header's format and why sniffing it is unreliable.
These links leave api-tester.com, which is independent of the projects they point to.
FAQ
How do I set the user agent in curl?
Use -A followed by the string, for example curl -A "my-app/1.0" URL. -H "User-Agent: my-app/1.0" is equivalent.
What is the default curl user agent?
curl/ followed by the version number, for example curl/8.5.0.
Why does a website block my curl request?
Some servers reject the default curl User-Agent or apply bot detection. Setting a descriptive User-Agent may help, but detection that inspects TLS and headers cannot be bypassed by changing the string alone.