API Fundamentals Course
API Fundamentals
/
Beginner

DELETE

Definition

An HTTP method used to delete the specified resource from the server.

Explain Like I'm New

Exactly what it sounds like. You tell the server an ID, and the server destroys it.

Real World Example

A user clicks the trash can icon next to a comment they wrote. The client sends `DELETE /api/comments/123`. The server removes it from the database.

Common Use Cases

  • •Removing database records
  • •Canceling subscriptions

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • Should a DELETE request have a Request Body?

intermediate

  • What HTTP Status code should a server return after successfully deleting a resource?

Flash Cards

Question

Have a body?

Click to reveal answer
Answer

Generally, no. The URL itself should contain all the information needed (e.g., the ID of the item to delete). Sending a body with a DELETE request is highly discouraged.

Question

Which status code?

Click to reveal answer
Answer

`200 OK` (if you want to return a JSON message), or `204 No Content` (if you deleted it and have absolutely nothing else to say to the client).