Add new fence to a project
Service version: 1
Last edit: 2019.09.18
On this page
- ▸ Purpose
- ▸ Request data
Purpose
The Add new fence to a project endpoint creates a new fence and automatically links it to a single project.
- The easiest way to add a new fence is by adding a new one to a project.
- Instead of listing fences in the Request body, a new fence can be added to the single project selected in the Request URL.
Request data
HTTPS method: POST
For ease of viewing and identification:
- Required constants and parameters are shown in bold text.
- Optional parameters are shown in plain text.
https://baseURL/geofencing/versionNumber/projects/projectId/fence?key=Your_API_Key&adminKey=Your_Admin_Key
curl command
curl -XPOST -H "Content-type: application/json" -d '{
"name": "fence_name",
"type": "Feature",
"geometry": {
"radius": radius_in_meters,
"type": "Point",
"shapeType": "shape_type",
"coordinates": [longitude, latitude]
},
"properties": { //Optional
"key": "value"
}
}' 'https://baseURL/geofencing/versionNumber/fences/fence?key=Your_API_Key&adminKey=Your_Admin_Key'
>
POST Request body (JSON)
{
"name": "fence_name",
"type": "Feature",
"geometry": {
"radius": radius_in_meters,
"type": "Point",
"shapeType": "shape_type",
"coordinates": ["longitude", "latitude"]
},
"properties": {
"key": "value"
}
}
Request parameters
The following table describes the parameters that can be used in a request.
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
- If there is a default value that will be assumed when an optional parameter is not used, it is shown in the table.
- The order of request parameters is not important.
Required parameters | |
---|---|
Parameter | Description |
baseURL string |
The base URL for calling the API. Value: api.tomtom.com |
versionNumber string |
Service version number. Value: 1 |
key string |
An API Key valid for the requested service. Value: API key |
adminKey string |
Admin key valid for provided API key. Value: A valid Admin Key. |
projectId string |
The project id to create a fence for. Value: UUID |
Optional parameters | |
Parameter | Description |
showGeoJson boolean |
If set to true , the output contains a representation of a custom fence shape.For fences that are defined as GeoJSON, this parameter changes nothing. Default value: false Other value: true |
Response data
Response body (JSON)
{
"name": "fence_name",
"id": "fence_id",
"type": "Feature",
"geometry": {
"radius": radius_in_meters,
"type": "Point",
"shapeType": "shape_type",
"coordinates": ["longitude, latitude"]
},
"properties": {
"key": "value>"
}
}
Response fields
The following table describes all of the Response fields.
Primary fields | |
---|---|
Field | Description |
name string |
The name of the fence. |
id string |
The UUID of the fence. |
type string |
In the current version it is always "Feature". |
geometry{} object |
An object that describes fence geometry. See the Custom fence shapes section. |
properties{} object |
(Optional) An object containing user-defined properties of the fence. Its content varies between fences. |
HTTP Response Codes
Code | Meaning and possible causes |
---|---|
201 |
Created |
400 |
Bad request:
|
403 |
Forbidden:
|
Examples
Request URL
https://api.tomtom.com/geofencing/1/projects/44de824d-c368-46cf-a234-a6792682dfd6/fence?key=Your_API_Key&adminKey=Your_Admin_Key
POST Request body (JSON)
{
"name": "No-fly zone 23",
"type": "Feature",
"geometry": {
"radius": 75,
"type": "Point",
"shapeType": "Circle",
"coordinates": [-67.137343, 45.137451]
},
"properties": {
"maxSpeedKmh": 70
}
}
Response body (JSON)
{
"name": "No-fly zone 23",
"id": "aaab6d78-1738-45bd-a78b-ff3a7ba839f3",
"type": "Feature",
"geometry": {
"radius": 75,
"type": "Point",
"shapeType": "Circle",
"coordinates": [-67.137343, 45.137451]
},
"properties": {
"maxSpeedKmh": 70
}
}