IoT Stadium

API Documentation

Automation

Automation - POST Add Automation Controller Trigger

Add the controller trigger for your automation

Post
{{url_iot_backend}}/ext/automations
{
	"key": "Content-Type",
	"value": "application/json"
},
{
	"key": "Authorization",
	"value": "Bearer {{token}}"
},

Parameter

Field Type Description
name String

Name for your controller trigger

automation_type String

The type of automation (trigger) or (schedule)

is_active Integer

Does your automation active(1) or not(0)

description String

The automation description

triggers Array

Conditions that trigger the automation

triggers[].device Integer

Device ID

triggers[].source String

use "controller"

triggers[].value[].telemetry_key String

Telemetry key to be evaluated

triggers[].value[].actuator_name String

Human-readable actuator name

triggers[].condition String

Operator condition (=)

triggers[].comparator String

Value to compare against

triggers[].relation String

Logical relation (e.g., "AND") if combining multiple triggers

actions Array

List of actions to execute if triggered

actions[].type String

Type of action: "controller", "alarm", "email", "api"

actions[].detail.controller.device Integer

Device ID to control

actions[].detail.controller.device_action_key String

Key for the action

actions[].detail.controller.device_action_value String

Value for the action "on" or "off"

actions[].detail.alarm.alarm_email Array

List of email recipients

actions[].detail.email.to Array

List of email recipients

actions[].detail.api.url String

External API URL to call

actions[].detail.api.method String

HTTP method

actions[].detail.api.headers[] Array

Key-value pairs of headers

actions[].detail.api.params[] Array

Key-value query parameters for the API call

actions[].detail.api.body String

Raw body string (can be JSON, plain text, etc.)

{
    "triggers": [
        {
            "device": 588,
            "source": "controller",
            "value": [
                {
                    "telemetry_key": "2139129123",
                    "actuator_name": "ets"
                }
            ],
            "condition": "=",
            "comparator": "on"
        },
        {
            "relation": "AND"
        },
        {
            "device": 568,
            "source": "controller",
            "value": [
                {
                    "telemetry_key": "door_sensor",
                    "actuator_name": "door sensor"
                }
            ],
            "condition": "=",
            "comparator": "true"
        }
    ],
    "actions": [
        {
            "type": "alarm",
            "detail": {
                "alarm": {
                    "is_send_email": 1,
                    "alarm_email": [
                        "usertenant4@baru.com"
                    ],
                    "device": 588,
                    "detail": "test",
                    "alarm_email_group_id": [
                        23
                    ]
                }
            }
        },
        {
            "type": "controller",
            "detail": {
                "controller": {
                    "device": 588,
                    "device_action_key": "2139129123",
                    "device_action_value": "off"
                }
            }
        },
        {
            "type": "email",
            "detail": {
                "email": {
                    "to": [
                        "usertenant2@baru.com"
                    ],
                    "subject": "test",
                    "content": "testing",
                    "email_group_id": [
                        4
                    ]
                }
            }
        },
        {
            "type": "api",
            "detail": {
                "api": {
                    "url": "testing.com",
                    "method": "GET",
                    "headers": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "params": [
                        {
                            "key": "test",
                            "value": "22"
                        }
                    ],
                    "body": "testing"
                }
            }
        }
    ],
    "name": "test controller trigger postman",
    "is_active": 0,
    "automation_type": "trigger",
    "description": "test"
}                                            
{
    "message": "automation created",
    "data": {
        "id": 987
    },
    "code": 200
}
{
    "message": "Invalid Message",
    "code": 400,
    "errors": [
        {
            "field": "actions.0.detail.alarm.alarm_email",
            "message": "The actions.0.detail.alarm.alarm_email field is required when actions.0.detail.alarm.is_send_email is 1."
        }
    ]
}