---
title: Set Property
description: Learn how to use EIPs
documentId: ipaas-eips-setproperty
locale: en-US
---

The **Set Property** EIP is used in the context of message exchange (*exchange*).
Properties are useful for storing intermediate data that can be accessed in other steps of the flow.

<Callout type="note" title="NOTE">
Properties are metadata associated with the message, but are not part of either the body or the header of the message.
</Callout>

## Parameters

| Parameter | Description | Default value | Type |
|-----------|-----------|--------------|------|
| Name | Name of the property that will be set. | | String |
| Expression | Expression that returns the property value. | | ExpressionDefinition |

## Expression

The **expression** allows you to calculate or dynamically define values during message processing in the integration flow.
It is a way to configure behaviors that can vary according to the context of the message in transit.

The expression is organized into two hierarchical levels that allow the structure to be more extensible and adaptable to different contexts:

* **First level**: specifies the type of logic that will be applied (*constant*, *simple*, *jsonpath*, etc.).

* **Second level**: defines the actual value of the expression, that is, the data that will be assigned to the property.

### Common types of expressions

* `constant`: assigns fixed values.
In the example, the `myProperty` property will be defined as `FixedValue`.

```yaml
- setProperty:
    name: myProperty
    expression:
      constant: "FixedValue"
```

* `simple`: accesses simple data (headers, body, properties) and manipulates values in a basic way.
In the example, the expression `${header.orderId}` accesses the `orderId` header and uses it as the value of the `myProperty` property.

```yaml
- setProperty:
    name: myProperty
    expression:
      simple: ${header.orderId}
```

* `xpath`: uses XPath queries to extract data from XML documents.
In the example, the XPath expression `/order/id` extracts the value of the `id` field from an XML with the structure `<order><id>123</id></order>`.

```yaml
- setProperty:
    name: myProperty
    expression:
      xpath: "/order/id"
```

* `jsonpath`: uses JSONPath queries to extract data from JSON documents.
In the example, the expression `$.order.id` extracts the value of the `id` field from a JSON object: `{ "order": { "id": 123 } }`.

```yaml
- setProperty:
    name: myProperty
    expression:
      jsonpath: "$.order.id"
```

* `groovy`: executes Groovy scripts for advanced data manipulation.
In the example, the value of `myProperty` will be calculated by the Groovy script, which returns the value of the `orderId` header incremented by 1.

```yaml
- setProperty:
    name: myProperty
    expression:
      groovy: "return message.getHeader('orderId') + 1"
```

### Examples

**Example 1**

```yaml
- setProperty:
    name: itemId
    expression:
       simple: ${body['id']}
```

* `name: itemId`: name of the property that will be defined.
The property will be referenced as `itemId` in the next steps of the route.

* `expression: simple: ${body['id']}`: uses the simple language to extract data from the message body (*body*).
In this case, it is accessing a field called `id` within a body that is presumably a data structure like a map (JSON or similar).
The value extracted from the `id` field will be assigned to the `itemId` property.

  Imagine that the message body is something like:

  ```yaml
  {
    "id": "12345",
    "name": "Sample Item"
  }
  ```

  * Camel will evaluate the expression `${body['id']}` and extract the value `12345` from the `id` field.
  * This value will be stored in the property called `itemId`.

**Example 2**

```yaml
- setProperty:
    id: setProperty-1014206318
    name: fullData
    expression:
      simple: >-
```

* `name`: name of the property that will be created or updated in the exchange context.
In this case, the property will be called `fullData`.

* `expression`: defines the property value using an expression.
In this case, a simple language expression is used.

  * `"${header.id}"`: extracts the value of the header called `id` and inserts it as the value of the `id` key.

  * `${exchangeProperty.customerData}`: retrieves the value stored in the `customerData` property of the exchange and assigns it to the `json` key.

  ```
  ```

<Callout type="note" title="NOTE">
The use of ">-" at the beginning of the expression keeps the text readable in YAML, as it ensures that the processed value is treated as a single line without unnecessary breaks.
</Callout>
