Skip to content

Sending Webhook Responses

Webhooks are HTTP endpoints — callers expect a body, not silence. Use the res instance to control exactly what goes back.


Quick start

res.json({ ok: true, processed: true })

The response is sent immediately and command execution stops. Treat every res.*() send call like a return.


Default behavior

If you do not call res, the platform returns:

{ "status": "success" }

with HTTP 200. Fine for fire-and-forget triggers. Bad for API integrations that parse the response body — use explicit res.json() so callers get predictable output.


Common patterns

JSON API

res.status(200).json({
  status: "success",
  data: result,
  timestamp: Date.now()
})

HTML page

res.render("report.html", {
  data: { rows: reportData }
})

Redirect browser

res.redirect("https://myapp.com/done")

Error to caller

if (!options.token) {
  return res.status(401).json({ error: "Unauthorized" })
}

Full res reference

Topic Page
Overview & availability res Overview
set(), status() Headers & Status
json(), text(), xml() JSON, Text & XML
html(), EJS HTML & EJS
redirect() Redirects
render() res.render()
Defaults, HTML protection Defaults & Protection

Webapp responses

The same res API applies to webapp commands. Public web pages do not use res — see Public Web.


See also