---
url: https://docs.fluxify.rest/blocks/get-http-request-body.md
description: Read the body of the incoming request, as JSON, form fields or files.
---

# Get HTTP Request Body

![Get HTTP Request Body block on the canvas](/blocks/get-http-request-body.png)

The **Get HTTP Request Body** block returns the body of the incoming request,
already turned into something you can work with. What you get depends on the
content type the caller used.

## When to use it

* Read the data a caller sent with a `POST`, `PUT` or `PATCH`: a JSON document, a form, or an uploaded file.
* Read the body again later in the flow. The [Entrypoint](./entrypoint.md) also starts the flow with the body, but later blocks replace it.
* Don't use it for URL values. Use [Get HTTP Param](./get-http-param.md).
* Don't use it for headers or cookies. Use [Get HTTP Header](./get-http-header.md) or [Get Request Cookie](./get-request-cookie.md).

## Inputs

None. The block always reads the body of the request that started the workflow.

## Outputs

| Handle | When it is used |
| --- | --- |
| **Next** (right) | Always. The next block receives the body, in the shape shown below. |

What you get depends on the content type the caller used:

| Caller sends | You get |
| :--- | :--- |
| `application/json` | The parsed JSON — an object, an array, a number, whatever was sent |
| `application/x-www-form-urlencoded` | An object of field names and text values |
| `multipart/form-data` | An object where text fields are strings and uploaded files are file objects |
| `application/octet-stream` | The raw binary body as a single `Blob` — or a `ReadableStream<Uint8Array>` in pipe-stream mode |
| `text/plain` | The text, exactly as sent |
| A `GET` or `DELETE` request | `null` — those methods carry no body |

::: info Which types your route allows
A route accepts **JSON only** unless you say otherwise. Pick the formats you
want under **Accepted content types** when you create the route. A request that
arrives in any other format is rejected with `415 Unsupported Media Type`
before your workflow runs.
:::

### Repeated field names

If a form sends the same field name twice (`tag=a&tag=b`, or two files under
`docs`), you get a list for that field instead of a single value. A name that
appears once stays a single value.

```json
{ "title": "Holiday photos", "tags": ["beach", "summer"] }
```

### Piping a large upload

For `application/octet-stream`, **Pipe request body as a stream** hands your
workflow the live `ReadableStream<Uint8Array>` instead of a `Blob`. Fluxify does
not buffer or size-limit the body in this mode, so it can be forwarded straight
to `Bun.write`, an S3 multipart upload, or an `fs` stream:

```javascript
const body = getRequestBody();
await Bun.write("/tmp/upload.bin", body);
```

A stream route accepts only `application/octet-stream`, has no body schema, and
cannot be called with `x-fluxify-reply: async`. Read the stream once: it is the
request itself, not a copy.

### Working with uploaded files

A file field is a file object, not text. In a **JS Runner** block you can read
its name, size, type, and contents:

```javascript
const body = getRequestBody();
const upload = body.avatar;

console.log(upload.name);  // "profile.png"
console.log(upload.size);  // 20481  (bytes)
console.log(upload.type);  // "image/png"

const text = await upload.text();          // for text files
const bytes = await upload.arrayBuffer();  // for anything else
```

::: warning Files are not JSON
A file object cannot be returned directly from a **Response** block — JSON has
no way to represent one. Read what you need from it (its text, its size, a
value you extract from it) and return that instead.
:::

## Size limit

Every **buffered** request body is capped, 8 MB by default. A larger request is
rejected with `413` and your workflow never starts. A pipe-stream
`application/octet-stream` route is not buffered or counted, so it is exempt.
See [request body size](../deployments/production.md#request-body-size) for how
to change the cap and why large uploads need care.

## Example

A caller sends `POST /orders` with `Content-Type: application/json`:

```json
{ "orderId": "A-1024", "items": [{ "sku": "x1", "qty": 2 }] }
```

The next block receives that same object, so it can read `input.orderId`.

## How it behaves

1. The caller's content type is checked against the formats the route accepts.
2. The body is read and turned into the value shown in the table above.
3. That value becomes the block's output, ready for the blocks after it.

* **It replaces the flowing data.** The next block's `input` is the body, not what came before. Store earlier data first with [Set Variable](./set-var.md).
* **No body is not an error.** A request without a body gives `null`.

## Related blocks

* [Entrypoint](./entrypoint.md): the flow starts with this same body.
* [Get HTTP Param](./get-http-param.md): read query and path values.
* [JS Runner](./js-runner.md): read files and work with the body in code.
* [If Condition](./if-condition.md): check that a required field is present.
