curl Cheatsheet
Power user.
Overview
curl is the universal HTTP client for command-line work, present on every Unix box and most container images. Five primitives carry most operational use: method support across the full HTTP verb set, header control, body shaping by content type, TLS debugging, and output control for scripting. Fluency turns "is the API up?" into a one-liner instead of a Postman session.
- Method support. GET, POST, PUT, PATCH, DELETE via
-X. Full-API access from the shell. - Headers.
-Hsets request headers. Supports auth (Bearer, Basic), content-type, custom headers. - Body data.
-dform data,--data-rawarbitrary,-Fmultipart. Match the content type, not the other way around. - TLS debug plus output control.
-vshows the TLS handshake;--cacertspecifies CA bundle;-o,-s,-wshape output for scripting.
The approach
Verbose first when debugging, silent with format string when scripting. Five idioms cover most operational curl use; memorising them turns API troubleshooting into a 30-second exercise.
curl -v. Verbose mode shows headers, TLS handshake, redirects. First move on every debug session.curl -s -w "%{http_code}\n". Silent mode with status code output. Scriptable health checks.curl -H "Authorization: Bearer $TOKEN". Header-based auth. Replaces deprecated-ufor API tokens.- JSON POST plus follow redirects.
curl --data-raw '{"key":"value"}' -H "Content-Type: application/json"; add-Lto follow redirects like a browser.
Why this compounds
Each curl one-liner that lands in muscle memory shortens the next API debug. Reusable scripts turn smoke tests, health checks, and deploy verification into command-line operations the team owns. By year two, curl is the first tool reached for any HTTP question and Postman becomes the optional GUI it always should have been.
- Faster API debugging. One-liners replace GUI clicks. Investigation latency drops.
- Reusable scripts. Health checks, smoke tests, deploy verification. Operations scale without new tooling.
- TLS expertise.
curl -vteaches the TLS handshake one investigation at a time. Network knowledge grows. - Year-one investment, year-two habit. First year builds fluency; by year two, curl is the reflexive first tool for HTTP investigations.