cURL Commands & HTTP Request Cheatsheet 2026
Essential cURL commands for making GET/POST requests, sending custom headers, form data, JSON payloads, authentication, and debugging connections.
Interactive Skill Mastery
Mark commands as learned to build your customized reference tracker. Retained locally in this browser.
HTTP Methods
When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl https://api.example.com/usersOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When submitting custom payloads, JSON data, or URL-encoded forms to create or process server resources.
Common Mistakes
Sending raw JSON payloads without declaring the correct Content-Type header (application/json), leading to 415 media errors.
Shortcut / Pro-Tip
Use '-d @filename.json' to submit large JSON structures saved in local project files.Example
curl -X POST https://api.example.com/usersOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -X PUT https://api.example.com/users/1Output Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -X DELETE https://api.example.com/users/1Output Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}Headers & Auth
When to Use
When setting custom request headers, declaring bearer tokens, cookies, or user agents to authenticate API calls.
Common Mistakes
Passing authorization tokens with typo keys or incorrect capitalization, resulting in 401 Unauthorized codes.
Shortcut / Pro-Tip
Use '-I' alongside your headers to view only the response header payload for quick debugging.Example
curl -H "Accept: application/json" https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When setting custom request headers, declaring bearer tokens, cookies, or user agents to authenticate API calls.
Common Mistakes
Passing authorization tokens with typo keys or incorrect capitalization, resulting in 401 Unauthorized codes.
Shortcut / Pro-Tip
Use '-I' alongside your headers to view only the response header payload for quick debugging.Example
curl -H "Authorization: Bearer <token>" https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -u username:password https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}Sending Data
When to Use
When submitting custom payloads, JSON data, or URL-encoded forms to create or process server resources.
Common Mistakes
Sending raw JSON payloads without declaring the correct Content-Type header (application/json), leading to 415 media errors.
Shortcut / Pro-Tip
Use '-d @filename.json' to submit large JSON structures saved in local project files.Example
curl -d "param1=value1¶m2=value2" https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When submitting custom payloads, JSON data, or URL-encoded forms to create or process server resources.
Common Mistakes
Sending raw JSON payloads without declaring the correct Content-Type header (application/json), leading to 415 media errors.
Shortcut / Pro-Tip
Use '-d @filename.json' to submit large JSON structures saved in local project files.Example
curl -H "Content-Type: application/json" -d '{"key":"value"}' https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}File Operations
When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -o filename.zip https://example.com/file.zipOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -O https://example.com/file.zipOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -F "file=@/path/to/local/file.jpg" https://api.example.com/uploadOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}Debugging & Verbose
When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -v https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -I https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}When to Use
When testing, calling, and debugging REST/GraphQL API endpoints or downloading remote resources directly from a terminal.
Common Mistakes
Forgetting to wrap complex URLs containing queries/ampersands inside single or double quotes, causing terminal execution splits.
Shortcut / Pro-Tip
Combine options like 'curl -sSL' to follow redirects automatically and mute bulky loading bars.Example
curl -k https://api.example.comOutput Example
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"success","message":"Request parsed successfully"}cURL Best Practices
1Always Quote URLs
Wrap request URLs in quotes to prevent terminals from interpreting query delimiters (like & or ?) as background job operators.
2Use Silent/Quiet Flags in Automation
In automated shell scripts, append the '-s' or '--silent' option to suppress download progress bars from cluttering logs.
3Strict SSL Verifications
Never use the '-k' or '--insecure' option in production scripts. Keep SSL certification verification active to prevent man-in-the-middle attacks.
4Dump Headers for Debugging
Use the '-v' or '--verbose' options to audit both outbound request headers and inbound response headers together.
5Format API Payloads Clearly
Write clean, multiline data options or read raw payload files (e.g., -d @data.json) to keep complex CLI commands structured and editable.
Common cURL Errors & Solutions
curl: (6) Could not resolve host
The DNS server failed to resolve the domain name. Solution: Verify your network connection and double-check domain name spelling.
curl: (60) SSL certificate problem
The server's SSL certificate is self-signed, expired, or untrusted. Solution: Install required CA certificates, or use -k cautiously for local testing only.
415 Unsupported Media Type
The server rejected the payload format. Solution: Explicitly declare '-H "Content-Type: application/json"' when sending JSON raw payloads.
curl: (7) Failed to connect
The remote server is offline, or a firewall is blocking the specified port. Solution: Check server host statuses and port settings.
curl: (52) Empty reply from server
The server closed the socket connection without returning any response. Solution: Inspect server logs to find internal crashes or connection limits.
Common cURL Interview Questions
Q1What is cURL and what is its primary purpose?
cURL (client URL) is a robust command-line tool and library used to transfer data to or from a server using various protocols (including HTTP, HTTPS, FTP, etc.), commonly used for testing REST APIs.
Q2How do you send a custom header in a cURL request?
Use the -H or --header option followed by the header name and value in quotes, e.g. -H "Content-Type: application/json".
Q3What is the difference between -o and -O options in cURL?
-o (lowercase) allows you to specify a custom local filename to save the downloaded content. -O (uppercase) saves the file using its remote filename from the target URL.
Q4How can you inspect response headers without fetching the body?
Use the -I (or --head) option to issue an HTTP HEAD request, returning only the server response headers.
Q5How do you handle redirects in cURL?
By default, cURL does not follow HTTP redirects. You must pass the -L (or --location) flag to tell cURL to follow any 3xx redirection headers automatically.
Related Resources
REST API Tester
Test API routes and endpoints directly in your browser with full request controls.
JSON Formatter & Validator
Beautify, validate, and minify JSON structures instantly.
Best Free Online Developer Tools
An expert review of must-have online utilities for developers.
Git Cheatsheet
Essential command reference for local and remote version control repositories.
Generated from LearnHubly Developer Cheatsheets
Access interactive sandbox tests, tools, and developer code bases at https://www.learnhubly.com