Message: asset.applyCommands
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
commands | array of command An array of [Asset commands](/resources/custom/actors/asset/commands/) to be applied. If any command fails, the asset will not be updated and the message will fail. |
Response Type
stringRelated Rule Hooks
During an applyCommands message, the following rule hook is run:
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**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/custom/asset/{assetId}",
"resources/actors/custom/asset/vendor/{assetNumber}",
"resources/actors/custom/asset/vendor/{externalReference}"
],
"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.