API

Common

Getting Started

User

Register New User
Login
Logout
Refresh Access Token
Get User Profile
Update Profile
Upload Avatar
Delete User
Reset Password
Reset Password by ID

User Token

List User Tokens
Add User Token
Update Default User Token
Delete User Token
Verify User Token
Reset Verification Code

User vAtom

Get vAtom
Get vAtoms by Ids
Get vAtom Inventory
Search vAtoms
Geo Discover Groups
Geo Discover vAtoms
Update vAtoms
Perform Action
Trash vAtom

User Activity

Get My Threads
Get My Thread Messages

Template

List Templates
Get Template
Create Template
Update Template
Delete Template

Template Variation

List Variations
Get Variation
Create Variation
Update Variation
Delete Variation

vAtom

Emit vAtom

Template Action

List Actions
Get Action
Register Action Handler
Register Action
Update Action
Delete Action

Template Face

List Faces
Register Face
Update Face
Delete Face

Asset

Upload Assets
Get Assets
Delete Assets

Register Action

POST
https://api.blockv.io/v1/publisher/action

Overview

Actions are registered and configured per-template to allow for interaction with vAtoms and user-triggered behavior.

Although templates are immutable once published (meaning they cannot be changed), actions for a given template can be added, modified, or removed even after the template is published.

All vAtoms that are created based on a given template will have the template's actions available.

Register Action Request

HTTP Headers

Content-Type: application/json App-Id: {app_id}

Payload Details

NameTypeDescription
name * stringName of the action, has to be of the form publisher_fqdn::Template_Name::v1::Action::Action_Name
reactor * stringName of the reactor that is executed.
waitbooleanFlag to define if the action should be executed synchronously ( true ) or not ( false ). Default false .
rollbackbooleanNot yet implemented
abort_on_pre_errorbooleanDefines if the action should abort if an error occurs while executing the pre policies.
abort_on_post_errorbooleanDefines if the action should abort if an error occurs while executing the post policies.
abort_on_main_errorbooleanDefines if the action should abort if an error occurs while executing the main reactor.
timeout * integerMax. execution time in milliseconds (has to be > 0).
guest_userbooleanDefines if users that are not activated (don't have a verified email of phone) are allowed to use the action. Default false .
state_impactarrayNot yet implemented
policyobjectPre and Post reactors that can execute additional logic before or after the main reactor is executed.
configobjectGeneric action configuration.
paramsobjectInput and output parameters.
limit_per_userintegerHow many times a user can call this action. 0 means no limit.
action_notificationobjectNotification configuration that is applied when the action is executed.

Reactor object

When considering the behaviors of a vatom, registered actions specify the "interface" for the behavior, such as the action name. Reactors are the code that actually implements the implementation of the action.

Built-In Actions

The BLOCKv platform includes some built-in reactors for commonly-registered actions:

Transfer

Allows a user who owns a specific vAtom to transfer ownership of that vAtom to another user.

Clone

Clones the vAtom and sends the copy to another user. The cloning parameters are defined in the template variation.

Drop

Drops a vAtom on the map. The user who dropped the vAtom is still considered the owner until somebody else picks it up (by calling the Pickup action).

Pickup

Picks up a vAtom that was previously dropped on the map. After calling this action, the vAtom changes ownership to whomever called the action and is no longer available on the map.

Acquire

Acquires a vAtom from a publisher. The difference between this action and the Transfer action is in who initiates the transfer of ownership.

The Transfer action must be called by the current owner of the vAtom, whereas the Acquire action can be called by any other user to effectively "take" the vAtom from the publisher (but only if the publisher signals that they would like this kind of behavior, by having the Acquire action registered).

As an example, the Acquire can be used to allow a user to take a picture of a billboard with a QR code on it containing a vAtom id, and call the Acquire action with this id as a parameter to move the vAtom into their own inventory.

AcquirePubVariation

Acquires a vAtom of the same template variation as a given vAtom from a publisher. The difference between this action and the Acquire action is that it can transfer an existing vAtom (not necessarily the one with the given vAtom ID) or create a new one (if there are no vAtoms fulfilling the conditions and AutoCreateOnAcquire is set in the template variation).

Redeem

Allows a user who owns a specific vAtom to redeem it, i.e. replace it for another vAtom(s) and/or goods according to the rules set by the publisher.

Discover

Discovers vAtoms, faces and actions associated with a Discover Container (vAtom::vAtomType::DiscoverContainerType) vAtom owned by the requester. It uses the discover query of the vAtom to dynamically get a list of child vAtoms.

Activate

Activates (i.e. unpacks) a package owned by the requester. The Activate action moves all vAtoms contained in the container vAtom out of it and trashes the container.

Policy object

NameTypeDescription
[ pre ]arrayList of policies that are executed before the main action.
[ post ]arrayList of policies that are executed after the main action.
rulestringNot yet implemented
Policy rule object
NameTypeDescription
action_handlerstringName of the action handler that is executed.
rulestringNot yet implemented

Config object

The config object is a generic JSON object, which allows the action publisher to define additional configuration parameters that can be read by the registered reactor during execution. Please see the Examples section of this document for information on what this section should look like for the built-in actions detailed above.

Params object

The params object documents the input and output parameters of an action. This object is returned as part of the response payload when a list of actions for a template is requested.

The fields input and output contain an array of strings which represent parameters and response values of the action. All listed parameters are required. If the user should be required to specify one of many parameters, but only one is required and the rest are optional, then they can be represented as a single string with the parameter names separated by a | character.

Action notification object

NameTypeDescription
onbooleanSet to true to send a message when the action is executed.
msgstringThe message content that is sent.
customobjectKey, value object with additional configuration parameters.

Return & Error Codes

ErrorTypeDescription
200httpEverything is OK
400httpBad Request
403httpNot Authorized

Examples

Sample Request: Register Transfer Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Transfer",
    "reactor": "blockv://v1/Transfer",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id", "new.owner.email|new.owner.phone_number|new.owner.id"],
        "output":["v1::Error"]
    },
    "config": {
        "auto_create_landing_page": "http://viewer.blockv.io/#",
        "auto_create_mode": "claim",
        "auto_create_non_existing_recipient": true
    },
    "action_notification": {
        "on": true,
        "msg": "You received a vAtom",
        "custom": {}
    }
}

