A fundamental concept in the EVRYTHNG Platform are actions. An action simply represents a discrete event or real-world actions performed by an app, user, or device within an brand-specific application, and usually created with a target product or a Thng to establish an association corresponding to the real world event. For example, an action created on a Thng could represent a 'shipped from warehouse' event when an item leaves a warehouse as part of its supply chain.
Each action has a type
associated, which allows categorisation of actions, similar to how Thngs can be categorised by their associated product. See the Action Types section for information on the built-in action types we provide, as well as how to create your own custom action types as required. These built-in action types cover some common scenarios including consumer scanning and factory commissioning.
In the real world, actions are usually created by an Application User within an application and a Thng, product, or collection ID is specified as the target. This identifies simultaneously what happened, who triggered it, for which purpose, and where it occurred, building a coherent picture of the item's journey through a supply chain.
In addition to specifying a resource in an action, it is also possible to create an action through the resource itself using aliased actions.
Action Context
When reading actions, the ?context=true
query parameter can be used to include the context
field in the response. This includes useful contextual information about the creation of the action. See the ActionContextDocument Data Model section for more information.
API Status
General Availability:
/actions/:type
/actions/:type/:actionId
/products/:productId/actions/:actionType
/thngs/:thngId/actions/:actionType
/collections/:collectionId/actions/:actionType
ActionDocument Data Model
Create an action
Read an Action
Read an Action with Context
Read all actions of a type
Delete an action
Create Multiple Actions
Aliased Actions
ActionDocument Data Model
.type (string, required)
The action type.
.id (string, read-only)
The ID of this resource.
.user (string, read-only)
The EVRYTHNG ID of the user who has performed this action.
.createdAt (integer, read-only)
Timestamp when the resource was created.
.createdByProject (string, read-only)
The EVRYTHNG ID of the project who has performed this
action.
.createdByApp (string, read-only)
The EVRYTHNG ID of the application who has performed this
action.
.thng (string)
The EVRYTHNG ID of the Thng this action was carried out on.
.product (string)
The EVRYTHNG product ID associated with the Thng this action
was carried out on.
.collection (string)
The EVRYTHNG ID of the collection this action was carried
out on. Custom action types only.
.timestamp (integer, read-only)
The timestamp when the action took place. Filled
automatically if unspecified.
.identifiers (IdentifiersDocument)
Various identifiers (EPC, GTIN, etc.) as a JSON object with
one or more key-value pairs.
.location (LocationDocument)
An object representing a location. Either 'position' or
'place' us required.
.locationSource (string, one of 'sensor', 'geoIp', 'unknown', 'place')
The method used to find the location where the action took
place, and requires `location` to also be set. If a GPS was
used (with user permission granted), `sensor` is specified.
Otherwise an estimate is made based on the apparent
location, which may not be the device itself.
.context (ActionContextDocument)
Object containing contextual data about the action creator.
.customFields (CustomFieldsDocument)
Object of case-sensititve key-value pairs of custom fields
associated with the resource.
.scopes (ScopesDocument)
Project and user scopes arrays.
.tags (array of string)
Array of string tags associated with this resource.
.reactions (array of ReactionDocument)
An array of Redirector reactions that occured from this
action.
{
"additionalProperties": false,
"type": "object",
"description": "An object representing a Platform action.",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"description": "The action type."
},
"id": {
"type": "string",
"description": "The ID of this resource.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$",
"readOnly": true
},
"user": {
"type": "string",
"description": "The EVRYTHNG ID of the user who has performed this action.",
"readOnly": true,
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"createdAt": {
"type": "integer",
"description": "Timestamp when the resource was created.",
"readOnly": true,
"minimum": 0
},
"createdByProject": {
"type": "string",
"description": "The EVRYTHNG ID of the project who has performed this action.",
"readOnly": true,
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"createdByApp": {
"type": "string",
"description": "The EVRYTHNG ID of the application who has performed this action.",
"readOnly": true,
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"thng": {
"type": "string",
"description": "The EVRYTHNG ID of the Thng this action was carried out on.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"product": {
"type": "string",
"description": "The EVRYTHNG product ID associated with the Thng this action was carried out on.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"collection": {
"type": "string",
"description": "The EVRYTHNG ID of the collection this action was carried out on. Custom action types only.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"timestamp": {
"type": "integer",
"description": "The timestamp when the action took place. Filled automatically if unspecified.",
"readOnly": true,
"minimum": 0
},
"identifiers": {
"type": "object",
"description": "Various identifiers (EPC, GTIN, etc.) as a JSON object with one or more key-value pairs."
},
"location": {
"additionalProperties": false,
"type": "object",
"description": "An object representing a location. Either 'position' or 'place' us required.",
"properties": {
"position": {
"type": "object",
"description": "A GeoJSON Point object. The coordinate order is longitude, then latitude.",
"required": ["type", "coordinates"],
"properties": {
"type": {
"type": "string",
"description": "The type of the point.",
"enum": ["Point"]
},
"coordinates": {
"type": "array",
"description": "The point coordinates",
"items": {
"type": "number",
"minimum": -180,
"maximum": 180
}
}
}
},
"createdAt": {
"type": "integer",
"description": "Timestamp when the resource was created.",
"readOnly": true,
"minimum": 0
},
"timestamp": {
"type": "integer",
"description": "The time the location update occurred, or filled automatically by the Platform if omitted.",
"readOnly": true
},
"longitude": {
"type": "number",
"description": "The longitude."
},
"latitude": {
"type": "number",
"description": "The latitude."
},
"place": {
"type": "string",
"description": "The place ID.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$"
},
"scopes": {
"additionalProperties": false,
"type": "object",
"description": "Project and user scopes arrays.",
"required": ["users", "projects"],
"properties": {
"users": {
"type": "array",
"description": "An array of Application User IDs this resource is scoped to.",
"items": { "type": "string" }
},
"projects": {
"type": "array",
"description": "An array of project IDs this resource is scoped to.",
"items": {
"type": "string",
"description": "The ID of this resource.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$",
"readOnly": true
}
}
}
}
},
"x-filterable-fields": ["timestamp"]
},
"locationSource": {
"type": "string",
"description": "The method used to find the location where the action took place, and requires `location` to also be set. If a GPS was used (with user permission granted), `sensor` is specified. Otherwise an estimate is made based on the apparent location, which may not be the device itself.",
"enum": ["sensor", "geoIp", "unknown", "place"]
},
"context": {
"additionalProperties": false,
"type": "object",
"description": "Object containing contextual data about the action creator.",
"properties": {
"ipAddress": {
"type": "string",
"description": "The geolocation IP address of the action.",
"readOnly": true
},
"city": {
"type": "string",
"description": "The geolocation city of the action, based on the IP address.",
"readOnly": true
},
"region": {
"type": "string",
"description": "The wider region of the action.",
"readOnly": true
},
"countryCode": {
"type": "string",
"description": "The country of the action.",
"readOnly": true
},
"userAgentName": {
"type": "string",
"description": "The user agent name of the action creator's browser or other client.",
"readOnly": true
},
"userAgent": {
"type": "string",
"description": "The user agent of the action creator's browser or other client.",
"readOnly": true
},
"operatingSystemName": {
"type": "string",
"description": "Name of the action creator's client operating system.",
"readOnly": true
},
"timeZone": {
"type": "string",
"description": "The timezone string, such as Europe/Paris",
"readOnly": true
}
}
},
"customFields": {
"type": "object",
"description": "Object of case-sensititve key-value pairs of custom fields associated with the resource."
},
"scopes": {
"additionalProperties": false,
"type": "object",
"description": "Project and user scopes arrays.",
"required": ["users", "projects"],
"properties": {
"users": {
"type": "array",
"description": "An array of Application User IDs this resource is scoped to.",
"items": { "type": "string" }
},
"projects": {
"type": "array",
"description": "An array of project IDs this resource is scoped to.",
"items": {
"type": "string",
"description": "The ID of this resource.",
"pattern": "^[abcdefghkmnpqrstwxyABCDEFGHKMNPQRSTUVWXY0123456789]{24}$",
"readOnly": true
}
}
}
},
"tags": {
"type": "array",
"description": "Array of string tags associated with this resource.",
"items": {
"type": "string",
"maxLength": 60
}
},
"reactions": {
"type": "array",
"description": "An array of Redirector reactions that occured from this action.",
"items": {
"additionalProperties": false,
"type": "object",
"description": "A single reaction from Redirector.",
"properties": {
"type": {
"type": "string",
"description": "The reaction type.",
"enum": ["redirection"],
"readOnly": true
},
"redirectUrl": {
"type": "string",
"description": "The redirection URL.",
"readOnly": true
},
"redirectionContext": {
"type": "object",
"description": "Object of redirection context values.",
"readOnly": true
}
}
}
}
},
"x-filterable-fields": ["timestamp", "identifiers.<key>", "tags", "type", "user", "context.city", "context.countryCode", "thng", "product", "collection"]
}
{
"id": "U4aPKKSEWy9nQQRaaghRasaa",
"createdAt": 1510914839892,
"customFields": {
"region_code": "en_gb"
},
"tags": [
"example",
"actions"
],
"timestamp": 1510914839892,
"type": "scans",
"user": "UnRPKGnUMQtVEPaaageq5ehk",
"location": {
"latitude": 51.4333,
"longitude": 0.1833,
"position": {
"type": "Point",
"coordinates": [
0.1833,
51.4333
]
}
},
"locationSource": "geoIp",
"context": {
"city": "Crayford",
"region": "England",
"countryCode": "GB",
"userAgentName": "Unknown",
"operatingSystemName": "Unknown",
"timeZone": "Europe/London"
},
"reactions": [
{
"type": "redirection",
"redirectUrl": "https://google.com",
"redirectionContext": {
"constants": {
"region_code": "en_gb"
}
}
}
],
"createdByProject": "UmxHK6K8BXsa9KawRh4bTbqc",
"createdByApp": "U3pxRQh2eD8RtKwaRgerfQgc",
"identifiers": {
"ean_13": "786432786349"
},
"thng": "U4wpchcBqm8hhqwwag8kgnqc"
}
See also: LocationDocument
, ScopesDocument
, ReactionDocument
, ActionContextDocument
Filterable Fields
This resource type can be filtered using the following fields and operators.
Field | Type | Operators |
---|---|---|
timestamp | Number | > , < |
identifiers.<key> | String | = |
tags | List of string | = |
type | String | = |
user | String | = |
context.city | String | = |
context.countryCode | String | = |
thng | String | = |
product | String | = |
collection | String | = |
ActionContextDocument Data Model
.ipAddress (string, read-only)
The geolocation IP address of the action.
.city (string, read-only)
The geolocation city of the action, based on the IP address.
.region (string, read-only)
The wider region of the action.
.countryCode (string, read-only)
The country of the action.
.userAgentName (string, read-only)
The user agent name of the action creator's browser or other
client.
.userAgent (string, read-only)
The user agent of the action creator's browser or other
client.
.operatingSystemName (string, read-only)
Name of the action creator's client operating system.
.timeZone (string, read-only)
The timezone string, such as Europe/Paris
{
"additionalProperties": false,
"type": "object",
"description": "Object containing contextual data about the action creator.",
"properties": {
"ipAddress": {
"type": "string",
"description": "The geolocation IP address of the action.",
"readOnly": true
},
"city": {
"type": "string",
"description": "The geolocation city of the action, based on the IP address.",
"readOnly": true
},
"region": {
"type": "string",
"description": "The wider region of the action.",
"readOnly": true
},
"countryCode": {
"type": "string",
"description": "The country of the action.",
"readOnly": true
},
"userAgentName": {
"type": "string",
"description": "The user agent name of the action creator's browser or other client.",
"readOnly": true
},
"userAgent": {
"type": "string",
"description": "The user agent of the action creator's browser or other client.",
"readOnly": true
},
"operatingSystemName": {
"type": "string",
"description": "Name of the action creator's client operating system.",
"readOnly": true
},
"timeZone": {
"type": "string",
"description": "The timezone string, such as Europe/Paris",
"readOnly": true
}
}
}
ReactionDocument Data Model
.type (string, read-only, one of 'redirection')
The reaction type.
.redirectUrl (string, read-only)
The redirection URL.
.redirectionContext (object, read-only)
Object of redirection context values.
{
"type": "object",
"description": "A single reaction from Redirector.",
"properties": {
"type": {
"type": "string",
"description": "The reaction type.",
"enum": [ "redirection" ],
"readOnly": true
},
"redirectUrl": {
"type": "string",
"description": "The redirection URL.",
"readOnly": true
},
"redirectionContext": {
"type": "object",
"description": "Object of redirection context values.",
"readOnly": true
}
}
}
Create an Action
Create a new action of the specified type
.
Notes
all
can be used astype
. In this case, the actiontype
must be supplied in the payload.When using
/actions/all
with a custom action type, the payload can contain only thetype
, and does not require a targetthng
,product
, orcollection
.
POST /actions/:type
Content-Type: application/json
Authorization: $APP_USER_API_KEY
ActionDocument
curl -i -H "Content-Type: application/json" \
-H "Authorization: $APP_USER_API_KEY" \
-X POST "https://api.evrythng.com/actions/scans" \
-d '{
"product": "UmAkSdqe69QVhswwRYNdbxna",
"type": "_Imported",
"identifiers": {
"sapId": "KDL-46EX402AEP",
"event_Id": "027242784925"
}
}'
const actionType = '_Imported';
const productId = 'UmAkSdqe69QVhswwRYNdbxna';
const payload = {
type: actionType,
product: productId,
identifiers: {
sapId: "KDL-46EX402AEP",
event_Id: "027242784925",
},
};
app.action(actionType).create(payload)
.then(console.log);
// with the nested resources
app.product(productId).action(actionType)
.create(payload)
.then(console.log);
String productId = "UmAkSdqe69QVhswwRYNdbxna";
ScanAction action = new ScanAction();
action.setProduct(productId); // Could also be a product or shortId
apiManager.actionService().actionCreator(action).execute();
HTTP/1.1 201 Created
Content-Type: application/json
Location: https://api.evrythng.com/actions/scans/UGByEXMEq9QBE8aRaYNeYnkb
{
"id": "UGByEXMEq9QBE8aRaYNeYnkb",
"createdAt": 1497528007035,
"timestamp": 1497528007035,
"type": "_Imported",
"user": "UmAFxMDnqQ9VEsRwaErAxfrr",
"identifiers": {
"sapId": "KDL-46EX402AEP",
"event_Id": "027242784925"
},
"location": {
"latitude": 48.86,
"longitude": 2.34,
"position": {
"type": "Point",
"coordinates": [
2.34,
48.86
]
}
},
"locationSource": "unknown",
"createdByProject": "UGdkbcyhqQtVEsaaRhrASatf",
"createdByApp": "UmAFxcdSMt9VE8awRE7dba9n",
"product": "UmAkSdqe69QVhswwRYNdbxna"
}
Read an Action
Application Users and Operators can read an action by its ID. Both the Application User and Operator API keys can be used. You can use all
as the action type to access the actions of unknown type.
GET /actions/:actionType/:actionId
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X GET 'https://api.evrythng.com/actions/_Imported/Uh7HKqtFryhmBaShGHVySmeg'
const productId = 'UhrHD9BnngymSrapaakKrq9g';
const actionId = 'UGByEXMEq9QBE8aRaYNeYnkb';
const actionType = '_Imported';
// Read a user's specific 'scan' action
user.action(actionType, actionId).read()
.then(console.log);
// Read user product's specific scan action
user.product(productId).action(actionType, actionId)
.read()
.then(console.log);
// Read a user's specific actions (regardless of type)
user.action('all').read()
.then(console.log);
String actionId = "UGByEXMEq9QBE8aRaYNeYnkb";
// The class parameter should match the class of the action being read
// For example, ScanAction.class for the 'scan' action type
ScanAction action = apiManager.actionService().actionReader(ScanAction.class, actionId).execute();
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "Uh7HKqtFryhmBaShGHVySmeg",
"createdAt": 1473953016966,
"timestamp": 1473953016966,
"type": "_Imported",
"identifiers": {
"sapId": "KDL-46EX402AEP",
"event_Id": "027242784925"
},
"location": {
"latitude": 51.5142,
"longitude": -0.0931,
"position": {
"type": "Point",
"coordinates": [
-0.0931,
51.5142
]
}
},
"locationSource": "geoIp",
"thng": "Uh74neTHnDcmbNwpaRmUhEht",
"product": "UhrHD9BnngymSrapaakKrq9g"
}
Read all Actions of a Type
Read all actions of a given type
. For example: GET /actions/scans
for all the scans
actions. The result may be paginated if there are more than 30 items.
A special type all
can be used to get all actions regardless of their type.
See Action Types to see how to read and manage action types.
GET /actions/:type
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X GET 'https://api.evrythng.com/actions/_Imported'
const actionType = '_Imported';
const productId = 'UGTdRHP4BDsa95waRhqfYhTh';
// Read user's product's most recent scans:
const params = {
filter: { product: productId },
};
user.action(actionType).read({ params })
.then(console.log);
// Above, simplified
user.product(productId).action(actionType)
.read()
.then(console.log);
// Read user's most recent scans:
user.action(actionType).read()
.then(console.log);
// Read all recent actions in this app:
user.action('all').read()
.then(console.log);
Iterator<PVector<Action>> actions = apiManager.actionService().iterator().perPage(10).filter("type=_Imported").execute();
while(actions.hasNext()) {
PVector<Action> page = actions.next();
for(Action action : page) {
System.out.println("action: " + action.toString());
}
}
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "UmBSBbDBBg8atKaRwXFBDwct",
"createdAt": 1497448804712,
"timestamp": 1497448804712,
"type": "_Imported",
"user": "UGBxVbDeVXsRt5aRwhQTngep",
"identifiers": {
"sapId": "KDL-46EX402AEP",
"event_Id": "027242784925"
},
"location": {
"latitude": 39.02,
"longitude": 125.75,
"position": {
"type": "Point",
"coordinates": [
125.75,
39.02
]
}
},
"locationSource": "unknown",
"createdByProject": "UmSqCDt5BD8atKRRagdqUnAa",
"createdByApp": "UGxqWERBBgsatKwRwgG9Kfcb",
"product": "UGTdRHP4BDsa95waRhqfYhTh"
}
]
Read an Action with Context
The ?context=true
query parameter can be used to include the context
field in the action read.
GET /actions/:actionType/:actionId?context=true
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X GET 'https://api.evrythng.com/actions/_Imported/UkqgkMW5egsatKawRYbywqeb?context=true'
const actionType = '_Imported';
const actionId = 'UkqgkMW5egsatKawRYbywqeb';
const params = { context: true };
user.action(actionType, actionId)
.read({ params })
.then(console.log);
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "UkqgkMW5egsatKawRYbywqeb",
"createdAt": 1489407066926,
"timestamp": 1489407066926,
"type": "_Imported",
"user": "Ukqg2MbseDPwtKwwaYE6QfRs",
"identifiers": {
"sapId": "KDL-46EX402AEP",
"event_Id": "027242784925"
},
"location": {
"latitude": 57.75,
"longitude": -0.9133,
"position": {
"type": "Point",
"coordinates": [
-0.9133,
57.75
]
}
},
"locationSource": "geoIp",
"context": {
"city": "Dartford",
"region": "England",
"countryCode": "GB",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
"timeZone": "Europe/London"
},
"createdByProject": "UF5hQHxMBg8a9pwwRYxqXkqp",
"createdByApp": "UkMgYtdEVDsaQKaRwgdAWsdn",
"thng": "Uk6XkAPbBXPwtKwawDAepMmm",
"product": "UFKE9nHBBg8atKaawgVrKKbs"
}
Delete an Action
Delete a single action by ID.
DELETE /actions/:type/:actionId
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X DELETE 'https://api.evrythng.com/actions/_Imported/UE9Akx9WaMQwgWdpMYAGUr9p'
const actionType = '_Imported';
const actionId = 'UE9Akx9WaMQwgWdpMYAGUr9p';
operator.action(actionType, actionId).delete();
String actionId = "UE9Akx9WaMQwgWdpMYAGUr9p";
// The class should match the type of action to be deleted
// For example, ScanAction.class for the 'scan' action type
apiManager.actionService().actionDeleter(ScanAction.class, actionId).execute();
HTTP/1.1 200 OK
Create Multiple Actions
It is possible to create multiple actions at the same time using the /actions/all
endpoint. Each action in the payload array must state the action type
. Different types can be used at the same time for different actions.
POST /actions/all
Authorization: $OPERATOR_API_KEY
Content-Type: application/json
[ ActionDocument, ... ]
curl -H "Content-Type: application/json" \
-H "Authorization: $OPERATOR_API_KEY" \
-X POST 'https://api.evrythng.com/actions/all' \
-d '[
{
"type": "scans",
"thng": "Um2MEbqHMm8Eh6aaaDBSQkHm"
},
{
"type": "_Imported",
"thng": "Um2MEbqHMm8Eh6aaaDBSQkHm"
}
]'
const payload = {
type: 'scans',
thng: 'UmCygXyDeXsw9KwwRhnnGg2a'
}, {
type: '_Imported',
thng: 'UmCygXyDeXsw9KwwRhnnGg2a'
};
operator.action('all').create(payload)
.then(console.log);
HTTP/1.1 201 Created
Content-Type: application/json
[
{
"id": "UmpbCgWRMGsEEqRRwgYEbtEs",
"createdAt": 1504794192742,
"timestamp": 1504794192742,
"type": "scans",
"location": {
"latitude": 51.45,
"longitude": 0.2167,
"position": {
"type": "Point",
"coordinates": [
0.2167,
51.45
]
}
},
"locationSource": "geoIp",
"context": {
"city": "Dartford",
"region": "England",
"countryCode": "GB",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
"timeZone": "Europe/London"
},
"thng": "Um2MEbqHMm8Eh6aaaDBSQkHm",
"product": "U3EtU2k3BD8wQpwwR6EMXgKb"
},
{
"id": "U3KbCgfRMmPhh6wwagYYbtka",
"createdAt": 1504794192756,
"timestamp": 1504794192756,
"type": "_Imported",
"location": {
"latitude": 51.45,
"longitude": 0.2167,
"position": {
"type": "Point",
"coordinates": [
0.2167,
51.45
]
}
},
"locationSource": "geoIp",
"context": {
"city": "Dartford",
"region": "England",
"countryCode": "GB",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
"timeZone": "Europe/London"
},
"thng": "Um2MEbqHMm8Eh6aaaDBSQkHm",
"product": "U3EtU2k3BD8wQpwwR6EMXgKb"
}
]
Aliased Actions
It is also possible to use alias endpoints to create or read actions performed on a specific Thng, product or collection using its ID. The available endpoints are:
/products/:productId/actions/:actionType
- Actions on a specific product/thngs/:thngId/actions/:actionType
- Actions on a specific Thng/collections/:collectionId/actions/:actionType
- Actions on a specific collection
Use the same payload as for /actions/:actionType
endpoint. The action's product
, thng
, or collection
property must match the ID that is specified in the URL, or in this special case may be omitted from the payload. The responses are of the same format as the Read all actions of a type operation.
Note
Only custom action types can be used for aliased actions.
Create an Aliased Action
The examples below show aliased action creation on a product, but are also applicable for Thngs and collections in the same /:type/:id/actions/:actionType
pattern.
POST /products/:productId/actions/:actionType
Content-Type: application/json
Authorization: $OPERATOR_API_KEY
ActionDocument
curl -H "Content-Type: application/json" \
-H "Authorization: $OPERATOR_API_KEY" \
-X POST 'https://api.evrythng.com/products/Uk7KFKGKBXPwQKawwDYF9bPr/actions/_Imported' \
-d '{
"type": "_Imported",
"product": "Uk7KFKGKBXPwQKawwDYF9bPr"
}'
const productId = 'Uk7KFKGKBXPwQKawwDYF9bPr';
const actionType = '_Imported';
const payload = {
product: productId,
type: actionType,
};
user.product(productId).action(actionType)
.create(payload)
.then(console.log);
Read all Aliased Actions on a Resource
GET /products/:productId/actions/:actionType
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X GET 'https://api.evrythng.com/products/Uk7KFKGKBXPwQKawwDYF9bPr/actions/_Imported'
const productId = 'Uk7KFKGKBXPwQKawwDYF9bPr';
const actionType = '_Imported';
user.product(productId).action(actionType)
.read()
.then(console.log);
Read an Aliased Action
GET /products/:productId/actions/:actionType/:actionId
Authorization: $OPERATOR_API_KEY
curl -H "Authorization: $OPERATOR_API_KEY" \
-X GET 'https://api.evrythng.com/products/Uk7KFKGKBXPwQKawwDYF9bPr/actions/_Imported/UHr9xPR8qG8YhMaawEPcbh4p'
const productId = 'Uk7KFKGKBXPwQKawwDYF9bPr';
const actionType = '_Imported';
const actionId = 'UHr9xPR8qG8YhMaawEPcbh4p';
user.product(productId).action(actionType, actionId)
.read()
.then(console.log);