# web.response.send

Answers the request — the caller receives it the moment this node runs — and passes its payload on unchanged: nodes after it keep running, and a failure after it is recorded on the run without changing the answer

# web.response.send

```
web.response.send [--status N] [--header KEY=TEXT…] [--body JSON] [--template TEXT] [--file TEXT] [--root TEXT] [--path TEXT] [--store VALUE] [--filename TEXT] [--script TEXT…]
```

Answers the request — the caller receives it the moment this node runs — and passes its payload on unchanged: nodes after it keep running, and a failure after it is recorded on the run without changing the answer. The first response of a run wins; a second one sends nothing (recorded `empty`). No source: the payload as JSON, 200. At most one source: `--body VALUE` (a string answers text/plain, anything else JSON, unless a `Content-Type` header says otherwise); `--template pages/x.tsx` (exact `file_list` path, `.tsx` required): render the page with the payload as its `input`; `--file pwa/manifest.webmanifest`: a project file, content type by extension, a `.ts` compiled to JavaScript (a service worker: `--file pwa/site.sw.ts` behind `trigger.webhook --route /sw.js`); `--root pwa/icons --file "{{ $trigger.params.file }}"`: one file out of a folder, the name from the route, never outside it. A stored file: `--file "{{ input.file }}"` with a FileRef (fs.file.put, fs.file.get --return file, an upload, one kept in a record), or `--path KEY` (`--store`) with a store key — streamed from its store, never read into the run, typed by the FileRef's mime, with `Range` (206/416), `HEAD`, `ETag`/`Last-Modified` and `304`, `Cache-Control: private, no-cache` unless a header says otherwise, shown inline; `--filename NAME` makes it a download under that name. A stored file that is not there — or a `--file` / `--path` that resolved to null — fails FW_NODE_WEB_RESPONSE_SEND_NOT_FOUND, which the route answers 404 (the run keeps the reason) unless an `:error` edge takes it. A rendered page never carries the request into the browser: its hydration state has no request headers, cookies or trigger auth (SSR still reads them; copy a value into a key of your own upstream to show it). `--status N`, `--header K=V` (repeat; a repeated name is sent twice). A redirect is `--status 303 --header "Location=/home"` — a Location without a 3xx, or a 3xx without a Location, is refused. Every header is sent exactly as written, `Set-Cookie` too: nothing is added, so a session cookie writes its own attributes — `--header "Set-Cookie=zebflow_session={{ input.token.access_token }}; Path=/; Max-Age=86400; SameSite=Lax; HttpOnly"`, plus `; Secure` behind HTTPS. There is no `--route`; the route is the trigger's `--route`. A 404 or 400 is a [`logic.if`](/nodes/logic/logic.if.md) whose `false` pin reaches a second `web.response.send` with that `--status` — a script cannot set one.

## Flags

- `--status`: HTTP status code (default 200). A 3xx needs a Location header.
- `--header`: A response header, e.g. --header "Location=/home". Sent exactly as written. Repeat for several; a repeated name is sent twice (two Set-Cookie headers are two cookies).
- `--body`: The answer: a string answers text/plain, anything else JSON, e.g. "{{ input.query.rows }}".
- `--template`: A TSX page under the source root, ending .tsx, e.g. pages/home.tsx. The payload is its input.
- `--file`: A project file to answer, e.g. pwa/manifest.webmanifest or pwa/site.sw.ts (compiled); with --root, a bare filename inside it. A FileRef ("{{ input.file }}") answers that stored file, streamed.
- `--root`: The project folder --file must be directly inside (no subfolders, no ..), e.g. pwa/icons for a /pwa/{file} route.
- `--path`: A store key to answer, streamed from --store, e.g. "reports/{{ input.query.rows[0].key }}".
- `--store`: The store --path is read from: `local`, or the id of an `s3` credential. Saved explicitly when the pipeline is registered. A FileRef names its own store.
- `--filename`: Answer the file as a download under this name (Content-Disposition: attachment). Default: inline.
- `--script`: An external script URL for the page (with --template); repeat for several. Each must match the project's RWE allow-list.

## Examples

### Render a page

```
| web.response.send --template pages/posts.tsx
```

The payload (e.g. `{ rows }`) is the page's `input`; the body must show no `RWE component error`.

### Redirect after a form POST

```
| web.response.send --status 303 --header "Location=/admin/posts"
```

### JSON with a status

```
| web.response.send --status 400 --body "{{ { error: 'title is required' } }}"
```

### Plain text with a status

```
| web.response.send --status 401 --body "invalid credentials"
```

### Set the session cookie and go home

```
| web.response.send --status 303 --header "Location=/home" --header "Set-Cookie=zebflow_session={{ input.token.access_token }}; Path=/; Max-Age=86400; SameSite=Lax; HttpOnly"
```

The header is sent as written: the cookie carries the attributes it names and no others. Add `; Secure` behind HTTPS. Logout: `--header "Set-Cookie=zebflow_session=; Path=/; Max-Age=0"`.

### The web-app manifest, a file in the project

```
| web.response.send --file pwa/manifest.webmanifest
```

Behind `trigger.webhook --route /manifest.webmanifest`; pages link it with `head.links: [{ rel: "manifest", href: "/manifest.webmanifest" }]`.

### The service worker, compiled from TypeScript

```
| web.response.send --file pwa/site.sw.ts
```

Behind `--path /sw.js`. The file starts with `self.__ZF = { version, source }`; the page registers it once with `navigator.serviceWorker.register("/sw.js")`.

### One icon out of a folder

```
| web.response.send --root pwa/icons --file "{{ $trigger.params.file }}"
```

Behind `--path /pwa/{file}`. The name may not leave the folder, so this is safe to expose.

### A member's own file, or 404

```
| web.response.send --path "{{ input.query.rows[0]?.path ?? null }}"
```

After `trigger.webhook --auth jwt` and `sekejap.query.run … WHERE _key = $1 AND owner = $2` with `--param "2={{ input.webhook.auth.sub }}"`: the owner gets the bytes, anyone else finds no row and gets 404.

### A stored key as a download

```
| web.response.send --path "exports/{{ $trigger.params.id }}.csv" --filename "export.csv"
```

## Used in

- [Agentic Scheduling (AI + Cron)](/examples/agentic-scheduling.md)
- [Let an app build inside its own project (control door)](/examples/app-control-door.md)
- [Auth and Authorization](/examples/auth-and-authorization.md)
- [Blog with Admin](/examples/blog-with-admin.md)
- [Cookie + JWT Authentication](/examples/cookie-jwt-auth.md)
- [Forum with Real-Time Chat](/examples/forum-with-chat.md)
- [Sign in to a published MCP server (OAuth)](/examples/mcp-oauth-login.md)
- [Sign in with Google (OAuth login)](/examples/oauth-login-google.md)
- [Real-Time Game (WebSocket State Sync)](/examples/realtime-game.md)
- [Web Scraping + Data Pipeline](/examples/scraping.md)
- [TTS API + Frontend Page](/examples/tts-with-page.md)
- [Webhook → TSX Page](/examples/webhook-page-tsx.md)
- [REST API + PostgreSQL](/examples/webhook-restapi-postgres.md)
