Networking & API
Updated for 2026

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.

Target Version Compatibility

Interactive Skill Mastery

Mark commands as learned to build your customized reference tracker. Retained locally in this browser.

Level:Novice
Command Mastery Progress0 of 15 Mastered (0%)

HTTP Methods

curl https://api.example.com/users
BeginnerBasics
Perform a default HTTP GET request to retrieve resource data.

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/users

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -X POST https://api.example.com/users
BeginnerBasics
Perform an HTTP POST request to submit 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 -X POST https://api.example.com/users

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -X PUT https://api.example.com/users/1
BeginnerBasics
Perform an HTTP PUT request to replace or update a resource.

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/1

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -X DELETE https://api.example.com/users/1
AdvancedRecovery
Perform an HTTP DELETE request to remove a resource.

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/1

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}

Headers & Auth

curl -H "Accept: application/json" https://api.example.com
BeginnerBasics
Send a custom request header to specify accepted media types.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -H "Authorization: Bearer <token>" https://api.example.com
AdvancedSecurity
Authenticate requests using a Bearer JWT/OAuth token.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -u username:password https://api.example.com
BeginnerBasics
Authenticate using HTTP Basic Authentication.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}

Sending Data

curl -d "param1=value1&param2=value2" https://api.example.com
BeginnerBasics
Submit standard url-encoded form data (implies POST method).

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&param2=value2" https://api.example.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -H "Content-Type: application/json" -d '{"key":"value"}' https://api.example.com
BeginnerBasics
Submit a JSON raw payload with correct content-type header.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}

File Operations

curl -o filename.zip https://example.com/file.zip
BeginnerBasics
Download a remote file and save it locally with a specified name.

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.zip

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -O https://example.com/file.zip
BeginnerBasics
Download a remote file and save it using its remote filename.

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.zip

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -F "file=@/path/to/local/file.jpg" https://api.example.com/upload
BeginnerBasics
Upload a file using multipart/form-data POST submission.

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/upload

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}

Debugging & Verbose

curl -v https://api.example.com
IntermediateDebugging
Enable verbose mode to inspect full request and response handshake streams.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -I https://api.example.com
IntermediateDebugging
Fetch only the response headers (HEAD request) to audit headers or response codes.

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.com

Output Example

Console / Terminal
HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success","message":"Request parsed successfully"}
curl -k https://api.example.com
IntermediateDebugging
Perform insecure connections, skipping SSL certificate validation.

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.com

Output Example

Console / Terminal
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

Error

curl: (6) Could not resolve host

Solution

The DNS server failed to resolve the domain name. Solution: Verify your network connection and double-check domain name spelling.

Error

curl: (60) SSL certificate problem

Solution

The server's SSL certificate is self-signed, expired, or untrusted. Solution: Install required CA certificates, or use -k cautiously for local testing only.

Error

415 Unsupported Media Type

Solution

The server rejected the payload format. Solution: Explicitly declare '-H "Content-Type: application/json"' when sending JSON raw payloads.

Error

curl: (7) Failed to connect

Solution

The remote server is offline, or a firewall is blocking the specified port. Solution: Check server host statuses and port settings.

Error

curl: (52) Empty reply from server

Solution

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.