> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/2-8-0/data-flows/services/managing/changing-resources-through-the-api/writing-properties.md). Agents can also search and read this documentation through its [MCP server](https://docs.cybus.io/~gitbook/mcp).

# Writing Properties

How the Services API handles tagged values, lists, masked secrets, and shared YAML values, and how a write changes the service commissioning file.

When you [change a resource through the API](https://docs.cybus.io/2-8-0/data-flows/services/managing/changing-resources-through-the-api.md), Connectware turns the JSON you send into YAML in the service commissioning file. This page describes the rules for tagged values, lists, masked secrets, and shared YAML values.

## Tagged Values

A tagged value is an object with the tag as its only key. What you send is what is written, so to point a reference at another resource, send `{ "!ref": "otherConnection" }`, not `"otherConnection"`.

{% code lineNumbers="true" %}

```json
{
  "connection": { "!ref": "opcuaConnection" },
  "topic": { "!sub": "${Cybus::MqttRoot}/in" },
  "options": { "!merge": { "host": "broker" } }
}
```

{% endcode %}

| To…                                           | Send                                                                |
| --------------------------------------------- | ------------------------------------------------------------------- |
| Replace a `!ref` or `!sub` value              | The new value in a `PATCH`.                                         |
| Change part of a `!merge` object              | The change inside the wrapper, `{ "!merge": { … } }`, in a `PATCH`. |
| Replace a `!merge` object with a plain object | The new object in a `PUT`.                                          |

The following rules also apply:

* `!ref` and `!sub` hold text, and `!merge` holds an object. Any other key next to the tag returns `400`.
* Connectware checks tagged values when it deploys the service, not against the schema of the type.
* A `${param}` resolves with the parameters the service already has. A write cannot change parameters.
* A block written as `properties: !ref someDefinition` cannot be written through the API.

## Lists

A `PATCH` replaces a list as a whole, so send the complete list. Every item keeps its tags. Connectware writes list items by position, so comments stay with their items when you change items in place, add items at the end, or only remove items. When you insert items before others or change their order, a comment can end up on a different item. An item that uses a `<<` merge key cannot be moved.

## Secrets

A read masks a value as `*****` when its key matches `CYBUS_RESOURCES_CONFIG_SENSITIVE_PROPERTY_NAME_PATTERN`, at any depth. By default, that is every key that contains `pass`, `secret`, `key`, or `token`, so some values that are not secret are masked too, such as the `key` of a rule. See [Environment Variables](https://docs.cybus.io/2-8-0/reference/environment-variables.md).

| To…                                          | Send                                                                     |
| -------------------------------------------- | ------------------------------------------------------------------------ |
| Keep a masked value                          | The mask, unchanged. A `PUT` also keeps a masked key that you leave out. |
| Change a masked value                        | The new value.                                                           |
| Delete a masked key                          | `null` for the key in a `PATCH`.                                         |
| Replace an object that the read masked whole | The complete new object in a `PATCH`.                                    |

If you leave out an object in a `PUT`, the masked keys inside it are deleted with it.

In a list, Connectware restores masked values only for items that you send back exactly as you read them. If you change anything in an item, send all its masked values in full. For example, a mapping row reads as follows:

{% code lineNumbers="true" %}

```json
{ "subscribe": { "topic": "a" }, "rules": [{ "cov": { "key": "*****" } }] }
```

{% endcode %}

To change `topic` to `b`, send the real value of `key`, such as `"key": "id"`. With `"key": "*****"`, the write returns `422`.

{% hint style="warning" %}
Two items can look the same after masking, for example two users named `op` with different passwords. If you move items or change the length of the list, send the secrets of these items in full.
{% endhint %}

## Shared YAML Values

Anchors, aliases, and `<<` merge keys share values between resources.

| Shared value                               | Result of a write                                                      |
| ------------------------------------------ | ---------------------------------------------------------------------- |
| Used by another resource through an anchor | Cannot be changed, retagged, or deleted.                               |
| Used by this resource through an alias     | The resource gets its own copy and no longer follows the shared value. |
| Inherited through a `<<` merge key         | Cannot be deleted or retagged. A change gives the block its own copy.  |

To change what the API refuses, edit the service commissioning file and update the service.

## The Service Commissioning File After a Write

A write changes only the block of the resource, plus, for a rename, the blocks whose references it rewrote. All other lines and comments stay as they are. A new block goes after the last resource. A deleted block is removed with the comments directly above it.

Inside a written block, the values stay the same, but the formatting can change. For example, folded text (`>`) becomes one line, values can get quotes, `0x1F` becomes `0x1f`, and `.5` becomes `0.5`.

Connectware writes the whole service commissioning file again in the following cases:

* A renamed resource is referenced from the `definitions` section.
* The last resource is deleted, which leaves `resources: {}`.
* The `resources` map is empty or written in flow style.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cybus.io/2-8-0/data-flows/services/managing/changing-resources-through-the-api/writing-properties.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
