Can You Put a Body in REST API DELETE?
Question
While implementing the Gift API at Kakao Tech Campus, I had to implement “delete wishlist item by product ID.” The question was: include productId in path or body?
1
2
Option 1: DELETE /api/wishlist/items/{productId}
Option 2: DELETE /api/wishlist/items (body: { "productId": 123 })
HTTP Spec
According to RFC 7231, DELETE with body is “allowed but may be ignored.”
“A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.”
Meaning: works but some proxies or servers might ignore or reject it.
Mentor Feedback
“HTTP method semantics-wise, resource is usually expressed in the URI. So DELETE /wishlist/items/{productId} would be more natural.”
“Body in DELETE technically isn’t wrong, but since it’s rarely used in practice, it could confuse API consumers.”
Conclusion
Went with DELETE /api/wishlist/items/{productId}.
- Follows REST convention
- Clear and intuitive for API consumers
- No compatibility issues
Lessons Learned
- REST resources are typically expressed in URI
- DELETE body is spec-allowed but practically uncommon
- API design is about consumer experience, not just technical correctness
From Kakao Tech Campus 3rd cohort Gift API clone coding, summarizing mentor feedback.