Lesson 38 of 158 – Postman DELETE Request
38%

Postman DELETE Request

A DELETE request is used to remove an existing resource from a server. In Postman, we can use DELETE requests to test APIs that remove records such as students, users, products, or courses.

Note: DELETE requests should be handled carefully because the operation may permanently remove data from the database.

1. What is a DELETE Request?

A DELETE request is an HTTP request used to remove an existing resource from a server.

For example:

DELETE /students/10

This request can be used to delete the student whose ID is 10.

2. DELETE Request in Postman

Postman provides an easy way to create and test DELETE requests.

The basic process is:

  1. Select DELETE
  2. Enter the API URL
  3. Provide the resource ID
  4. Click Send
  5. Check the response

3. Create a New DELETE Request

Open Postman and create a new HTTP request.

You will see the HTTP method dropdown, URL field, and Send button.

These controls are used to create and send the DELETE request.

4. Select DELETE Method

Click the HTTP method dropdown and select DELETE.

DELETE

DELETE tells the server that the client wants to remove a resource.

5. Enter the API URL

Enter the URL of the API that will delete the existing resource.

Example:

http://localhost/api/students.php?id=10

The API can use the student ID to identify the record that should be deleted.

6. Identify the Resource

The API needs to know which resource should be deleted.

An ID can be provided as a query parameter.

http://localhost/api/students.php?id=10

Here, id=10 identifies the student that should be removed.

7. DELETE Request Without a Body

A DELETE request often does not require a request body when the resource can be identified through the URL.

DELETE http://localhost/api/students.php?id=10

The server can use the ID to identify the resource.

8. Click Send

After selecting DELETE and entering the API URL, click the Send button.

Postman sends the DELETE request to the API server.

DELETE
   ↓
API URL
   ↓
Server

9. Server Receives DELETE Request

The server receives the DELETE request and identifies the resource.

A PHP REST API can use the resource ID to find the corresponding database record.

DELETE Request
      ↓
PHP API
      ↓
Find Resource
      ↓
Delete Record

10. DELETE Request and MySQL

A PHP REST API can use a DELETE request to remove a record from a MySQL database.

Conceptually:

DELETE Request
      ↓
PHP API
      ↓
MySQL DELETE
      ↓
Record Removed

11. Example Student DELETE Request

Suppose our database contains a student with ID 15.

We can send the following request:

DELETE http://localhost/api/students.php?id=15

The API can use ID 15 to identify the student.

12. Successful DELETE Response

After successfully deleting the resource, the API can return a JSON response.

{
    "status": true,
    "message": "Student deleted successfully"
}

The response tells the client that the delete operation was completed.

13. Status Code 200 OK

A successful DELETE operation may return:

200 OK

The response body can contain additional information about the operation.

14. Status Code 204 No Content

Another possible successful response for DELETE is:

204 No Content

This indicates that the request was successfully processed and the server does not return a response body.

15. Resource Not Found

If the requested resource does not exist, the API can return an appropriate error response.

{
    "status": false,
    "message": "Student not found"
}

The API should check whether the resource exists before deleting it.

16. Status Code 404 Not Found

If the requested resource cannot be found, the API may return:

404 Not Found

For example, this can happen when the requested student ID does not exist.

17. Missing Resource ID

A DELETE API may require an ID to identify the resource.

For example, this URL does not contain an ID:

http://localhost/api/students.php

If the API requires an ID, it should return a validation error instead of deleting an unspecified record.

18. Delete Only the Requested Record

A properly designed DELETE endpoint should identify the requested resource and delete only that resource.

For example:

DELETE /students.php?id=10

The API should target the student with ID 10 rather than unrelated records.

19. DELETE Request and Authentication

Delete operations often require authentication and authorization.

For example, an API may require an access token before allowing a user to delete a record.

Authorization: Bearer YOUR_TOKEN

Authentication and authorization will be covered in later REST API lessons.

20. DELETE Request and React Native

React Native applications can use DELETE requests when a user needs to remove an existing resource.

Examples include:

  • Delete a student
  • Delete a user
  • Delete a product
  • Remove an item
  • Delete a saved record

21. DELETE Request Mobile App Flow

React Native App
       ↓
DELETE Request
       ↓
PHP REST API
       ↓
Check Resource
       ↓
MySQL DELETE
       ↓
JSON Response
       ↓
React Native App

Postman can be used to test the DELETE API before connecting it to the mobile application.

22. DELETE vs GET

GET DELETE
Commonly used to retrieve data Commonly used to remove data
Does not normally change the resource Changes the server by removing a resource
Example: Get student Example: Delete student

23. DELETE vs POST

POST DELETE
Commonly used to create a resource Commonly used to remove a resource
Example: Add student Example: Delete student

24. DELETE vs PUT and PATCH

Method Common Purpose
PUT Update an existing resource
PATCH Partially update an existing resource
DELETE Remove an existing resource

25. Common DELETE Request Mistakes

  • Wrong API URL
  • Wrong HTTP method
  • Missing resource ID
  • Incorrect resource ID
  • Server not running
  • Database connection error
  • Authentication missing
  • Authorization failure

26. Debugging a DELETE Request

If a DELETE request does not work, check the following:

  1. Check the API URL.
  2. Confirm DELETE is selected.
  3. Check the resource ID.
  4. Check whether the record exists.
  5. Check the PHP API.
  6. Check the database connection.
  7. Check authentication if required.
  8. Check authorization if required.
  9. Check the response status code.

27. Complete DELETE Request Flow

1. Open Postman
2. Create a request
3. Select DELETE
4. Enter API URL
5. Add resource ID
6. Add authentication if required
7. Click Send
8. Check the response
9. Verify the resource was removed

28. Complete DELETE Example

Method:

DELETE

URL:

http://localhost/api/students.php?id=10

Action:

Click Send to send the DELETE request to the API.

The API can find student ID 10 and remove the corresponding record.

29. Example DELETE Response

After successfully deleting the student, the API might return:

{
    "status": true,
    "message": "Student deleted successfully",
    "student_id": 10
}

The React Native application can use this response to remove the student from the displayed list.

30. Postman DELETE Request Summary

A DELETE request is commonly used to remove an existing resource. In Postman, select DELETE, enter the API URL with the resource identifier, click Send, and inspect the response.

DELETE
   ↓
Resource ID
   ↓
PHP REST API
   ↓
Check Resource
   ↓
MySQL DELETE
   ↓
JSON Response

📌 Key Points

  • DELETE is commonly used to remove an existing resource.
  • Postman can be used to test DELETE APIs.
  • The resource ID identifies the record to delete.
  • A DELETE request often does not require a request body.
  • The API should verify that the resource exists.
  • Authentication and authorization may be required.
  • PHP can use DELETE requests to remove MySQL records.
  • 200 OK or 204 No Content can indicate a successful DELETE operation.
  • 404 Not Found can indicate that the requested resource does not exist.
  • React Native applications can use DELETE requests to remove data.

🧠 Quick Quiz

Question: Which HTTP method is commonly used to remove an existing resource?