> ## Documentation Index
> Fetch the complete documentation index at: https://docs.connectedfleet.michelin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Domain events

# Domain Events API 1.0.0 documentation

AsyncAPI documentation for domain change events.

This API describes the structure of events when domain entities are created, updated, or deleted.

Supported entity types:

* Asset: Vehicles and equipment
* User/Driver: People and drivers
* HierarchyNode: Organization hierarchy groups
* Customer: Customer accounts

The message format uses compact JSON with abbreviated field names for bandwidth efficiency. The fc, cv, and pv fields contain embedded JSON strings that must be parsed separately.

## Table of Contents

* [Servers](#servers)
  * [kafka](#kafka-server)
* [Operations](#operations)
  * [RECEIVE mn\_domain\_events](#receive-mn_domain_events-operation)

## Servers

### `kafka` Server

* URL: `kafka://{brokerHost}:{brokerPort}/`
* Protocol: `kafka-secure`

#### URL Variables

| Name       | Description           | Default value | Allowed values |
| ---------- | --------------------- | ------------- | -------------- |
| brokerHost | Kafka broker hostname | `localhost`   | *Any*          |
| brokerPort | Kafka broker port     | `9092`        | *Any*          |

#### Security

##### Security Requirement 1

* security.protocol: SASL\_SSL
* sasl.mechanism: OAUTHBEARER

## Operations

### RECEIVE `mn_domain_events` Operation

*Receive a domain event*

* Operation ID: `receiveDomainEvent`

Channel for domain change events. Events for all entity types (Asset, User/Driver, HierarchyNode, Customer) are published to this channel.

Receives domain events when an entity is created, updated, deleted, or refreshed.

The ety (entityType) field determines which entity type the event relates to:

* Asset: Vehicle/equipment changes
* User/Driver: Person/driver changes
* HierarchyNode: Organization hierarchy changes
* Customer: Customer account changes

#### Message Domain Event `DomainEvent`

*A domain change event for any supported entity type*

* Message ID: `domainEvent`
* Content type: [application/json](https://www.iana.org/assignments/media-types/application/json)

##### Payload

| Name                 | Type           | Description                                                                                                                                                                                                                                                                                                                                                                    | Value                                                                 | Constraints          | Notes                                 |
| -------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | -------------------- | ------------------------------------- |
| (root)               | object         | Domain event payload with compact field names.  The fc, cv, and pv fields contain JSON strings that must be parsed. Their structure depends on the ety (entityType) field: <ul><li> Asset: See AssetEntity schema </li><li> User/Driver: See PersonEntity schema</li><li> HierarchyNode: See HierarchyNodeEntity schema</li><li> Customer: See CustomerEntity schema</li></ul> | -                                                                     | -                    | **additional properties are allowed** |
| et                   | string         | Event timestamp - when the domain event occurred (ISO 8601 format)                                                                                                                                                                                                                                                                                                             | -                                                                     | format (`date-time`) | **required**                          |
| un                   | string         | Username - the user who made the change                                                                                                                                                                                                                                                                                                                                        | -                                                                     | -                    | -                                     |
| cid                  | string         | Customer ID - identifier of the customer owning the entity                                                                                                                                                                                                                                                                                                                     | -                                                                     | -                    | **required**                          |
| eid                  | string         | Entity ID - unique identifier of the changed entity                                                                                                                                                                                                                                                                                                                            | -                                                                     | -                    | **required**                          |
| en                   | string         | Entity name - human-readable name of the entity (e.g., asset registration, person name)                                                                                                                                                                                                                                                                                        | -                                                                     | -                    | -                                     |
| ety                  | string         | Entity type - determines the structure of fc, cv, and pv fields                                                                                                                                                                                                                                                                                                                | allowed (`"Asset"`, `"User/Driver"`, `"HierarchyNode"`, `"Customer"`) | -                    | **required**                          |
| ddo                  | string         | Domain data operation:<ul><li>CREATED: New entity created</li><li>UPDATED: Existing entity modified</li><li>DELETED: Entity removed</li><li>REFRESH: Entity data refreshed (sync)</li></ul>                                                                                                                                                                                    | allowed (`"CREATED"`, `"UPDATED"`, `"DELETED"`, `"REFRESH"`)          | -                    | **required**                          |
| ipids                | array\<string> | Interested party IDs - list of interested party identifiers (omitted if empty)                                                                                                                                                                                                                                                                                                 | -                                                                     | -                    | -                                     |
| ipids (single item)  | string         | -                                                                                                                                                                                                                                                                                                                                                                              | -                                                                     | -                    | -                                     |
| iptags               | array\<string> | Interested party tags - list of interested party tags (omitted if empty)                                                                                                                                                                                                                                                                                                       | -                                                                     | -                    | -                                     |
| iptags (single item) | string         | -                                                                                                                                                                                                                                                                                                                                                                              | -                                                                     | -                    | -                                     |
| fc                   | string         | Field changes - JSON string containing an array of field change objects. Each object has fieldName, previousValue, and currentValue. Present for CREATED and UPDATED operations. See FieldChange schema for structure.                                                                                                                                                         | -                                                                     | -                    | -                                     |
| cv                   | string         | Current version - JSON string containing the full entity state after the change. The structure depends on the ety field. Null for DELETED operations. See entity schemas (AssetEntity, PersonEntity, etc.).                                                                                                                                                                    | -                                                                     | -                    | -                                     |
| pv                   | string         | Previous version - JSON string containing the full entity state before the change. The structure depends on the ety field. Null for CREATED and REFRESH operations. See entity schemas (AssetEntity, PersonEntity, etc.).                                                                                                                                                      | -                                                                     | -                    | -                                     |

> Examples of payload *(generated)*

```json theme={null}
{
  "et": "2019-08-24T14:15:22Z",
  "un": "string",
  "cid": "string",
  "eid": "string",
  "en": "string",
  "ety": "Asset",
  "ddo": "CREATED",
  "ipids": [
    "string"
  ],
  "iptags": [
    "string"
  ],
  "fc": "string",
  "cv": "string",
  "pv": "string"
}
```

## Download AsyncAPI Specification

<a href="./domain-events.json" download="domain-events.json">
  Domain Events AsyncAPI Specification
</a>
