ctx.response.message

Gets or sets the HTTP response status message associated with the current status code.

Since Koa 2 Spec ↗

Syntax

ctx.response.message  // or ctx.message

Returns

string — The HTTP status message string (e.g. `"OK"`, `"Not Found"`, `"Internal Server Error"`).

Examples

import Koa from 'koa';

const app = new Koa();

app.use(async (ctx) => {
  ctx.status = 200;
  ctx.message = 'Everything is fine';
  ctx.body = { ok: true };
});

app.listen(3000);
Output
HTTP/1.1 200 Everything is fine
{"ok":true}

Notes

By default Koa sets the status message from the Node.js `http.STATUS_CODES` map when you assign `ctx.status`. Overriding `ctx.message` is rarely needed; most HTTP/2 clients ignore the reason phrase entirely.

See also