# curl command cheat sheet: flags and examples for APIs

Source: https://checkcraft.ru/en/guides/curl-cheat-sheet.html · updated 2026-12-02

A curl cheat sheet: the main flags -X, -H, -d, -u, -o, -L, -i, -v, -k, -x with examples.

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

curl is a command-line program for HTTP requests, available on Linux, macOS and Windows 10 and 11. One command shows whether an API answers, what it returns and which headers arrive. Below is a table of the flags you need nine times out of ten, ready commands for each case and links to detailed guides.

Checkcraft · 24 November 2026

Get help with your first test →

## How a curl command is built

A command is the word curl, flags and a URL. Flags go in any order; quote the URL because the shell treats ampersands and question marks specially. With no flags curl sends a GET and prints the response body.

## Where to start checking an API

First a request with -i: you see the status code and headers. If there is no answer or it looks odd, the same request with -v shows the connection, TLS and what actually went to the server. In scripts add -sS to hide the progress meter but keep errors, and -f so an HTTP error ends the command with a non-zero code.

Repeating checks like this by hand? Checkcraft saves them and reruns them in one click. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## From a one-off command to a repeatable check

curl answers what the server returned right now. It does not check whether the answer is correct: amounts, statuses and fields must be compared separately. When the same request runs after every change, move it into a saved check with expectations.

## Main curl flags

| Flag | What it does | Example |
|---|---|---|
| -X METHOD | Request method | -X DELETE |
| -H | Request header, repeatable | -H "Accept: application/json" |
| -d | Request body, method becomes POST | -d '{"qty":2}' |
| --json | JSON body with the right headers, curl 7.82+ | --json '{"qty":2}' |
| -G --data-urlencode | Encoded query parameters | -G --data-urlencode "q=monitor 24" |
| -u | Login and password, Basic auth | -u user:password |
| -F | Form with fields and files | -F "file=@photo.png" |
| -i | Show status and response headers with the body | -i |
| -I | HEAD request, headers only | -I |
| -v | Verbose: connection, TLS, headers | -v |
| -o and -O | Save the response to a file | -o report.zip |
| -L | Follow redirects | -L |
| -sS | No progress meter, errors kept | -sS |
| -f | Exit code 22 on HTTP 400 and above | -f |
| -w | Print status code, timing and more | -w "%{http_code}" |
| --connect-timeout, --max-time | Connection and total timeouts | --max-time 30 |
| -x | Proxy | -x http://proxy:3128 |
| -b and -c | Send and save cookies | -b "session=abc" |
| -k | Skip certificate checks, diagnostics only | -k |

## Ready commands

```
# GET с параметрами
curl "https://api.example.com/v1/orders?status=new&limit=10"

# POST с JSON и токеном
curl -X POST https://api.example.com/v1/orders \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"sku":"MON-24","qty":2}'

# PUT и DELETE
curl -X PUT https://api.example.com/v1/orders/5001 -H "Content-Type: application/json" -d '{"status":"SHIPPED"}'
curl -X DELETE https://api.example.com/v1/orders/5001

# код ответа и заголовки
curl -i https://api.example.com/v1/orders/5001

# только код ответа
curl -s -o /dev/null -w "%{http_code}\n" https://api.example.com/health

# загрузить файл формой
curl -F "file=@report.pdf" -F "comment=отчёт" https://api.example.com/v1/upload

# скачать файл, пройти редиректы, не сохранять страницу ошибки
curl -fL -o report.zip https://files.example.com/download?id=42
```

In Windows PowerShell type curl.exe and avoid single quotes around JSON: see [curl on Windows and PowerShell](https://checkcraft.ru/en/guides/curl-windows-powershell.html).

## Checking a response in a script

```
#!/bin/sh
# проверка в скрипте: код ответа и поле из JSON (нужна утилита jq)
body=$(curl -sS -f --max-time 30 https://api.example.com/v1/orders/5001) || { echo "запрос не прошёл"; exit 1; }
status=$(echo "$body" | jq -r '.status')
[ "$status" = "PAID" ] || { echo "ожидали PAID, пришло $status"; exit 1; }
echo "ок"
```

Such a script suits one or two checks. With dozens of checks and readable reports, saved rules work better: see [HTTP response checks](https://checkcraft.ru/en/guides/http-response-checks.html).

## All guides in the curl section

- [curl GET request: parameters, response headers and status code](https://checkcraft.ru/en/guides/curl-get-request.html)
- [cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell](https://checkcraft.ru/en/guides/curl-post-json.html)
- [Headers in curl: Content-Type application/json, Accept and multiple -H](https://checkcraft.ru/en/guides/curl-headers-content-type.html)
- [curl with authorization: Bearer token, Basic, API key and headers](https://checkcraft.ru/en/guides/curl-authorization-header.html)
- [curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them](https://checkcraft.ru/en/guides/curl-errors.html)
- [curl on Windows and PowerShell: how to run it and why commands fail](https://checkcraft.ru/en/guides/curl-windows-powershell.html)
- [Download a file with curl: -o, -O, redirects and resume](https://checkcraft.ru/en/guides/curl-download-file.html)
- [curl through a proxy: -x, environment variables, SOCKS and no_proxy](https://checkcraft.ru/en/guides/curl-proxy.html)
- [PHP cURL: GET and POST requests with JSON, headers and error handling](https://checkcraft.ru/en/guides/php-curl.html)
- [Webhook: what it is, how it works and how to test it](https://checkcraft.ru/en/guides/webhook-testing.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[curl man page](https://curl.se/docs/manpage.html)

## Continue with a related task

[curl GET request: parameters, response headers and status code](https://checkcraft.ru/en/guides/curl-get-request.html) · [cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell](https://checkcraft.ru/en/guides/curl-post-json.html) · [curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them](https://checkcraft.ru/en/guides/curl-errors.html) · [curl on Windows and PowerShell: how to run it and why commands fail](https://checkcraft.ru/en/guides/curl-windows-powershell.html) · [Validate API status codes, headers and response time](https://checkcraft.ru/en/guides/http-response-checks.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/curl-cheat-sheet.md
