# Body

## Introduction

The `body` tab is used primarily for creating or updating resources (i.e. for `POST`, `PUT`, `PATCH` and `DELETE` requests).&#x20;

Any parameters added here are passed in the endpoint request body. You can define `required` body parameters and `optional` body parameters:&#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F02qEujMwGjBlWwznv3zq%2Fendpoint%20-%20body.png?alt=media&#x26;token=31bb5ea8-b7df-4003-94a5-57a7a893c61b" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
It's important to note that when a [process flow](https://doc.wearepatchworks.com/product-documentation/process-flows/about-process-flows) runs and reaches a target connector step (typically, a [connector shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape) associated with a `POST`, `PUT`, `PATCH` or `DELETE` endpoint), the payload generated from previous steps is automatically added to the body of that request. You do not need to add anything to the endpoint `body` tab for this to happen - it's automatic.
{% endhint %}

{% hint style="info" %}
When an [authentication method](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/authentication) is applied for an endpoint, any `header` and `body` parameters specified for the authentication method are also sent in the endpoint requests - you don't need to add them twice.
{% endhint %}

The `body` tab is split into upper and lower panels:

* [Required body parameters](#required-body-parameters)
* [Body filters](#body-filters)

## Required body parameters

If you have parameters that must always be passed in the endpoint request body, add them to the `required body parameters` panel. Default parameters are passed straight into requests - users are never asked to provide values for these.

Required body content can be [none](#none), or added as [raw](#raw-data), [form](#form-data), or [text](#text) data:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F0T25wFUwVaFC0s2ozuCq%2Fendpoint%20body%20tab%201.png?alt=media&#x26;token=11a375a5-a426-440c-9cb9-09bb0047f421" alt=""><figcaption></figcaption></figure></div>

### Raw data

Use this option to pass static content or an incoming payload into the request body. Select the `raw` option and choose the required data type:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FEnK0njwk2YDR2pPvtJlU%2Fbody%202.png?alt=media&#x26;token=c71537c6-fba3-4ebb-b24b-1cc804f6a353" alt=""><figcaption></figcaption></figure></div>

...then (if required) use the editor provided to add the required data:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FV8IO4jgrwbk5fhjFiBbz%2Fbody%203.png?alt=media&#x26;token=cbb173ac-60ca-4123-90b6-487f0aae96dc" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
If no static content is added, any incoming payload is passed into the request body.
{% endhint %}

### Form data

Select the `form` option to add data as key pairs:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F1PDMPvooiCHK2TJdePBs%2Fbody%204.png?alt=media&#x26;token=08c31138-e04a-4722-ac1d-679f3cec1694" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
If you use form data to send data as files, please be aware that [pre-request scripts](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/pre-request-script) cannot be used.
{% endhint %}

### Text

Select the `text` option and add the required text content to the body content field:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FCmdENzVTGhpkaJ5KSBAM%2Fendpoint%20body%20tab%202.png?alt=media&#x26;token=c350225c-da6d-46a7-8b4b-5cdbe88df7e1" alt=""><figcaption></figcaption></figure></div>

### None

Set this option to `none` if no body content is expected.&#x20;

It's important to note that this option is ignored if data is found in the body. This handles scenarios where body content isn't typically expected, so `body format` is set to `none`, but later (for example) a custom script is introduced which adds a payload to the body.

{% hint style="warning" %}
To send an empty body, no `Content-Type` header should be set. If a `Content-Type` header IS set (within [header](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/header) options), then `none`  falls back to sending the default payload (i.e. any output of the previous shape).
{% endhint %}

## Body filters

If you have parameters that you want to expose to users when they configure a [connection shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape) to use this endpoint in [process flows](https://doc.wearepatchworks.com/product-documentation/process-flows/about-process-flows), and then pass provided values into the endpoint request body, add them to the lower panel:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FarcjiZLr4OcymPStKjZ7%2Fbody%205.png?alt=media&#x26;token=d564bc2b-7a3d-4def-aa6c-916c27cbf3fa" alt=""><figcaption></figcaption></figure></div>

`Body filters` are available for your users to update with their own required values, in process flows. These work in the same way [as noted for optional URL parameters](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/url#optional-parameters), except any values provided by users (via the [connector shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape) in [process flows](https://doc.wearepatchworks.com/product-documentation/process-flows/about-process-flows)) are passed into the request body, rather than being added as URL queries.&#x20;

## More information

Techniques for adding body parameters are the same as all other types of parameters that you may encounter in the connector builder. For information, please see [Working with parameters](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/techniques-for-working-with-variables-and-parameters/working-with-parameters).
