Skip to main content
The NoContent response type returns a 204 No Content status code, indicating that the request succeeded but there’s no content to return.

Basic usage

Return NoContent from handlers that perform an action but have nothing to return:

When to use NoContent

DELETE operations

The most common use case is successful DELETE requests:
Example from examples/todos/src/main.rs:146-151.

PUT operations with no response body

When updating a resource without returning the updated data:

Successful operations with no data

Any operation that succeeds but has nothing to return:

How it works

Type definition

See definition in axum/src/response/mod.rs:78.

IntoResponse implementation

The NoContent type simply converts to a 204 No Content status code:
See implementation in axum/src/response/mod.rs:80-84.

Comparison with unit type ()

The unit type () returns 200 OK with an empty body, while NoContent returns 204 No Content.

Using () returns 200 OK

Using NoContent returns 204 No Content

When to choose which

  • Use NoContent (204): When the operation succeeded and there’s intentionally no content (DELETE, some PUTs)
  • Use () (200): When you want a default successful response (less common)
  • Use StatusCode::NO_CONTENT: When you need more control or want to return it conditionally

Response fields

StatusCode
Always 204 No Content
empty
The response body is always empty

Common patterns

Using with Result for error handling

Conditional response with status codes

Using StatusCode directly

You can also use StatusCode::NO_CONTENT directly:
Both approaches are valid. NoContent is more self-documenting, while StatusCode::NO_CONTENT gives you more flexibility for conditional logic.

See also