Event service

Event service is by setting a threshold for the stream of the channel, make the notification to the email or an external system. Before Event service use, please make sure that the stream to the channel is stored.

API Sandbox

List all event(s)

List event(s) of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

Response Body:

Elements Type Descritption
event_id number event_id
mapped_ch number event related channel-Id
description string description of event
notify_type string notification method("email"or"http")
post_url string Webhook URI
enabled boolean event status
source string target payload of channel // eg1.{"temp":25} → temp eg2.{"data":[{"value" : 10}]} →data:value
operator string "<" : IF source < threshold ">" : IF source > threshold "<=" : IF source <= threshold ">=" : IF source >= threshold "=" : IF source = threshold "!=" : IF source != threshold
threshold string threshold value

GET https://m.thingscale.io/v2/event/{event_id}

Parameters: event_id (Integer)

Sample payload:

[
  {
    "event_id": 1,
    "mapped_ch": 0,
    "description": "CH0 Low TEMP",
    "notify_type": "email",
    "post_url": "",
    "enabled": true,
    "source": "temp",
    "operator": "<=",
    "threshold": "8"
  }
]
curl -X GET -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/event/EVENT_ID_HERE

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
401 Unauthorized {"error": "AUTH_REQUIRED"}
404 Not found {"error": "NO_EVENT"}

Create a new event

Create a event of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

Response Body:

Elements Type Descritption
event_id number CREATED_EVENT_ID

POST https://m.thingscale.io/v2/event/

Parameters: NONE

Sample payload:

 {"event_id" : CREATED_EVENT_ID}
curl -X POST -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/event

Response code:

HTTP status: Desc./Response body
201 Created Transaction OK.
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "MAX_EVENT_REACH" } // Per account event limit reached.

Update a event

Update a event of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

Request Body:

Elements Type Descritption
event_id number event_id
mapped_ch number event related channel-Id
description string description of event
notify_type string notification method("email"or"http")
post_url string Webhook URI
enabled boolean event status
source string target payload of channel // eg1.{"temp":25} → temp eg2.{"data":[{"value" : 10}]} →data:value
operator string "<" : IF source < threshold ">" : IF source > threshold "<=" : IF source <= threshold ">=" : IF source >= threshold "=" : IF source = threshold "!=" : IF source != threshold
threshold string threshold value

PUT https://m.thingscale.io/v2/event/{event_id}

Parameters: event_id (Integer)

Sample payload:

[
  {
    "event_id": 1,
    "mapped_ch": 0,
    "description": "CH0 Low TEMP",
    "notify_type": "email",
    "post_url": "",
    "enabled": true,
    "source": "temp",
    "operator": "<=",
    "threshold": "8"
  }
]
curl -X PUT -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/event/{event_id}

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
400 Bad Request { "error": "BAD_JSON_FORMAT" } // check json array.
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "NO_CHANNEL" } // Because channel_id is nothing
404 Not found { "error": "NO_EVENT" } // Specified event_id is not found.

Delete a event

Delete a event of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

DELETE https://m.thingscale.io/v2/event/{event_id}

Parameters: event_id (Integer)

curl -X DELETE -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/event/{event_id}

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "EVENT_ENABLE" } // Specified event status is true.
404 Not found { "error": "NO_EVENT" } // Specified event_id is not found.

results matching ""

    No results matching ""