Send a custom header
Send a custom request header with curl -H 'Name: value'. A header with an empty value after a colon removes one of curl's defaults, such as User-Agent.
An API wants an extra header, such as a request id, and you want to see exactly which headers curl put on the wire.
curl -sv -H 'X-Request-Id: abc123' http://127.0.0.1:8000/index.txt -o /dev/null 2>&1 | grep '^>'
echo ---
curl -sv -H 'User-Agent:' -H 'Accept:' http://127.0.0.1:8000/index.txt -o /dev/null 2>&1 | grep '^>'> GET /index.txt HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/7.88.1
> Accept: */*
> X-Request-Id: abc123
>
---
> GET /index.txt HTTP/1.1
> Host: 127.0.0.1:8000
>Each -H adds one header line, and -v prints the request curl sent, with lines marked by a greater-than sign. A header name followed by a colon and no value tells curl to remove that header from its defaults, so the second run sends neither User-Agent nor Accept. The rules are in the curl manual, and a header ending in a semicolon, as in -H 'X-Empty;', sends the name with an empty value.
A header you set replaces curl's own of the same name, but not one added by a library or a proxy between you and the server. The output here is from curl 7.88 on Debian 12, and the default User-Agent string changes with the version.