Contact Us 1-800-596-4880

Mule Message Structure

This version of Mule reached its End of Life on May 2, 2023, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

A Mule message is the part of the Mule event that serves as a container for message content and metadata, typically from external sources, as it is processed within flows of a Mule app.

The Mule message is immutable, so every change to a Mule message results in the creation of a new instance. Each processor in a flow that receives a message returns a new Mule message consisting of these parts:

  • A message payload, which contains the body of the message. For example: the content of a file, a record from a database, or the response to a REST or Web Service request.

  • Message attributes, which are metadata associated with the payload.

mule message structure 82af1

A Mule message is created as part of a Mule event when a Message source in a Mule flow triggers a flow to start, as when an HTTP listener receives a response or each time the Scheduler component triggers an execution of the flow.

For example, when an HTTP listener in a Mule app receives a response, it creates a Mule event with a Mule message that contains the content of the response as its payload along with the metadata associated with that content, such as HTTP headers, as it attributes. Message processors in the flow (such as Core components, File read operations, or the HTTP request operations) can then retrieve, set, and process Mule message data that resides in the Mule event according to their configurations.

Note that in Anypoint Studio, the xref:@studio::datasense-explorer.adoc[DataSense Explorer] shows the structure of a Mule message at any given point of the flow.

Message Payload

The message payload contains the content or body of a message. For example, the payload can contain the results of an HTTP request, the content of records you retrieve through the Select operation of the Database connector, or the content of a file that you retrieve through a Read operation to the File or FTP connector.

The payload content changes as it travels through a flow when message processors in a Mule flow set it, enrich it, transform it into a new format, extract information from it, or even store it in a Mule event variable and produce a new payload.

You can select the payload of a Mule message through a DataWeave expression that uses the Mule Runtime variable, payload.

For example, a Logger component configured to display the payload of a response to an HTTP request for the JSON content at outputs the following example JSON content in the Studio console:

Example: HTTP Response Payload
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "",
    "address": {
      "street": "Kulas Light",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
    "id": 2,
    "name": "Ervin Howell",
    "username": "Antonette",
    "email": "",
    "address": {
      "street": "Victor Plains",
      "city": "Wisokyburgh",
      "zipcode": "90566-7771",
      "geo": {
        "lat": "-43.9509",
        "lng": "-34.4618"

A Logger component set to display the payload for the output of a File Read operation for a simple JSON file can output the following example JSON content in the Studio console:

Example: File Payload
{ "hello" : "world" }

The next message processor in the flow can then act on this payload, for example, by selecting the value of the JSON object in the payload with payload.'hello' to replace the preceding JSON payload with the string, "world".


Attributes contain the metadata associated with the body (or payload) of the message. The specific attributes of a message depend on the connector (such as HTTP, FTP, File) associated with the message. Metadata can consist of headers and properties received or returned by a connector, as well as other metadata that is populated by the connector or through a Core component, such as Transform Message.

You can select attributes of a Mule message through a DataWeave expression that uses the Mule Runtime variable, attributes.

For example, when using the attributes variable to display HTTP response metadata through a Logger component, the Studio console outputs the following example HTTP response attributes:

Example: HTTP Response Attributes
   Status Code=200
   Reason Phrase=OK
      date=Sun, 20 Jan 2019 19:13:51 GMT
      expires=Mon, 20-Jan-20 19:13:51 GMT;
      vary=Origin, Accept-Encoding
      cache-control=public, max-age=14400
      last-modified=Tue, 15 Jan 2019 18:17:15 GMT
      via=1.1 vegur
      expires=Sun, 20 Jan 2019 23:13:51 GMT

The example is a response from an HTTP Request operation to the web page

Notice that each attribute is a key/value pair separated by an equal sign (=). You access the value of an attribute through its key. For example, when using a connector or component (such as the Logger) in your flow, you can access attributes of an HTTP response or a file that you are reading with the following syntax:

  • attributes.'statusCode' to select an HTTP status code like 200.

  • attributes.headers.'date' to select Sun, 20 Jan 2019 18:54:54 GMT from the header of an HTTP response.

  • attributes.headers.'content-type' to select the HTTP content type application/json.

For file metadata the attributes are different. For example, when using the attributes variable to display file metadata through a Logger component, the Studio console displays the following example content:

Example: File Attributes

Notice that each attribute is a key/value pair (such as fileName=myJson.json). You can select the value of an attribute by referencing its key, for example:

  • attributes.'fileName' to return the file name: myJson.json.

  • attributes.size to return the size of the file: 22.

Valid Identifiers for Attribute Names

You can access and declare attribute names that follow the rules described in Rules for Declaring Valid Identifiers without using any quotation marks.

To use an attribute name that is not a valid identifier, surround the attribute name with any of the following characters:

  • Single quotation marks (')

  • Double quotation marks (")

  • Backticks (`)

For example, consider the following DataWeave variable declaration:

var myVar = {
              id : "1234",
              "123 abc !@#" : "some_value"

Because attribute name 123 abc !@# is not a valid identifier, you must use quotation marks or backticks to declare it.

To access the value from attribute 123 abc !@#, which is "some_value", use quotation marks or backticks:

myVar.'123 abc !@#'

Using quotation marks or backticks to declare an attribute or select a value from an attribute when the attribute name is a valid identifier is optional.

In the previous variable declaration example, attribute id is declared without using any quotation marks. To access the value stored in attribute id, you can use any of the following methods:


  • myVar.'id'

  • myVar."id"

  • myVar.`id`