Skip to content

Assets API

Manage IoT assets. Assets are stored in the iot_objects collection with obj_type: 'assets'.


List Assets

Retrieves a paginated list of assets with their attributes.

GET /api/assets

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber10Items per page
namestringFilter by name (case-insensitive)
datestringFilter by creation date (YYYY-MM-DD)
groupIdstringFilter by group (24-character hex Object ID)
projectIdstringFilter by project (24-character hex Object ID)
attrNamestringFilter by attribute name (requires attrValue)
attrValuestringFilter by attribute value (requires attrName)

Example

bash
curl -H "Authorization: Bearer <key>" \
  "http://localhost:9001/api/assets?page=1&limit=10"

Example (with attribute filter)

bash
curl -H "Authorization: Bearer <key>" \
  "http://localhost:9001/api/assets?attrName=wattage&attrValue=5000"

Returns only assets that have an attribute named wattage with value 5000.

Response

json
{
  "success": true,
  "data": [
    {
      "_id": "665a1b2c3d4e5f6a7b8c9d0e",
      "name": "Solar Panel Array",
      "label": "Rooftop A",
      "description": "Main solar array",
      "obj_type": "assets",
      "clientId": "664a1b2c3d4e5f6a7b8c9d0a",
      "owner": "664a1b2c3d4e5f6a7b8c9d0b",
      "group": null,
      "profile": null,
      "ruleChainId": null,
      "created_at": "2025-01-15T10:30:00.000Z",
      "updated_at": "2025-01-15T10:30:00.000Z",
      "attributes": [
        {
          "_id": "665a1b2c3d4e5f6a7b8c9d10",
          "name": "wattage",
          "type_data": "number",
          "value": "5000"
        }
      ]
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 10
}

Get Asset

Retrieves a single asset by ID, including its attributes and relations.

GET /api/assets?id=<asset_id>

Query Parameters

ParameterTypeRequiredDescription
idstringyes24-character hex Object ID

Example

bash
curl -H "Authorization: Bearer <key>" \
  "http://localhost:9001/api/assets?id=665a1b2c3d4e5f6a7b8c9d0e"

Response

json
{
  "success": true,
  "data": {
    "_id": "665a1b2c3d4e5f6a7b8c9d0e",
    "name": "Solar Panel Array",
    "label": "Rooftop A",
    "description": "Main solar array",
    "obj_type": "assets",
    "clientId": "664a1b2c3d4e5f6a7b8c9d0a",
    "owner": "664a1b2c3d4e5f6a7b8c9d0b",
    "created_at": "2025-01-15T10:30:00.000Z",
    "updated_at": "2025-01-15T10:30:00.000Z"
  },
  "attributes": [
    {
      "_id": "665a1b2c3d4e5f6a7b8c9d10",
      "name": "wattage",
      "type_data": "number",
      "value": "5000"
    }
  ],
  "relations": [
    {
      "_id": "665a1b2c3d4e5f6a7b8c9d20",
      "clientId": "664a1b2c3d4e5f6a7b8c9d0a",
      "fromType": "asset",
      "fromId": "665a1b2c3d4e5f6a7b8c9d0e",
      "fromName": "Solar Panel Array",
      "fromObjType": "assets",
      "direction": "child",
      "deviceId": "665a1b2c3d4e5f6a7b8c9d30",
      "deviceName": "Inverter-01",
      "deviceObjType": "devices",
      "created_at": "2025-01-15T10:30:00.000Z",
      "updated_at": "2025-01-15T10:30:00.000Z"
    }
  ]
}

Returns "data": null if the asset is not found. The attributes array contains all attributes linked to the asset from the iot_attributes collection. The relations array contains all relations involving the asset from the iot_relations collection, with resolved entity names (fromName, assetName, deviceName).


Create Asset

Creates a new asset.

POST /api/assets?id=new
Content-Type: application/json

Request Body

FieldTypeRequiredDescription
namestringyesAsset name
labelstringnoDisplay label
descriptionstringnoDescription
ownerstringyesUser Object ID (24 hex)
groupstringnoAsset group Object ID
profilestringnoAsset profile Object ID
ruleChainIdstringnoRule chain Object ID
projectIdstringnoProject Object ID

Example

bash
curl -X POST -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Solar Panel Array",
    "label": "Rooftop A",
    "description": "Main solar array",
    "owner": "664a1b2c3d4e5f6a7b8c9d0b"
  }' \
  "http://localhost:9001/api/assets?id=new"

Response

json
{
  "success": true
}

Update Asset

Updates an existing asset.

POST /api/assets?id=<asset_id>
Content-Type: application/json

Query Parameters

ParameterTypeRequiredDescription
idstringyes24-character hex Object ID

Request Body

FieldTypeRequiredDescription
namestringyesAsset name
labelstringnoDisplay label
descriptionstringnoDescription
ownerstringnoUser Object ID
groupstringPass empty string to clear
profilestringPass empty string to clear
ruleChainIdstringPass empty string to clear

Example

bash
curl -X POST -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Solar Panel Array v2",
    "label": "Rooftop B",
    "description": "Updated description",
    "owner": "664a1b2c3d4e5f6a7b8c9d0b"
  }' \
  "http://localhost:9001/api/assets?id=665a1b2c3d4e5f6a7b8c9d0e"

Response

json
{
  "success": true
}

Delete Asset

Deletes an asset and its associated attributes and relations.

DELETE /api/assets?id=<asset_id>

Query Parameters

ParameterTypeRequiredDescription
idstringyes24-character hex Object ID

Example

bash
curl -X DELETE -H "Authorization: Bearer <key>" \
  "http://localhost:9001/api/assets?id=665a1b2c3d4e5f6a7b8c9d0e"

Response

json
{
  "success": true
}

Cleanup

Deletion removes:

  • Asset document from iot_objects
  • All attributes linked to the asset from iot_attributes
  • All relations involving the asset from iot_relations