Which HTTP status code should a DELETE API return?

The HTTP status code returned by a DELETE API depends on the outcome of the operation. In RESTful applications, the most commonly used status code is 204 No Content when the resource is successfully deleted and no response body is returned. Other status codes may be used based on specific business requirements and API design.

Key Points

Common DELETE Response Status Codes

1. 204 No Content

Used when

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteEmployee(
        @PathVariable Long id) {

    employeeService.delete(id);
    return ResponseEntity.noContent()
            .build();
}

Response

HTTP/1.1 204 No Content

This is considered the preferred RESTful approach.

2. 200 OK

Used when

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteEmployee(
        @PathVariable Long id) {

    employeeService.delete(id);
    return ResponseEntity.ok(
            "Employee deleted successfully");
}

Response

HTTP/1.1 200 OK

{

message": "Employee deleted successfully

}

3. 404 Not Found

Used when

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteEmployee(
        @PathVariable Long id) {

    throw new EmployeeNotFoundException(
            "Employee not found");
}

Response

HTTP/1.1 404 Not Found

{

message": "Employee not found

}

4. 403 Forbidden

Used when

Response

HTTP/1.1 403 Forbidden

5. 401 Unauthorized

Used when

Response

HTTP/1.1 401 Unauthorized

How DELETE Request Processing Works

Client Sends DELETE Request

|

Resource Found?

/ \

Yes No

| |

Delete Resource Return 404

|

Return 204 or 200

The status code should accurately represent the outcome of the operation.

Example

Suppose an Employee API exposes

DELETE /employees/101

Scenario 1

Employee exists.

Response

204 No Content

Scenario 2

Employee exists and confirmation message is returned.

Response

200 OK

{

message": "Employee deleted successfully

}

Scenario 3

Employee does not exist.

Response

404 Not Found

{

message": "Employee not found

}

Best Practice

For REST APIs

This follows standard REST conventions and keeps APIs predictable.

Common Mistakes

Follow-up Questions

Interview Tip

A concise interview answer is

The most appropriate status code for a successful DELETE operation is 204 No Content when no response body is returned. If a confirmation message or additional information is included, 200 OK can be used. If the resource does not exist, 404 Not Found is typically returned.

Last updated: 11 November 2026

Previous question: What is ResponseEntity used for in Spring Boot?

Next question: What is Swagger?

More Spring Boot - Level I interview questions

All Spring Boot - Level I questions