Tarsheed
  1. Automation
Tarsheed
  • Auth
    • Create Account
      POST
    • Verifiy Email
      POST
    • Login
      POST
    • Resend Verfication Code
      POST
    • Forget Password Request
      POST
    • Forget password Verify Code
      POST
    • Reset Password
      PATCH
    • Login With Google
      POST
    • Login With Facebook
      POST
  • Users
    • Get all users
      GET
    • Get specific user
      GET
    • Delete user account
      DELETE
    • Update user data
      PUT
    • Change user password
      PUT
    • Get Recomendation
      GET
    • Get Avarage Cost For Spesfic User
      GET
    • Get The Power Saving Modes Settings
      GET
    • Update the Usage of the power saving mode
      PATCH
  • Reports
    • GetUserReport
      GET
  • Room
    • Create New Room
      POST
    • Update Room
      PATCH
    • Delete Room
      DELETE
    • Get Room Details
      GET
    • Get all Rooms for spesfic user
      GET
  • Device
    • Create New Device
    • Update Device
    • Delete Device
    • Get All Devices id For IOT System
    • Toggle Device Status
  • category
    • get all categories
  • Sensor
    • Create New Sensor
    • Update Sensor
    • Delete Sensor
    • Get All Sensor For Spesfic user
  • Automation
    • Add New Automation
      POST
    • Get all Automation for Spesfic User
      GET
    • Delete Spesfic Automation
      DELETE
    • Update Spesfic Automation
      PATCH
    • Apply Automation Manually
      POST
  1. Automation

Add New Automation

Developing
POST
/automation/create
Automation
this endpoint for add new automation

Request

Header Params
Authorization
string 
optional
Example:
token
Body Params application/json
triggers
array [object {4}] 
required
type
string 
required
SENSOR | SCHEDULE
sensorId
string 
required
if type is SENSOR
value
string 
required
if type is SENSOR
time
integer 
required
if type is SCHEDULE
actions
array [object {2}] 
required
type
string 
required
data
object 
required
conditions
array [object {3}] 
required
type
string 
required
DEVICE | SENSOR
deviceId
string 
required
state
string 
required
name
string 
required
name
Example
{
  "name": "Automation 1",
  "triggers": [
    {
      "type": "SENSOR",
      "sensorId": "60b8d2950f1b2c001f8c8e4d",  
      "value": 30
    }
  ],
  "conditions": [
    {
      "type": "DEVICE",
      "deviceId": "60b8d2950f1b2c001f8c8e4f",  
      "state": "on"
    }
  ],
  "actions": [
    {
      "type": "NOTIFICATION",
      "data": {
        "title": "Temperature Alert",
        "message": "The temperature has reached 30°C."
      }
    }
  ]
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/automation/create' \
--header 'Authorization: token' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "Automation 1",
  "triggers": [
    {
      "type": "SENSOR",
      "sensorId": "60b8d2950f1b2c001f8c8e4d",  
      "value": 30
    }
  ],
  "conditions": [
    {
      "type": "DEVICE",
      "deviceId": "60b8d2950f1b2c001f8c8e4f",  
      "state": "on"
    }
  ],
  "actions": [
    {
      "type": "NOTIFICATION",
      "data": {
        "title": "Temperature Alert",
        "message": "The temperature has reached 30°C."
      }
    }
  ]
}'

Responses

🟢200Success
application/json
Body
object {0}
Example
{
    "message": "Automation created successfully",
    "automation": {
        "userId": "680a9b2dcdf756b0e0909dde",
        "triggers": [
            {
                "type": "SENSOR",
                "sensorId": "60b8d2950f1b2c001f8c8e4d",
                "value": 30
            }
        ],
        "actions": [
            {
                "type": "NOTIFICATION",
                "data": {
                    "title": "Temperature Alert",
                    "message": "The temperature has reached 30°C."
                }
            }
        ],
        "conditions": [
            {
                "type": "DEVICE",
                "deviceId": "60b8d2950f1b2c001f8c8e4f",
                "state": "on"
            }
        ],
        "_id": "6822a355f5451751b0c737f0",
        "createdAt": "2025-05-13T01:41:41.136Z",
        "updatedAt": "2025-05-13T01:41:41.136Z",
        "__v": 0
    }
}
Previous
Get All Sensor For Spesfic user
Next
Get all Automation for Spesfic User
Built with