POST a JSON body

Send a JSON payload in a POST request.

curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -d '{"name":"foo"}'

tool
curl21 commands
tags
curl

More curl commands

  • curl -H 'Authorization: Bearer $TOKEN' https://api.example.com/me

    Send a JWT or Bearer token in the Authorization header.

  • curl -Lv --max-redirs 5 https://example.com

    Follow up to 5 redirects and show every request and response in detail.

  • curl -sSL -o /tmp/result.json https://api.example.com/data

    Download quietly and follow redirects, but still show errors.

  • curl -o /dev/null -sS -w 'ttfb: %{time_starttransfer}s\ntotal: %{time_total}s\n' https://example.com

    Measure TTFB and the total request time.

  • curl -sI https://example.com

    Print HTTP response headers without the body.

all 21 curl commands