---
schema_version: "1"
id: 7fda08ff7ccf3a33263d137fb3601350799828a5d19e066202ab90e650816f51
title: Set Payload (<set-payload/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-set-payload.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-set-payload
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7fe6b97711ff4db7766e32fd8552b1ffbdfdf3fa224013049fc377f7ef30d13e
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Set Payload (<set-payload/>)

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Sets or updates the payload of the message.

The payload can be a literal string or a DataWeave expression. Use the `set-payload` component only
for simple expressions or transformations. For complex scenarios, use the
[Transform Message Component](https://docs.mulesoft.com/anypoint-code-builder/acb-component-transform).

## Component XML

This component supports the following XML structure:

```xml
<set-payload
  value=""
  doc:name="Set payload"
  doc:id="vnjpqo" />
```

Set Payload (`<set-payload/>`) attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Set payload</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr><tr><td><p><strong>Value</strong></p></td><td><p><code>value</code></p></td><td><div><div><p>A literal string or DataWeave expression that defines how to set the payload, for example, <code>"some string"</code> or <code>#[now()]</code>. This attribute is required.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>resource</code></p></td><td><div><div><p>A <code>.dwl</code> file containing a DataWeave transformation script. These values are resolved statically (not dynamically). For example, using <code>&lt;ee:set-payload resource="myscript-$site.dwl"/&gt;</code> generates an error. For more information, see <a href="https://docs.mulesoft.com/dataweave/latest/dataweave-language-introduction#dwl_file">dwl File</a>.</p></div></div></td></tr><tr><td><p><strong>Encoding</strong></p></td><td><p><code>encoding</code></p></td><td><div><div><p>Encoding of the payload that this component outputs.</p></div></div></td></tr><tr><td><p><strong>Mime type</strong></p></td><td><p><code>mimeType</code></p></td><td><div><div><p>MIME type of the payload that this component outputs. For more information, see <a href="https://docs.mulesoft.com/dataweave/latest/dataweave-formats#reader_writer_properties">Using Reader and Writer Properties</a>.</p></div></div></td></tr><tr><td><p><strong>Parameters</strong></p></td><td><p>N/A</p></td><td><div><div><p>Appends a key-value pair for a reader property to the value of the <code>outputMimeType</code> attribute. Multiple key-value pairs are allowed. Reader properties are specific to the MIME type. For example, see the <a href="https://docs.mulesoft.com/dataweave/latest/dataweave-formats-json#properties">JSON reader properties</a> for <code>application/json</code>. To find other reader properties, navigate to a supported format from the <a href="https://docs.mulesoft.com/dataweave/latest/dataweave-formats">DataWeave format documentation</a>, and see <a href="https://docs.mulesoft.com/dataweave/latest/dataweave-formats#reader_writer_properties">Using Reader and Writer Properties</a>.</p></div></div></td></tr></tbody></table>

> [!WARNING] The `mimeType` and `encoding` attributes do not affect a DataWeave expression used as a
> `value`. These attributes affect the _output_ Mule Message only. If a transformation is required,
> the DataWeave expression must contain an explicit `output` directive.

## Examples

The following examples show how to set the payload using a static value or a DataWeave expression.

### Example: Set the Payload with a Static Value

The following example sets a payload with static values:

```xml
<set-payload value="{ 'name' : 'Ana', 'office' : 'BA' }" mimeType="application/json" encoding="UTF-8"/>
```

### Example: Set the Payload Using a DataWeave Expression

The following example sets the message payload to `"Hello, World"` appending today’s date using a
DataWeave expression: `#['Hello World!' ++ ' Today is ' ++ now()]`

```xml
<set-payload value="#['Hello World!' ++ ' Today is ' ++ now()]"/>
```

## See Also

- [Mule Message Structure](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message)

- [DataWeave Language](https://docs.mulesoft.com/dataweave/latest/)
