Skip to content

Message: asset.applyCommands

Back to Index

Applies a list of Asset commands to a given ASSET ID. Commands are batch processed, which means that if one command fails, the entire message fails.

Schema

Body
commandsarray of command

An array of Asset commands to be applied. If any command fails, the asset will not be updated and the message will fail.

Response Type string

During an applyCommands message, the following rule hook is run:

  1. OnAssetCommands

Example: Add an Item and a Relation to an Asset

Add an Item and a Relation to an Asset

This example will create an item and a relation on an Asset.

First, send a request to the correct ASSET ID.

Request

POST https://<hantera-hostname>/resources/actors/asset/<ASSET ID>
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[{
"type": "applyCommands",
"body": {
"commands": [
{
"type": "createItem",
"itemTypeKey": "localVendor",
"dynamic": {
"distance": "close"
}
},
{
"type": "createRelation",
"relation": "order",
"nodeId": <NODE ID>
}
]
}
}]

Response

HTTP/1.1 200 OK
---
{
"paths": [
"resources/actors/asset/<ASSET ID>",
"resources/actors/asset/vendor/<ASSET NUMBER>",
"resources/actors/asset/vendor/<EXTERNAL REFERENCE>"
],
"data": {
"applyCommands": "OK"
}
}

Ensure you enter the correct id to avoid getting a NOT_FOUND error. You will also get an INVALID_COMMAND response if you don’t send a properly formed request body.

Back to Index