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/assetsQuery Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | number | 1 | Page number |
limit | number | 10 | Items per page |
name | string | — | Filter by name (case-insensitive) |
date | string | — | Filter by creation date (YYYY-MM-DD) |
groupId | string | — | Filter by group (24-character hex Object ID) |
projectId | string | — | Filter by project (24-character hex Object ID) |
attrName | string | — | Filter by attribute name (requires attrValue) |
attrValue | string | — | Filter 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | 24-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/jsonRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Asset name |
label | string | no | Display label |
description | string | no | Description |
owner | string | yes | User Object ID (24 hex) |
group | string | no | Asset group Object ID |
profile | string | no | Asset profile Object ID |
ruleChainId | string | no | Rule chain Object ID |
projectId | string | no | Project 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/jsonQuery Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | 24-character hex Object ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Asset name |
label | string | no | Display label |
description | string | no | Description |
owner | string | no | User Object ID |
group | string | — | Pass empty string to clear |
profile | string | — | Pass empty string to clear |
ruleChainId | string | — | Pass 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | 24-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