Send a curl DELETE Request {With Example}

February 2, 2022


cURL (client URL) is a command-line utility for transferring data to and from a server. The tool allows communication with a web or application server and sending method requests directly from the terminal.

The HTTP DELETE method request sends a signal to the originating server to delete a resource.

This tutorial explains how to send a curl DELETE request through an example REST API JSON server.

Send a DELETE Request Using curl


  • Access to the command line/terminal with administrator user privileges.
  • NodeJS and NPM installed and updated.
  • Access to a text editor.

Note: To install NodeJS and NPM, follow our OS-based guides for:

Curl DELETE Request Syntax

The basic syntax to send a DELETE request method using curl is:

curl --request "DELETE" <URL>

Alternatively, use the shorthand version:

curl -X "DELETE" <URL>

The curl command sends a DELETE request to the HTTP server, deleting the page or entry at the provided URL.

Curl DELETE Request Example

The example below demonstrates how the curl DELETE request works. The example creates a fake REST API server using the JSON server package.

Note: Need a real and inexpensive server to set up a testing environment? Check out Bare Metal Cloud instances that start as low as $0.10/h.

Then, follow our instructions on how to set up a sandbox envrionment on BMC. Alternatively, see how to create a load balancer and test the connection using curl.

1. Open the terminal (CTRL+ALT+T).

2. Run the following command to install the json-server library using the NPM package manager:

sudo npm install -g json-server

3. Open a text editor and create a database.json file. If you're using nano, run:

nano database.json

4. Add the following data:

  "people": [
      "id": 1,
      "name": "Matthew"
      "id": 2,
      "name": "Mark"
      "id": 3,
      "name": "Luke"

The file represents a mock database of people with unique IDs and names.

5. Save the file and close the text editor.

6. Run the following command to start the server:

json-server --watch database.json
json-server --watch database.json terminal output

The server starts locally, listing the following two pages:

  • Resources at http://localhost:3000/people contains the data defined in the database.json file.
json database on localhost browser page
  • Home at http://localhost:3000 contains the landing page with the message that the server is up.
json server running

7. In a new terminal tab, send a DELETE request using curl:

curl -X "DELETE" 'http://localhost:3000/people/3'
curl delete request terminal

The terminal outputs an empty set. Check http://localhost:3000/people to confirm the third entry is no longer there.

json database deleted entry

The server session in the command line/terminal shows the DELETE request with a server response of 200 (success).

json server curl delete request response 200

Attempting to delete non-existing data results in a server response 404 (not found).


After following the steps from this tutorial, you understand how to send a DELETE request through the command line using the curl command.

Next, see how you can change the user agent with curl.

Was this article helpful?
Milica Dancuk
Milica Dancuk is a technical writer at phoenixNAP with a passion for programming. With a background in Electrical Engineering and Computing, coupled with her teaching experience, she excels at simplifying complex technical concepts in her writing.
Next you should read
403 Forbidden Error - What Is It and How to Fix It
October 7, 2021

The 403 Forbidden error appears when you are trying to access content, but the access is denied. This article deals with different ways of fixing the 403 error.
Read more
How to Fix the 500 Internal Server Error in WordPress
April 25, 2024

The 500 Internal Server Error is one of the most common errors you will encounter in WordPress. The error indicates...
Read more
How to Make curl Ignore Certificate Errors
October 13, 2020

Learn how to make curl ignore certificate errors by adding the required option to the command. Ignoring certificate errors, should only...
Read more
How to Set or Change User Agent with curl
October 15, 2020

Change the user agent string with curl by adding the required option attribute. Change the user agent to the wanted browser to access any webpage.
Read more