> ## Documentation Index
> Fetch the complete documentation index at: https://prowork.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How do I create a JSON body in Prowork?

> Create a JSON request body in the Prowork API step, build line items in an Add text column step, or use Custom transform for more complex JSON.

There are **three main ways** to construct a JSON body in Prowork, depending on your use case:

## **1. Create JSON in an API Step (for API Requests)**

If you're building a JSON body to send in a `POST`, `PATCH`, or `PUT` API request, use the **API step** and enter the JSON directly into the **Request Body** field.

* **Use merge tags** to dynamically insert data from your flow. A merge tag is a column name wrapped in **single curly braces**, like `{order name}`.
* Prowork will automatically replace these with the actual values from the referenced column when the flow runs.

**Example:**

```
{
  "order_id": "{order name}",
  "status": "shipped"
}
```

## **2. Create JSON in a Column (Using Add Text Column Step)**

If you need to build JSON **within your flow** (e.g., to generate line items for an array), use the **Add text column** step.

* Write your JSON structure as plain text.
* Reference column values with **merge tags**, using single curly braces like `{inventory amount}`.
* Prowork will substitute these with the correct values when the flow runs.

**Example:**

```json theme={null}
{
  "sku": "{product code}",
  "quantity": {inventory amount}
}
```

This method is especially useful when creating line items. You can then use the **Merge duplicate rows** step to combine them into a single array string, using commas or line breaks as delimiters.

### **Example: Creating Line Items in JSON and Merging Them into an Array**

Let's say you have a table like this:

| order id | sku | quantity |
| :- | :- | :- |
| 12345 | ABC-001 | 2 |
| 12345 | XYZ-999 | 1 |

**1. Use Add text column to create line item JSON per row**

In the **Add text column** step, create a new column, called "line item JSON," with this JSON structure:

```json theme={null}
{"sku": "{sku}", "quantity": {quantity}}
```

Your output will look like:

| order id | sku | quantity | line item JSON |
| :- | :- | :- | :- |
| 12345 | ABC-001 | 2 | \{"sku": "ABC-001", "quantity": 2} |
| 12345 | XYZ-999 | 1 | \{"sku": "XYZ-999", "quantity": 1} |

**2. Use Merge duplicate rows to group line items by order**

* Group by `order id`
* Merge the **line item JSON** column
* Use **comma** as the delimiter

Your result:

| order id | line item JSON |
| :- | :- |
| 12345 | `{"sku": "ABC-001", "quantity": 2}, {"sku": "XYZ-999", "quantity": 1}` |

You now have a comma-separated string of line items for each order. Wrap it in square brackets when you use it in a request body, for example `"line_items": [{line item JSON}]`.

## **3. Create JSON Using the Custom Transform Step**

For more complex JSON structures, use the **Custom transform** step. This step allows you to describe the JSON you want, and Prowork will generate code to build it for each row.

* **Be specific** in your instructions.
* Include an **example JSON output** when possible.
* Remind the step to wrap column names in single curly braces. For example, reference a column like this: `{total price}`.

**Step Instruction Tip:**

When writing your prompt in the Custom transform step, say something like:

"Create a JSON object that includes `total_price` from the column named 'total price'. Wrap all column references in single curly braces like `{column name}`."

Each method has different strengths depending on your goal, use API step for external calls, Add text column for row-level JSON strings, and Custom transform for complex, rule-based JSON creation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.