reply.status()

Sets the HTTP status code for the response (alias of reply.code()).

Since Fastify 5 Spec ↗

Syntax

reply.status(statusCode: number)

Parameters

NameTypeRequiredDescription
statusCode number No The HTTP status code to send.

Returns

FastifyReply — The reply, for chaining.

Examples

import Fastify from 'fastify';

const app = Fastify();

app.delete('/cats/:id', async (req, reply) => {
  return reply.status(204).send();
});

Notes

status() is a direct alias of code(); use whichever reads better. It must be set before the body is sent.