Skip to main content
Version: 4.0.0

Status variants

Variants of type status define status code to be sent without body when a route is requested.


The options property in a variant of type status must be an object containing next properties:

  • status (Number): Status code to send.
  • headers (Object): Object containing headers to set in the response. Optional.
module.exports = [
id: "create-user",
url: "/api/users",
method: "POST",
variants: [
id: "success",
type: "status", // variant of type status
options: {
status: 201, // status to send
headers: { // response headers to send
"x-custom-header": "foo-header-value",

A response defined with the status Variant Handler will always have an empty body.

Response headers

By default, the status variant type sets a Content-Length header in the response with value 0, but it can be changed using the headers option.