Skip to content

Asset Actor Messages

An Asset message is a method applied to an existing instance of an Asset. These are the available Asset messages:

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.

create

Creates a new instance of an asset actor.

You must specify an asset type. If not, you'll get an INVALID_MESSAGE_BODY error.

delete

Deletes the asset

query

Queries the asset from the graph.

Send Asset message requests using /resources/actors/asset/<asset_id>, where <asset_id> is new when creating a new instance.

Aside from the delete message, each time you send a message, the Asset returns all of its access URIs. They include:

  • Default GUID
  • Asset Number
  • External Reference, if specified.

Therefore, you can also message an Asset with assetNumber or externalReference by including the assetType in the URL like so: /resources/actors/asset/<ASSET TYPE>/<ASSET NUMBER OR EXTERNAL REFERENCE>.

Additionally, you can send multiple messages in one request or test them in preview mode.

A general template for Asset messages is:

POST https://<hantera-hostname>/resources/actors/asset/<ASSET ID>
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[{
"type": <MESSAGE TYPE>,
"body": {
}
}]

Example: Create a new Vendor and add a localVendor item

Create a new Vendor and add a localVendor item

In this example, we will apply multiple messages at once to an Asset instance. We will create a Vendor Asset and immediately add a localVendor item to it.

Request

POST https://<hantera-hostname>/resources/actors/asset/new
Authorization: Bearer <YOUR TOKEN>
Content-Type: application/json
[
{
"type": "create",
"body": {
"typeKey": "vendor",
"externalReference": "vendor100"
}
},
{
"type": "applyCommands",
"body": {
"commands": [
{
"type": "createItem",
"itemTypeKey": "localVendor",
"dynamic": {
"distance": "close"
}
}
]
}
}
]

Response

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