# Reading and replacing the Mule event payload

*MuleSoft Developer Study Guide · Accessing and Modifying Mule Events · Last updated October 28, 2026 · https://www.certifyforce.com/study-guide/mulesoft-developer/accessing-and-modifying-mule-events/reading-and-replacing-the-mule-event-payload*

How the Mule 4 event splits into a message (payload and attributes) and variables, how Set Payload, Transform Message, operations and the Logger affect the payload, and how DataWeave selectors, `#[ ]` delimiters and the `.^mimeType` metadata selector decide what a flow outputs.

- Certification: Salesforce MuleSoft Developer
- Exam section: Accessing and Modifying Mule Events
- Study guide: https://www.certifyforce.com/study-guide/mulesoft-developer

**Official exam objective:**

> Apply correct processors/DataWeave expressions to access and modify Mule event payloads, and predict outcomes.

## What the exam expects

- Describe the Mule 4 event: a message holding the payload and attributes, plus variables that sit outside the message.
- Predict the payload after Set Payload, a Logger, or a connector operation without a target, given a short XML flow.
- Write Set Payload values correctly: a literal string versus a `#[ ]` DataWeave expression, and an output directive instead of `mimeType` when the expression must produce JSON.
- Choose Set Payload for simple selections and Transform Message for complex transformations.
- Predict DataWeave selector results on the payload: single-value on an object or an array, index, and the `.^mimeType` metadata selector.
- Key terms: **Mule event** (message plus variables); **Mule message** (payload plus attributes, immutable); **payload** (the body, read with `payload`); **Set Payload** (Core transformer that replaces the payload); **selector** (DataWeave syntax that returns matching values); **metadata selector** (`.^name`, returns metadata such as the MIME type instead of content).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Event parts | A Mule message (payload + attributes) plus variables | [Mule Event Structure](https://docs.mulesoft.com/mule-runtime/latest/about-mule-event) |
| Immutability | Each processor that receives a message returns a new Mule message | [Mule Message Structure](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message) |
| Set Payload fields | Value required; Mime Type and Encoding optional | [Set Payload Transformer](https://docs.mulesoft.com/mule-runtime/latest/set-payload-transformer-reference) |
| `mimeType` on Set Payload | Does not affect a DataWeave value; transformation needs an explicit output directive | [Set Payload Transformer](https://docs.mulesoft.com/mule-runtime/latest/set-payload-transformer-reference) |
| Complex transformations | Use Transform Message, not Set Payload | [Set Payload Transformer](https://docs.mulesoft.com/mule-runtime/latest/set-payload-transformer-reference) |
| Expression syntax in Studio | `#[payload]` in Anypoint Studio; bare `payload` only in Design Center | [Set Variable Transformer](https://docs.mulesoft.com/mule-runtime/latest/variable-transformer-reference) |
| Logger | Writes to the log (Console in Studio); default level `INFO` | [Logger Component](https://docs.mulesoft.com/mule-runtime/latest/logger-component-reference) |
| Single-value selector on an array | Applies to every object in the array and returns an array | [DataWeave Selectors](https://docs.mulesoft.com/dataweave/latest/dataweave-selectors) |
| No matching key | Single-value selector returns `null` | [DataWeave Selectors](https://docs.mulesoft.com/dataweave/latest/dataweave-selectors) |
| Metadata selector | `.^mimeType` returns the MIME type of a payload, variable or attribute | [DataWeave Selectors](https://docs.mulesoft.com/dataweave/latest/dataweave-selectors) |
| `vars` | Holds only variables set on the event, read as `vars.myVar` | [Predefined Variables](https://docs.mulesoft.com/dataweave/latest/dataweave-variables-context) |

## Check yourself

- When does the component after an operation receive the same message the operation received?
- Why are Transform Message and Set Payload listed in different groups on the Core Components page?
- What does `payload.name` return for `[{"name": "Arg"}, {"name": "Japan"}]`?
- Which level does a Logger use by default?

## Sources

- [Set Payload Transformer](https://docs.mulesoft.com/mule-runtime/latest/set-payload-transformer-reference)
- [Mule Message Structure](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message)
- [Mule Event Structure](https://docs.mulesoft.com/mule-runtime/latest/about-mule-event)
- [Predefined Variables](https://docs.mulesoft.com/dataweave/latest/dataweave-variables-context)
- [DataWeave Selectors](https://docs.mulesoft.com/dataweave/latest/dataweave-selectors)
- [Logger Component](https://docs.mulesoft.com/mule-runtime/latest/logger-component-reference)
- [Core Components](https://docs.mulesoft.com/mule-runtime/latest/about-components)
- [Set Variable Transformer](https://docs.mulesoft.com/mule-runtime/latest/variable-transformer-reference)
- [Enrich Data with Target Variables](https://docs.mulesoft.com/mule-runtime/latest/target-variables)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 8 linked practice questions, and unlimited timed mock exams are included with the MuleSoft Developer pack (USD $19): https://www.certifyforce.com/practice-exams
