---
schema_version: "1"
id: 8bdceb22f87446eeb62ff60a9a9a5f79a4ea605be7f6b59a2faad8e45061cf95
title: Set Payload Transformer
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.6/set-payload-transformer-reference.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.6/set-payload-transformer-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1293b4b1de38506444486657dedf3545578c6278b0412320725cb0879534663f
description: MuleSoft Documentation Site
release: "4.6"
latest: false
---
---
product: Mule Runtime
version: 4.6
keywords: anypoint studio, mule, set payload, payload
---

# Set Payload Transformer

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

The Set Payload (`set-payload`) component lets you update the payload of the message. The payload
can be a literal string or a DataWeave expression. The `set-payload` component, however, is not
recommended for complex expressions or transformations but rather, simple ones, such as selections.
You should use [Transform Message Component](https://docs.mulesoft.com/mule-runtime/4.6/transform-component-about) for complex scenarios.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>Usage</th><th>Description</th></tr></thead><tbody><tr><td><p>Value (<code>value</code>)</p></td><td><p>Required</p></td><td><p>Accepts a literal string or DataWeave expression that defines how to set the payload, for example, <code>"some string"</code> or <code>#[now()]</code>.</p></td></tr><tr><td><p>Mime Type (<code>mimeType</code>)</p></td><td><p>Optional</p></td><td><p>The mime type of the value assigned to the payload, for example, <code>text/plain</code> or <code>application/json</code>.</p></td></tr><tr><td><p>Encoding (<code>encoding</code>)</p></td><td><p>Optional</p></td><td><p>The encoding of the value assigned to the payload, for example, <code>UTF-8</code>.</p></td></tr></tbody></table>

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

This XML example sets a payload with static values:

Static Content Example:

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

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

Expression Content Example:

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

## See Also

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

- [DataWeave Language](https://docs.mulesoft.com/mule-runtime/4.6/dataweave)
