How to specify the HTTP method in cURL

The HTTP method tells the server whether the request is reading, creating, changing, or deleting data. In cURL, sending the right URL with the wrong method often returns 405 Method Not Allowed or applies the wrong action to the target resource.

A plain URL request uses GET by default. Other curl options already select methods for common cases: --data, --json, and --form send POST, --head sends HEAD, and --upload-file sends PUT. Use --request when the endpoint expects a different verb than curl would otherwise send.

Official curl documentation notes that --request changes only the method word, not the rest of curl's transfer behavior. --request HEAD is not the same as --head, and custom verbs can behave differently across redirects, proxies, and gateways, so confirm the sent request line before reusing a mutating command in a script.

Steps to specify the HTTP method in cURL:

  1. Send a plain URL request first to confirm curl's default method.
    $ curl --silent --show-error 'https://httpbin.org/anything?state=scheduled'
    {
      "args": {
        "state": "scheduled"
      },
      "data": "",
      "files": {},
      "form": {},
      "headers": {
        "Accept": "*/*",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.x",
        "X-Amzn-Trace-Id": "##### snipped #####"
      },
      "json": null,
      "method": "GET",
      "origin": "##### snipped #####",
      "url": "https://httpbin.org/anything?state=scheduled"
    }

    A URL-only HTTP request uses GET unless another option changes the transfer mode.

  2. Send form fields with --data and let curl choose POST automatically.
    $ curl --silent --show-error --data 'status=active' https://httpbin.org/anything
    {
      "args": {},
      "data": "",
      "files": {},
      "form": {
        "status": "active"
      },
      "headers": {
        "Accept": "*/*",
        "Content-Length": "13",
        "Content-Type": "application/x-www-form-urlencoded",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.x",
        "X-Amzn-Trace-Id": "##### snipped #####"
      },
      "json": null,
      "method": "POST",
      "origin": "##### snipped #####",
      "url": "https://httpbin.org/anything"
    }

    Skip --request POST for normal form or JSON submissions unless the endpoint contract explicitly requires a custom method string.

  3. Set PUT with --request when the same resource URL expects a full update.
    $ curl --silent --show-error --request PUT --json '{"status":"active"}' https://httpbin.org/anything/maintenance-windows/mw-48217
    {
      "args": {},
      "data": "{\"status\":\"active\"}",
      "files": {},
      "form": {},
      "headers": {
        "Accept": "application/json",
        "Content-Length": "19",
        "Content-Type": "application/json",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.x",
        "X-Amzn-Trace-Id": "##### snipped #####"
      },
      "json": {
        "status": "active"
      },
      "method": "PUT",
      "origin": "##### snipped #####",
      "url": "https://httpbin.org/anything/maintenance-windows/mw-48217"
    }

    --json still controls the request body and headers here; --request changes only the HTTP verb.

  4. Set PATCH with --request when only selected fields should change.
    $ curl --silent --show-error --request PATCH --json '{"status":"paused"}' https://httpbin.org/anything/maintenance-windows/mw-48217
    {
      "args": {},
      "data": "{\"status\":\"paused\"}",
      "files": {},
      "form": {},
      "headers": {
        "Accept": "application/json",
        "Content-Length": "19",
        "Content-Type": "application/json",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.x",
        "X-Amzn-Trace-Id": "##### snipped #####"
      },
      "json": {
        "status": "paused"
      },
      "method": "PATCH",
      "origin": "##### snipped #####",
      "url": "https://httpbin.org/anything/maintenance-windows/mw-48217"
    }

    If an older curl build does not support --json, send the same payload with --header "Content-Type: application/json" plus --data.

  5. Set DELETE with --request when the endpoint expects the resource URI plus a removal verb.
    $ curl --silent --show-error --request DELETE https://httpbin.org/anything/maintenance-windows/mw-48217
    {
      "args": {},
      "data": "",
      "files": {},
      "form": {},
      "headers": {
        "Accept": "*/*",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.x",
        "X-Amzn-Trace-Id": "##### snipped #####"
      },
      "json": null,
      "method": "DELETE",
      "origin": "##### snipped #####",
      "url": "https://httpbin.org/anything/maintenance-windows/mw-48217"
    }

    Test DELETE, PUT, and PATCH against a disposable resource first so a mistyped path does not change live data.

  6. Use --head for header-only checks instead of --request HEAD.
    $ curl --silent --show-error --head https://example.com/
    HTTP/2 200
    date: Wed, 22 Apr 2026 03:51:24 GMT
    content-type: text/html
    server: cloudflare
    last-modified: Sat, 18 Apr 2026 00:49:31 GMT
    allow: GET, HEAD
    accept-ranges: bytes
    ##### snipped #####

    Official curl documentation warns that --request HEAD changes only the method word. Use --head or -I when the goal is a real header-only transfer.

  7. Inspect the sent request line with --verbose before reusing a custom verb in automation.
    $ curl --silent --verbose --output /dev/null --request DELETE https://httpbin.org/anything/maintenance-windows/mw-48217
    * Host httpbin.org:443 was resolved.
    ##### snipped #####
    > DELETE /anything/maintenance-windows/mw-48217 HTTP/2
    > Host: httpbin.org
    > User-Agent: curl/8.x
    > Accept: */*
    >
    ##### snipped #####
    < HTTP/2 200
    < content-type: application/json
    ##### snipped #####

    The line beginning with > is the fastest way to confirm the exact method and path that curl sent on the wire.