curl Deep Dive: HTTP Requests from the Command Line
Master curl for API testing, debugging, and automation—from basic requests to advanced authentication and scripting.
February 25, 2026 · 8 min · 1541 words · Rob Washington
Table of Contents
curl is the universal language of HTTP. Every API doc includes curl examples. Every debugging session starts with “can you curl it?” If you’re not comfortable with curl, you’re missing the most portable tool in your kit.
# Single filecurl -X POST https://api.example.com/upload \
-F "file=@document.pdf"# Multiple filescurl -X POST https://api.example.com/upload \
-F "file1=@doc1.pdf"\
-F "file2=@doc2.pdf"# File with custom filenamecurl -X POST https://api.example.com/upload \
-F "file=@localname.pdf;filename=remote.pdf"# File with content typecurl -X POST https://api.example.com/upload \
-F "file=@image.png;type=image/png"# Mixed form data and filescurl -X POST https://api.example.com/upload \
-F "title=My Document"\
-F "file=@document.pdf"
# Save to filecurl -o output.html https://example.com
# Save with remote filenamecurl -O https://example.com/file.zip
# Save multiple filescurl -O https://example.com/file1.zip -O https://example.com/file2.zip
# Append to filecurl https://example.com >> output.txt
# Write headers to filecurl -D headers.txt https://example.com
# Output to stdout and filecurl https://example.com | tee output.html
# Send cookiecurl -b "session=abc123" https://api.example.com
# Send cookies from filecurl -b cookies.txt https://api.example.com
# Save cookies to filecurl -c cookies.txt https://api.example.com/login
# Full session (save and send)curl -b cookies.txt -c cookies.txt https://api.example.com
-X METHOD # HTTP method-H "Header"# Add header-d "data"# POST data-F "field=val"# Form/file upload-o file # Output to file-O # Output to remote filename-i # Include response headers-I # Headers only-s # Silent-S # Show errors (with -s)-v # Verbose-L # Follow redirects-u user:pass # Basic auth-b cookies # Send cookies-c cookies # Save cookies-m seconds # Max time-k # Insecure (skip cert verify)-x proxy # Use proxy-w "format"# Custom output format--json "data"# POST JSON (7.82+)
curl is more than a download tool—it’s a complete HTTP client that fits in your terminal. Learn it well, and you’ll never need Postman for a quick test again.
Start with simple GETs, graduate to authenticated POSTs, and eventually you’ll be scripting entire API workflows from the command line.
📬 Get the Newsletter
Weekly insights on DevOps, automation, and CLI mastery. No spam, unsubscribe anytime.