Keep Repeated curl Options in a Config File with -K
Keep repeated curl options in a file and load it with -K, or read options from standard input with -K -. Headers set that way stay out of the process list.
The same long list of headers and flags goes into every call, and you would rather not repeat them or leave a token on the command line.
cat > api.cfg <<'EOF'
silent
header = "X-Token: abc123"
url = "http://localhost:8000/items"
EOF
curl -K api.cfg -v 2>&1 | grep -i '^> x-token'
echo 'header = "X-Key: s3cret"' | curl -K - -sv http://localhost:8000/ 2>&1 | grep -i '^> x-key'> X-Token: abc123
> X-Key: s3cretA config file holds one option per line, written without the leading dashes, with header = "..." and url = "..." as examples. The -v output shows that X-Token: abc123 was sent from the file. With -K - curl reads the same syntax from standard input, so a secret can be piped in and never appears in the arguments that ps lists. See --config in the manual.
A config file with a token in it needs mode 600 like any credential. Options on the command line are added to the ones in the file and not replaced, and curl also reads ~/.curlrc first unless you pass -q as the first argument.