Sample Request: Register Clone Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Clone",
    "reactor": "blockv://v1/Clone",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id", "new.owner.email|new.owner.phone_number|new.owner.id"],
        "output":["v1::Error"]
    },
    "config": {
        "auto_create_landing_page": "http://viewer.blockv.io/#",
        "auto_create_mode": "claim",
        "auto_create_non_existing_recipient": true
    },
    "action_notification": {
        "on": true,
        "msg": "You received a vAtom",
        "custom": {}
    }
}

Sample Request: Register Drop Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Drop",
    "reactor": "blockv://v1/Drop",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id", "geo.pos"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {
        "on": false,
        "msg": "",
        "custom": {}
    }
}

Sample Request: Register Pickup Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Pickup",
    "reactor": "blockv://v1/Pickup",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {
        "on": false,
        "msg": "",
        "custom": {}
    }
}

Sample Request: Register Acquire Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Acquire",
    "reactor": "blockv://v1/AcquireWithCoins",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {}
}

Sample Request: Register AcquirePubVariation Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::AcquirePubVariation",
    "reactor": "blockv://v1/AcquirePubVariationWithCoins",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {}
}

Sample Request: Register Redeem Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Redeem",
    "reactor": "blockv://v1/Redeem",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id", "new.owner.email|new.owner.phone_number|new.owner.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {
        "on": true,
        "msg": "a vAtom has been redeemed",
        "custom": {}
    }
}

Sample Request: Register Discover Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Discover",
    "reactor": "blockv://v1/Discover",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {}
}

Sample Request: Register Activate Action

{
    "name": "publisher_fqdn::Template_Name::v1::Action::Activate",
    "reactor": "blockv://v1/PackageActivate",
    "wait": true,
    "rollback": false,
    "abort_on_pre_error": true,
    "abort_on_post_error": false,
    "abort_on_main_error": true,
    "timeout": 10000,
    "guest_user": true,
    "limit_per_user": 0,
    "params":{
        "input": ["this.id"],
        "output":["v1::Error"]
    },
    "config": {},
    "action_notification": {}
}

Register Action Response

Return & Error Codes

ErrorTypeDescription
200httpEverything is OK
400httpInvalid data
403httpNot Authorized
409httpAction already exists

Sample Response

{
    "payload": {
        "success_message": "Registered action: name=publisher_fqdn::Template_Name::v1::Action::Transfer"
    }
}
©2020 BLOCKv
Info