Public API – POST Action with Condition

The actions endpoint allows existing Actions and Conditions to be updated. Zone Id, Action Id and Condition Id have to be provided for the successful update to occur.

URL to call

https://api.bluedotinnovation.com/1/actions

Content Type

The content type should be specified in the Content-Type HTTP header as “application/json”.

image

Content-Type: application/json

Parameters

No URL Parameters required. See example JSON below.

Key JSON fields

Name
Required
Data Type
Description
Format
customerApiKey String API Key for the customer, rather than the app.
apiKey String API Key of the relevant app.
zoneId String The identifier of the zone being updated.
conditions Object The conditions object is where the different conditions can be added to an action. At least one of the following fields should be present: percentageCrossed, dateRange or timeActive.
percentageCrossed Array The percentageCrossed condition is the percentage of Geofences and/or Beacons that must be crossed for this condition to pass in the a certain time period.
dateRange Array Start and end dates for the date range condition. Multiple date ranges can be added to a condition.
timeActive Array Start and end time for the time active condition. Time must be in HH:MM format, using a 12 hour clock and reference to AM or PM. Example “09:00” with a period of “am”.
bearing Array From and to angle for the bearing condition. The minimum difference between from and to angle should be 90°.
speed Array Minimum and maximum speed for the Speed condition. The minimum difference between minimum and maximum speed should be 5 m/s.

JSON request to create a Percentage Crossed condition for an Action

Name
Required
Data Type
Description
Format
percentage Number The percentage value is the percentage of Geofences and/or beacons For example, “50” represents 50%.  1 to 100
timeoutPeriod String Time period within which the percentage of Geofences noted in the percentageCrossed field must be crossed. Example “00:02” represents 2 minutes.  HHH:MM

{

    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with Percentage Crossed Condition",
                        "conditions": {
                            "percentageCrossed": [
                                {
                                    "percentage": 50,
                                    "timeoutPeriod": "00:02",
                                    "sequential": false
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a Sequential Percentage Crossed condition for an Action

Name
Required
Data Type
Description
Format
percentage Number The percentage value is the percentage of Geofences and/or beacons For example, “50” represents 50%.  1 to 100
timeoutPeriod String Time period within which the percentage of Geofences noted in the percentageCrossed field must be crossed. Example “00:02” represents 2 minutes.  HHH:MM
sequential Boolean Requires that fences or beacons be crossed in sequence (see Sequence Geofeatures) true or false
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with a Sequential Percentage Crossed Condition",
                        "conditions": {
                            "percentageCrossed": [
                                {
                                    "percentage": 65,
                                    "timeoutPeriod": "00:50",
                                    "sequential": true
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a Date condition for an Action

Name
Required
Data Type
Description
Format
start String The start date from when the action should be triggered. DD/MM/YYYY
end String The end date after when the action would not be triggered DD/MM/YYYY

{

    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with a Date Condition",
                        "conditions": {
                            "dateRange": [
                                {
                                    "start": "01/10/2016",
                                    "end": "01/12/2017"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a Time condition for an Action

Name
Required
Data Type
Description
Format
from Object The start time from when the action would be triggered.
to Object The end time after when the action would not be triggered.
time String Time must use a 12 hour clock. HH:MM
period String The Time period of the day. am/pm
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with a Time Condition",
                        "conditions": {
                            "timeActive": [
                                {
                                    "from": {
                                        "time": "10:00",
                                        "period": "am"
                                    },
                                    "to": {
                                        "time": "02:00",
                                        "period": "pm"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a Bearing condition for an Action 

Name
Required
Data Type
Description
Format
fromAngle Number The from angle from when the action would be triggered. 0 – 359
toAngle Number The to angle from when the action would be triggered. 0 – 359
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with a Bearing Condition",
                        "conditions": {
                            "bearing": [
                                {
                                    "fromAngle": 80,
                                    "toAngle": 200
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a Speed condition for an Action 

Name
Required
Data Type
Description
Format
minimumSpeed Number The minimum speed from when the action would be triggered.
maximumSpeed Number The maximum speed from when the action would be triggered.
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "cc6f9dd1-3d69-454d-abdd-58176cbf67dc",
            "actions": {
                "customActions": [
                    {
                        "name": "A Custom Action with a Speed Condition",
                        "conditions": {
                            "speed": [
                                {
                                    "minimumSpeed": 10,
                                    "maximumSpeed": 30
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

JSON Response

{
    "objectsUpdated": [
        {
            "actionId": "210a86e8-f616-4c2b-9ec3-98e8786e69a8",
            "actionName": "A Custom Action with Percentage Crossed Condition"
        }
    ],
    "message": "Your request has been successfully processed.",
    "messageCode": 200
}

Source code examples

Created by Bluedot DevOps on March 3, 2018

Start the discussion