cURL

curl sends a request from the terminal and prints the response: method with -X, headers with -H, a body with -d, and -i to show the response headers. Because a curl command spells out every part of a request, it has become the standard way to share one — in documentation, bug reports and the "Copy as cURL" option of every browser's developer tools.

How it works

-d implies POST and a form content type unless you set -H "Content-Type: application/json". -L follows redirects, -v shows the whole exchange including TLS, and --fail makes curl exit non-zero on a 4xx or 5xx so it can gate a script. Single quotes around the body keep the shell from interpreting it.

The misconception

That curl and a browser send the same request. A browser adds cookies, an Origin, CORS preflights and its own User-Agent; curl sends only what you write. A call that works in curl and fails in the browser is very often a CORS or cookie problem, not an API bug.

Try it here

Every endpoint's Try it out panel generates the curl command for the request you configured, and the curl converter in the tools section turns any curl command into code in nine languages.

Sources

Other terms

All glossary terms · Testing techniques · All 39 mock REST APIs

Last updated