Create new fence, assign to multiple projects
Service version: 1
Last edit: 2021.01.19
On this page
- ▸ Purpose
- ▸ Request data
Purpose
This endpoint creates a new fence and assigns it to multiple projects.
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/fences/fence?key=Your_API_Key&adminKey=Your_Admin_Key
curl command
curl -v -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",
"projects": ["project_1_id", ...],
"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: Your valid API Key .
|
adminKey string |
A valid Admin Key. Value: Your valid Admin Key .
|
Optional parameters | |
Parameter | Description |
showGeoJson boolean |
If set to true , the output contains a GeoJSON 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
{
"name": "fence_name",
"id": "fence_id",
"type": "Feature",
"projects": [project_1_id, ... , project_N_id],
"geometry": {
"radius": radius_in_meters,
"type": "Point",
"shapeType": "shape_type",
"coordinates": [longitude, latitude]
},
"properties": {
"key:" "value"
}
}
Response fields
The following data tables describe all of the fields that can appear in a Response. Fields are listed by the Response section they belong to and in the order that they appear in the Response.
Primary fields | |
---|---|
Field | Description |
name string |
The name of the fence. |
id string |
The UUID of the fence. |
type string |
In the current version its always "Feature". |
projects[] array |
The list of projects the fence was assigned to. |
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. |
projects[] array |
|
Field | Description |
id string |
The UUID of a project. |
name string |
The name of a project. |
HTTPS Response codes
Code | Meaning and possible causes |
---|---|
201 |
Created |
400 |
Bad request:
|
403 |
Forbidden:
|
Examples
Request URL
https://api.tomtom.com/geofencing/1/fences/fence?key=Your_API_Key&adminKey=Your_Admin_Key
POST Request body (JSON)
{
"name": "No-fly zone 23",
"type": "Feature",
"projects": ["131db271-752e-4462-bd7a-ac948864110e", "36188f87-03ea-4fd4-b606-68d28f781365"],
"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",
"projects": ["131db271-752e-4462-bd7a-ac948864110e", "36188f87-03ea-4fd4-b606-68d28f781365"],
"geometry": {
"radius": 75,
"type": "Point",
"shapeType": "Circle",
"coordinates": [-67.137343, 45.137451]
},
"properties": {
"maxSpeedKmh": 70
}
}