> 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/service-commissioning-files/resources/cybus-model.md). Agents can also search and read this documentation through its [MCP server](https://docs.cybus.io/~gitbook/mcp).

# Cybus::Model

Define the data properties, attributes, and relations that every asset of one type shares, and version them as the type changes.

The **Cybus::Model** resource describes one type of asset, such as a pump or a milling center. Each [Cybus::Asset](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-asset.md) follows one model version. The mount of an asset decides where it is, and its endpoints decide how it is connected. For how the UNS resources work together, see [Namespaces, Models, and Assets](https://docs.cybus.io/2-8-0/unified-namespace/unified-namespace.md).

## Model Properties

| Property                    | Type      | Required     | Default   |
| --------------------------- | --------- | ------------ | --------- |
| [modelId](#modelid)         | `string`  | **Required** |           |
| [version](#version)         | `integer` | **Required** |           |
| [description](#description) | `string`  | Optional     |           |
| [implements](#implements)   | `array`   | Optional     |           |
| [data](#data)               | `object`  | Optional     |           |
| [attributes](#attributes)   | `object`  | Optional     |           |
| [relations](#relations)     | `object`  | Optional     |           |
| [targetState](#targetstate) | `enum`    | Optional     | `enabled` |

### modelId

The identity of the model across all services. Assets reference a model by its `modelId` or with `!ref` in the same service commissioning file.

The `modelId` stays the same across versions and is independent of the resource ID. So one service commissioning file can declare two versions of the same model under different resource IDs, for example during a migration.

* **Required**
* Type: `string`
  * Minimum length: 1 character
  * Must not start with `cybus:`, which is reserved

### version

The version of the model. With the default `modelVersioning: strict` policy of the namespace, an installed version cannot change. Any change to its data properties or attributes needs a new version. For what may change within a version, see [Model Versioning](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-namespace.md#model-versioning). To reference one version, see [Referencing a Model](#referencing-a-model).

* **Required**
* Type: `integer`
  * Minimum: 1

### description

A description of the model.

* **Optional**
* Type: `string`

### implements

The models whose data properties and attributes this model inherits. A circular chain of `implements` fails the installation.

* **Optional**
* Type: `array` of model references (`modelId` or `!ref`)

### data

The values that an asset of this type publishes. Each data property becomes a topic of the asset. If the machine writes a value, it is a data property.

* **Optional**
* Type: `object` (property name → property definition)

A property definition is a JSON Schema plus the keywords in the following table. Every property needs a `type`, one of `string`, `number`, `integer`, `boolean`, `object`, or `array`. Use nested `properties` for an object and `items` for an array.

| Keyword      | Type      | Description                                                                                                                                                                                 |
| ------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `unit`       | `string`  | The unit of the value, for example `bar`. It is published in `$meta`.                                                                                                                       |
| `semanticId` | `string`  | A semantic identifier, such as an ECLASS or IDTA ID or your own URI. It is published in `$meta`.                                                                                            |
| `writable`   | `boolean` | When `true`, the property also gets a `/set` topic for commands and a `/res` topic for their results.                                                                                       |
| `model`      | `string`  | Only with `type: object`. The value has the shape of another model, for example a three-phase current. The data properties and attributes of that model become the properties of the value. |

The property definitions describe the data for the clients that read it. The `$meta` topic of each asset carries the `unit`, `semanticId`, and `writable` of each data property. The [Topic Explorer API](https://docs.cybus.io/2-8-0/reference/api-reference/topic-explorer-api.md) returns the complete definitions of a model.

Connectware checks the attribute values of an asset against the model when you install the service. Endpoints and mappings publish their messages on the topics of data properties as they are. An endpoint that references a data property publishes its usual `{ timestamp, value }` message on the topic of the property.

Property names start with a letter and contain only letters, digits, and underscores, so camelCase names such as `toolTemperature` are valid. They do not have to match the `naming` policy of the namespace. The names `set`, `res`, and `_quarantine`, and names that start with `$`, are reserved.

A data property inherited through `implements` can have the same name as another data property, inherited or the model's own. Identical definitions are allowed. If the two definitions differ, the installation fails. The same applies to attributes.

A data property and an attribute can share a name.

### attributes

The facts about an asset that a person writes when commissioning it, such as the serial number or the manufacturer. Connectware publishes them in the `$meta` topic of the asset. If you enter a value when you commission the asset, it is an attribute.

* **Optional**
* Type: `object` (attribute name → property definition)

Attributes use the same property definitions as [data](#data). Add `required: true` to an attribute that every asset must set. When you install an asset, Connectware checks its attribute values against the model. See [attributes](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-asset.md#attributes) of the asset.

### relations

The typed links that assets of this model can have to assets of other models, for example `suppliedBy` a warehouse system. The model declares the relations. Each [asset](https://docs.cybus.io/2-8-0/data-flows/service-commissioning-files/resources/cybus-asset.md#relations) fills them with the IDs of the related assets.

* **Optional**
* Type: `object` (relation name → relation definition)

| Property      | Type     | Required     | Default | Description                                                                                         |
| ------------- | -------- | ------------ | ------- | --------------------------------------------------------------------------------------------------- |
| `target`      | `string` | **Required** |         | The model of the related assets, by `modelId` or `!ref`. Connectware checks that this model exists. |
| `cardinality` | `enum`   | Optional     | `many`  | `one` or `many`. Connectware stores it, and the Topic Explorer API returns it with the model.       |

### targetState

Whether the resource is active. Assets that follow a disabled model keep their topics.

* **Optional**
* Type: `enum`
  * Allowed values: `enabled`, `disabled`
* Default: `enabled`

## Removing a Model

A model cannot be removed while a resource of another service references it. Such a resource can be one of the following:

* An asset that follows the model
* A model that implements it
* A model whose data property uses it with the `model` keyword
* A relation that targets it

Changing the `modelId` or `version` of such a model counts as a removal. A service also cannot declare a model version that another service already owns.

## Referencing a Model

Assets, `implements`, and relation targets reference a model in one of the following ways:

* `!ref <resourceId>` for a model in the same service commissioning file.
* `<modelId>`, for example `Pump`.
* `<modelId>@<version>`, for example `Pump@2`, to select one version.
* `srv:<serviceId>/<modelId>`, optionally with `@<version>`, to select the model of one service.

If a reference is unknown, the installation fails. A reference can also match more than one model, for example when two versions of `Pump` are installed. The installation then fails with an error that lists the candidates. Add the version or the service qualifier to resolve it.

A reference without a version selects the only installed version of a model. A new version would make that reference match two models. While another service holds such a reference, the installation of a new version fails, and the error names those references. The form of the reference decides which installations it blocks:

* `Pump` blocks a new version of `Pump` in any service.
* `srv:models/Pump` blocks a new version only in the `models` service.

If you expect new versions, reference the model with its version, such as `Pump@1`.

## Example

The following model describes a pump with measured values, a writable setpoint, and attributes.

{% code lineNumbers="true" %}

```yaml
pumpModel:
  type: Cybus::Model
  properties:
    modelId: Pump
    version: 1
    description: A centrifugal pump
    data:
      temperature:
        type: number
        unit: Cel
        minimum: -50
        maximum: 250
      pressure:
        type: number
        unit: bar
      setpoint:
        type: number
        unit: Cel
        writable: true
    attributes:
      serialNumber:
        type: string
        required: true
      manufacturer:
        type: string
```

{% endcode %}

An asset of this model publishes `temperature`, `pressure`, and `setpoint` on topics of their own, and receives setpoint commands on `setpoint/set`. Its serial number and manufacturer appear in its `$meta` topic.


---

# 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/service-commissioning-files/resources/cybus-model.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.
