Request Body
What Is a Request Body?
A request body is the data a client sends to a server in an HTTP request. In an API, this payload commonly contains structured inputs, such as JSON fields, form values, or files.
How an HTTP Request Body Works
- A user action or app feature creates a request.
- The client sends headers, including Content-Type, followed by the body.
- The server parses the body according to its declared format.
- The server validates and processes the inputs, then returns a response.
Request Body vs Headers vs URL Parameters
A request header describes the request. Parameters identify or filter a resource, while the body supplies the main input.
| Part | Purpose | Example |
|---|---|---|
| Body | Structured input | {"name":"Ava"} |
| Header | Metadata and format | Content-Type: application/json |
| Path or query | Resource or filter | /users/42?active=true |
Common Request Body Formats
| Format | Best use |
|---|---|
| application/json | Most web APIs |
| application/x-www-form-urlencoded | Simple form submissions |
| multipart/form-data | Forms with file uploads |
| text/plain | Unstructured text |
Which HTTP Methods Use a Request Body?
| Method | Typical body use |
|---|---|
| POST | Create or submit data |
| PUT | Replace a resource representation |
| PATCH | Apply partial changes |
| DELETE | Possible, but API-specific |
| GET | Avoid it, support and meaning are inconsistent |
Request Body Example
A booking app might send Content-Type: application/json with {"date":"2026-10-22","guests":2}. The server checks those expected fields and returns a response body with the booking result.
Request Body Best Practices
- Match the body format to Content-Type.
- Validate required fields and types on the server.
- Set size limits and document the expected schema.
- Keep secrets out of URLs and return useful validation errors.
Common Request Body Problems
- Incorrect Content-Type or invalid JSON prevents parsing.
- Empty bodies and mismatched field names fail validation.
- req.body may be undefined when parsing middleware is missing.
- Streamed bodies generally cannot be read twice.
Request Bodies in Emergent Apps
Request bodies connect forms, integrations, and database actions in full-stack products. Learn more about an API request and app design and development; Emergent can help build API-powered apps from natural-language instructions.
Frequently Asked Questions
Your Questions, Answered
Don't change this element unless you know what you are doing
What is a request body in an API?
It is the payload sent from a client to a server, usually to create, update, or process data.
What is the difference between a request body and a request header?
The body contains the main input data. Headers provide metadata, such as the body format and authorization details.
Can a GET request have a body?
Technically some HTTP systems may accept one, but developers should avoid it because support and semantics vary.
Can PUT requests have a body?
Yes. PUT commonly sends a body representing the resource state to create or replace.
What formats can a request body use?
Common formats include JSON, URL-encoded form data, multipart form data, and plain text.
Why is req.body undefined?
The server may lack the correct body parser, receive the wrong Content-Type, or receive an empty or already consumed request stream.
on Emergent today


