> For the complete documentation index, see [llms.txt](https://doc.wearepatchworks.com/product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/script-shape.md).

# Script shape

## Introduction

If you have defined [custom scripts](/product-documentation/developer-hub/custom-scripting.md) for use in process flows, use the `script` shape to select a script to apply at a given point in a process flow. You can use any version of a script which has been saved and deployed.

{% hint style="info" %}
A single incoming payload for [any process flow shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes) should not exceed 500MB.

We recommend processing multiple, smaller payloads rather than a single payload (1000 x 0.5MB payloads are more efficient than 1 x 500MB payload!).

For payloads up to 500MB, consider adding a[ flow control shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) to batch data into multiple, smaller payloads. Payloads exceeding 500MB should be batched at source.
{% endhint %}

## Need to know

* If a script fails it is retried three times (automatically) before a failure is given.
* A script will time out if it runs for more than 120 seconds.

## Adding a script shape

**Step 1**\
In your process flow, add the `script` shape in the usual way:

<div align="left"><figure><img src="/files/lzhzyJeChKyxpOJRL0rD" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 2**\
You're prompted to select an existing script:

<div align="left"><figure><img src="/files/Fq7Rl3XobFEfX4CU6oJv" alt="" width="375"><figcaption></figcaption></figure></div>

**Step 3**\
Select the script that you want to use at this point in the process flow:

<div align="left"><figure><img src="/files/Q0FFWAbW2M39jsKDgjZ0" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The list of available scripts includes all scripts, irrespective of whether they are deployed. If you choose a script that isn't deployed, it will be deployed the first time it's needed, when the process flow runs.
{% endhint %}

{% hint style="info" %}
If you have lots of scripts, use the `search` field to search by name.
{% endhint %}

**Step 4**\
Select which `version` of the script to use. Unless you have a specific reason to do otherwise, we advise using the latest version of scripts. For example:

<div align="left"><figure><img src="/files/ns9YXlRQgaUAGevn0ZAF" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Code is displayed in view mode. If you need to change the script, save your shape now and then use the left-hand navigation bar to access `process flows` ➤ `custom scripts`.
{% endhint %}

**Step 6**\
Save the shape:

<div align="left"><figure><img src="/files/2awof7V4tv4MvnTDABUq" alt="" width="375"><figcaption></figcaption></figure></div>

## Accessing script shape settings

To view/change the selected script for an existing **script** shape, click the associated 'cog' icon:

<div align="left"><figure><img src="/files/vsQsw3E5sbVF2Vk3qujK" alt="" width="317"><figcaption></figcaption></figure></div>

From here, the existing script is displayed - you can either select a different script, or a different version of the existing script:

<div align="left"><figure><img src="/files/VIkxJ2cedAq0Z4CgC1Tp" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Remember that the script code can't be changed here. If you need to change the script, save your shape now and then use the left-hand navigation bar to access `process flows` ➤ `custom scripts`.
{% endhint %}
