Skip to main content
Send Web Request

How to Make an HTTP Request with cURL

cURL is a command-line tool for making HTTP requests. It's available on most systems (Linux, macOS, Windows) and is widely used for API testing, scripting, and debugging. No installation is needed on most Unix-like systems—it's often pre-installed.

GET request example

Making a GET request to fetch data with custom headers:

curl -X GET "https://api.example.com/users" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

POST request example

Making a POST request to send JSON data:

curl -X POST "https://api.example.com/users" \
  -H "Content-Type: application/json" \
  -d '{"name": "John", "email": "john@example.com"}'

PUT request example

Replacing a resource with PUT:

curl -X PUT "https://api.example.com/users/123" \
  -H "Content-Type: application/json" \
  -d '{"name": "John Updated", "email": "john.new@example.com"}'

PATCH request example

Partially updating a resource with PATCH:

curl -X PATCH "https://api.example.com/users/123" \
  -H "Content-Type: application/json" \
  -d '{"email": "john.updated@example.com"}'

DELETE request example

Deleting a resource:

curl -X DELETE "https://api.example.com/users/123" \
  -H "Authorization: Bearer YOUR_TOKEN"

Error handling

Check the HTTP status code with -w '%{http_code}' or inspect the response. Use -s for silent mode (no progress) and -S to show errors. For production scripts, always verify the status before assuming success.

# Get status code and body
HTTP_CODE=$(curl -s -o /tmp/response.json -w "%{http_code}" "https://api.example.com/users")
if [ "$HTTP_CODE" -eq 200 ]; then
  cat /tmp/response.json
else
  echo "Error: HTTP $HTTP_CODE"
fi

Try it in Send Web Request

You can run these cURL commands directly in Send Web Request. Paste any curl command and we'll parse it—or build your request visually and export it as curl.

Open Send Web Request

Other libraries you can try