curl flags & options
-X, --request
Set the HTTP method. Defaults to GET.
curl -X POST https://api.example.com/data
curl -X DELETE https://api.example.com/items/1
-H, --header
Add a custom request header.
curl -H "Content-Type: application/json" https://api.example.com
curl -H "Authorization: Bearer TOKEN" https://api.example.com
-d, --data
Send data in a POST request body. Automatically sets method to POST.
curl -d '{"key":"value"}' -H "Content-Type: application/json" https://api.example.com
curl -d "user=joe&pass=secret" https://example.com/login
-o, --output
Write output to a file instead of stdout.
curl -o page.html https://example.com
curl -o /dev/null -s -w "%{http_code}" https://example.com
-O, --remote-name
Save file using the remote filename.
curl -O https://example.com/file.tar.gz
-L, --location
Follow redirects (3xx responses).
curl -L https://example.com/short-link
-v, --verbose
Show detailed request and response info including headers.
curl -v https://example.com
-s, --silent
Suppress progress meter and error messages.
curl -s https://api.example.com/data | jq .
-f, --fail
Return an error code (22) on HTTP errors instead of outputting the error page.
curl -f https://example.com/missing || echo "Request failed"
-I, --head
Fetch headers only (HEAD request).
curl -I https://example.com
-k, --insecure
Skip TLS certificate verification. Useful for self-signed certs in development.
curl -k https://localhost:8443/api
-u, --user
Provide username and password for server authentication.
curl -u user:password https://api.example.com/private