What should be the delete API method status code?
When designing a RESTful API, the HTTP status codes returned by a DELETE method can vary based on the outcome of the operation. Here are some common status codes you might use:
204 No Content: This is the most common response for a successful DELETE request. It indicates that the resource was successfully deleted, and there is no additional content to return.
200 OK: This can also be used if you want to return a response body (e.g., a confirmation message) along with the status code, indicating that the deletion was successful.
404 Not Found: This status code should be returned if the resource that you are trying to delete does not exist. It indicates that the server could not find the requested resource.
403 Forbidden: If the user does not have permission to delete the resource, you should return this status code.
500 Internal Server Error: If there is an unexpected error on the server while trying to process the DELETE request, this status code should be returned.
In summary, the most appropriate status codes for a DELETE API method are typically 204 No Content for successful deletions and 404 Not Found for cases where the resource does not exist.