Public API – POST Create Fence

The fences end point allows new Geofences to be created and added to an existing Zone.

Geofences can be added regardless of whether the Zone was created using the zones API or via the web interface for the Bluedot back-end system, Point Access.

URL to call

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

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

These are the common fields required in the create fences JSON request.

Name
Required
Data Type
Description
Format
customerApiKey String API key for customer (rather than the app).
apiKey String API key for the app.
zoneId String The identifier of the zone being updated.
name String Name given to the fence.
color String Hash code representing the color of the Geofence. For example, “#FFFFFF” is white
order Number The order number in which device should walk into the Geofence or cross the Geoline™ for triggering based on Sequential condition. 0 – N

JSON request to create a circular fence (requiring a centre point and radius)

Name
Required
Data Type
Description
Format
radius Number Double value representing the radius of a circular geofence in metres.
center Object Coordinates for the center point of the circle.
latitude Number Latitude of the center of the circular fence.
longitude Number longitude of the center of the circular fence.

{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "24d9a245-2087-421b-9972-2af2ee0970f1",
            "fences": {
                "circles": [
                    {
                        "name": "Test Circular fence with 8M radius",
                        "color": "#000fff",
                        "radius": 8,
                        "order": 1,
                        "center": {
                            "latitude": -37.8159544565362,
                            "longitude": 144.9723565578461
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a bounding box (requires points for north east and south west)

Name
Required
Data Type
Description
Format
northEast Object Coordinates for the north-east point of a bounding box.

It consists of a latitude and longitude fields.

southWest Object Coordinates for the south-west point of a bounding box.

It consists of a latitude and longitude fields.

latitude Number Latitude of the north-east or south-west points of a bounding box
longitude Number Longitude of the north-east or south-west points of a bounding box
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "24d9a245-2087-421b-9972-2af2ee0970f1",
            "fences": {
                "rectangles": [
                    {
                        "name": "A bounding box with north east and south west",
                        "color": "#58fe15",
                        "order": 1,
                        "northEast": {
                            "latitude": -37.81794619852986,
                            "longitude": 144.97999548912048
                        },
                        "southWest": {
                            "latitude": -37.81846319511329,
                            "longitude": 144.97921228408813
                        }
                    }
                ]
            }
        }
    }
}

JSON request to create a polygonal fence (requires a series of points)

Name
Required
Data Type
Description
Format
vertices Array A polygon is made of multiple vertices. In the JSON, vertices is an array of more than 3 points, each having a latitude and longitude.
latitude Number Latitude of a vertex of a polygon
longitude Number Longitude of a vertex of a polygon
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "24d9a245-2087-421b-9972-2af2ee0970f1",
            "fences": {
                "polygons": [
                    {
                        "name": "A Polygonal Fence",
                        "color": "#000fff",
                        "order": 3,
                        "vertices": [
                            {
                                "latitude": -37.81902680201739,
                                "longitude": 144.9821037054062
                            },
                            {
                                "latitude": -37.8196878692931,
                                "longitude": 144.98161554336548
                            },
                            {
                                "latitude": -37.82052267015026,
                                "longitude": 144.9816906452179
                            },
                            {
                                "latitude": -37.82128118660006,
                                "longitude": 144.98312830924988
                            },
                            {
                                "latitude": -37.82102693614463,
                                "longitude": 144.98458743095398
                            },
                            {
                                "latitude": -37.820196378553405,
                                "longitude": 144.98524725437164
                            },
                            {
                                "latitude": -37.81895899991077,
                                "longitude": 144.9847161769867
                            },
                            {
                                "latitude": -37.81865812731128,
                                "longitude": 144.9839222431183
                            },
                            {
                                "latitude": -37.81866660261256,
                                "longitude": 144.98308539390564
                            },
                            {
                                "latitude": -37.81902680201739,
                                "longitude": 144.9821037054062
                            }
                        ]
                    }
                ]
            }
        }
    }
}

JSON request to create a GEOLINE™ (requires a series of points)

Name
Required
Data Type
Description
Format
vertices Array A Geoline is made of two or more points. In the JSON, vertices is an array of 2 or more points, each having a latitude and longitude
latitude Number Latitude for a point of a Geoline™.
longitude Number Longitude for a point of a Geoline™.
{
    "security": {
        "customerApiKey": "bc199c80-5441-11e4-b7bb-a0481cdc3311",
        "apiKey": "d3161e80-38d1-11e4-b039-bc305bf60831"
    },
    "content": {
        "zone": {
            "zoneId": "24d9a245-2087-421b-9972-2af2ee0970f1",
            "fences": {
                "polylines": [
                    {
                        "name": "Geoline near MCG",
                        "order": 3,
                        "vertices": [
                            {
                                "latitude": -37.818717,
                                "longitude": 144.983085
                            },
                            {
                                "latitude": -37.81954,
                                "longitude": 144.982125
                            },
                            {
                                "latitude": -37.820298,
                                "longitude": 144.981894
                            }
                        ]
                    }
                ]
            }
        }
    }
}

Example: JSON response to request

{
    "fencesUpdated": [
        {
            "fenceId": "019ddd20-3c9d-4d3c-902f-d78c1d1e9d0d",
            "fenceName": "Test Circular fence with 8M radius"
        }
    ],
    "message": "Your request has been successfully processed.",
    "messageCode": 200
}
Created by Bluedot DevOps on January 31, 2018

Start the discussion