---
schema_version: "1"
id: 502b20263449f5f1595197bb62cbc085c10dd112f65cc4761f48be8217dedb17
title: Set Payload Transformer
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/latest/set-payload-transformer-reference.md
canonical_url: https://docs.mulesoft.com/mule-runtime/latest/set-payload-transformer-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0a7ee35b8f5426293442bc3d63e80f70e0d7f376c4fca22bbf38a8b74f5bd077
description: MuleSoft Documentation Site
release: "4.13"
latest: true
---
---
product: Mule Runtime
version: 4.13
is-latest-version: true
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/latest/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/latest/about-mule-message)

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