What is the Default HTTP Method for Curl?

When using the command-line tool curl to interact with web servers, understanding how it transmits requests is crucial for debugging and API development. This article explains the default HTTP method that curl uses when no method is explicitly defined, how certain command-line options can implicitly change this default, and how to manually specify different HTTP methods for your requests.

The Default HTTP Method: GET

By default, if you run a basic curl command with only a URL, it uses the GET HTTP method. The GET method is used to retrieve data from a specified resource.

For example, running the following command sends a standard HTTP GET request to the target server:

curl https://api.github.com

In this scenario, curl connects to the server, requests the resource using GET, and outputs the response body directly to your terminal.

Implicit Changes to the Default Method

While GET is the absolute default for a bare command, curl will automatically switch its HTTP method if you use specific data-sending or formatting flags. You do not need to specify the method explicitly for these changes to occur:

How to Explicitly Specify an HTTP Method

If you need to use HTTP methods other than the defaults—such as PUT, DELETE, PATCH, or OPTIONS—you must explicitly define them using the -X or --request flag followed by the desired HTTP verb.

Here are a few examples of how to explicitly set the HTTP method:

Using the -X flag overrides any implicit behavior, ensuring that curl uses the exact HTTP method required by your target API.