Updated 1 day ago
The HTTP DELETE Method
DELETE removes a resource from the server. The request is simple. The implications are not.
The Request
DELETE requests are minimal. The URL identifies what to destroy. Headers handle authentication. There's typically no body.
After a successful DELETE, GET requests to that URL should return 404 Not Found. The resource is gone.
The Response
204 No Content is the most common success response—the resource is deleted, there's nothing more to say:
200 OK works when you want to return information about what was deleted:
202 Accepted signals that deletion is queued but not complete—useful when removing large amounts of data.
404 Not Found means the resource doesn't exist. But this raises an interesting question.
409 Conflict indicates the resource can't be deleted—perhaps it has dependencies, or business rules prevent removal.
The Idempotency Paradox
DELETE is idempotent: calling it multiple times should have the same effect as calling it once. But you can only destroy something once. What happens when you DELETE something that's already gone?
Camp One—Return 404: "The resource doesn't exist. I can't delete what isn't there."
Camp Two—Return 204: "You asked me to ensure this resource doesn't exist. Mission accomplished."
Both positions have merit. The 404 approach tells you whether your request actually did anything. The 204 approach emphasizes the end state—the resource is gone, which is what you wanted.
Most modern APIs return 404, but the debate reveals something real. Is deletion an action ("remove this thing") or an outcome ("ensure this thing is absent")? The HTTP specification doesn't say. You have to decide.
Soft Deletes
Many applications never actually delete data. They mark it as deleted:
From the API's perspective, the resource is gone—GET returns 404, it disappears from lists. But the data remains in the database, recoverable if needed.
This provides:
- Recovery from accidental deletions
- Audit trails showing what was deleted and when
- Compliance with regulations requiring data retention
- Referential integrity for resources that reference deleted items
Some APIs expose this explicitly:
Conditional Deletes
Destruction doesn't have an undo button. Conditional requests provide a safety check before you cross that line.
The If-Match header ensures you're deleting what you think you're deleting:
If the article has been modified since you last read it—if someone else edited it while you were deciding to delete—the ETags won't match:
This prevents a specific kind of tragedy: deleting a resource that contains changes you've never seen.
Bulk Deletions
Deleting multiple resources at once is powerful and dangerous. Several patterns exist:
Individual requests: Simple, safe, chatty.
Query parameters: Powerful, terrifying.
A misconfigured filter could delete everything.
Explicit bulk endpoint: Not RESTful, but safe.
For bulk operations, favor explicitness over elegance. The extra verbosity is a feature.
Security
DELETE requires careful protection:
Authentication: Never allow anonymous deletions.
Authorization: Verify the user can delete this specific resource. Owning a resource doesn't mean owning all resources.
CSRF protection: Prevent malicious sites from tricking browsers into sending DELETE requests.
Rate limiting: A compromised account with unlimited DELETE access is catastrophic.
Audit logging: Log every deletion with timestamp, user, and what was deleted. When something goes wrong, you'll need this.
Cascading behavior: Decide what happens to dependent resources. Delete them too? Return an error? The answer affects data integrity.
Asynchronous Deletion
Deleting large amounts of data takes time. Rather than making clients wait, acknowledge the request and process it in the background:
Clients poll the status URL until the job completes. This pattern works for any operation that takes longer than a reasonable request timeout.
The Recycle Bin Pattern
User-facing applications often combine soft deletes with a grace period:
- DELETE request triggers a soft delete
- Resource appears "deleted" to users
- 30-day grace period for recovery
- Background job permanently deletes after grace period
Users get the satisfaction of immediate deletion. Operations teams get time to fix mistakes.
Frequently Asked Questions About the HTTP DELETE Method
Was this page helpful?