curl commands

21 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 21 shown

  • curl -s -X POST https://api.example.com/v1/resource -H 'Content-Type: application/json' -H 'Authorization: Bearer <token>' -d '{"key":"value"}' | jq .

    Send a JSON POST request with Bearer auth

    network

  • curl -sLv https://example.com 2>&1 | grep -E '^[<>*]'

    Show full request/response headers including redirects

    network · debug

  • curl -so /dev/null -w 'DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://example.com

    Measure DNS, connect, and TTFB timing

    network · debug

  • curl -L --progress-bar -o output.file https://example.com/file.tar.gz

    Download a file showing a clean progress bar

    network

  • curl -s -u user:password https://api.example.com/endpoint | jq .

    HTTP request with Basic Authentication

    network

  • curl -so /dev/null -w '%{http_code}' https://example.com

    Get just the response status code — useful in scripts

    network · debug

  • curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -d '{"name":"foo"}'

    Send JSON payload via POST

  • curl -H 'Authorization: Bearer $TOKEN' https://api.example.com/me

    Attach JWT/Bearer token in Authorization header

    security

  • curl -Lv --max-redirs 5 https://example.com

    Follow up to 5 redirects and show full request/response

    debug

  • curl -sSL -o /tmp/result.json https://api.example.com/data

    Download silently, fail on error, follow redirects

  • curl -o /dev/null -sS -w 'ttfb: %{time_starttransfer}s\ntotal: %{time_total}s\n' https://example.com

    Benchmark TTFB and total request time

    monitoring

  • curl -sI https://example.com

    Print HTTP response headers without body

    debug

  • curl -F 'file=@./report.pdf' -F 'user=alice' https://upload.example.com/api

    Multipart form-data upload with extra fields

  • curl --http2 -sI https://example.com | grep -i 'http\|alt-svc'

    Force HTTP/2 and check protocol in response

    network

  • curl --resolve example.com:443:1.2.3.4 https://example.com

    Override DNS for a host:port pair (test behind CDN/LB)

    network · debug

  • curl --retry 5 --retry-delay 2 --retry-all-errors https://api.example.com/healthz

    Retry up to 5 times with 2s delay on any error

  • curl -d 'user=alice&pass=secret' -X POST https://auth.example.com/login

    Send URL-encoded form data

  • curl --cert client.crt --key client.key --cacert ca.crt https://secure.example.com

    mTLS request with client cert and custom CA

    security

  • cat urls.txt | xargs -P 5 -I{} curl -sSL -o /dev/null -w '%{url_effective} %{http_code}\n' {}

    Download 5 URLs in parallel and print status codes

  • curl -i -N -H 'Upgrade: websocket' -H 'Connection: Upgrade' -H 'Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==' -H 'Sec-WebSocket-Version: 13' http://localhost:8080/ws

    Verify WebSocket upgrade handshake responds with 101

    network · debug

  • curl --limit-rate 1M -O https://example.com/bigfile.iso

    Limit download bandwidth to 1 MB/s