Add new fence to a project
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
- Constants and parameters enclosed in curly brackets { } must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL request format
https://{baseURL}/geofencing/{versionNumber}/projects/{projectId}/fence?key={Your_API_Key}&adminKey={Your_Admin_Key}
curl command request format
1curl -XPOST -H "Content-type: application/json" -d '{2 "name": "fence_name",3 "type": "Feature",4 "geometry": {5 "radius": radius_in_meters,6 "type": "Point",7 "shapeType": "shape_type",8 "coordinates": [longitude, latitude]9 },10 "properties": { //Optional11 "key": "value"12 }13}' 'https://{baseURL}/geofencing/{versionNumber}/projects/{projectId}/fence?key={Your_API_Key}&adminKey={Your_Admin_Key}'
POST request body format
1{2 "name": "fence_name",3 "type": "Feature",4 "geometry": {5 "radius": radius_in_meters,6 "type": "Point",7 "shapeType": "shape_type",8 "coordinates": ["longitude", "latitude"]9 },10 "properties": {11 "key": "value"12 }13}
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.
- The order of request parameters is not important.
Required parameters | Description |
---|---|
| The base URL for calling the API. |
| Service version number. |
| An API Key valid for the requested service. |
| Admin Key valid for provided API Key. |
| The project id to create a fence for. |
Optional parameters | Description |
---|---|
| If set to |
Response data
Response body
1{2 "name": "fence_name",3 "id": "fence_id",4 "type": "Feature",5 "geometry": {6 "radius": radius_in_meters,7 "type": "Point",8 "shapeType": "shape_type",9 "coordinates": ["longitude, latitude"]10 },11 "properties": {12 "key": "value"13 }14}
Response fields
The following table describes all of the response fields.
Primary fields | Description |
---|---|
| The name of the fence. |
| The UUID of the fence. |
| In the current version it is always "Feature". |
| An object that describes fence geometry. See the Custom fence shapes section. |
| (Optional) An object containing user-defined properties of the fence. Its content varies between fences. |
Response codes
Code | Meaning & possible causes |
---|---|
| Created |
| Bad request:
|
| Forbidden:
|
Example
Add a new fence to a project
URL request example
https://api.tomtom.com/geofencing/1/projects/44de824d-c368-46cf-a234-a6792682dfd6/fence?key=Your_API_Key&adminKey=Your_Admin_Key
POST request body example
1{2 "name": "No-fly zone 23",3 "type": "Feature",4 "geometry": {5 "radius": 75,6 "type": "Point",7 "shapeType": "Circle",8 "coordinates": [-67.137343, 45.137451]9 },10 "properties": {11 "maxSpeedKmh": 7012 }13}
Response body example
1{2 "name": "No-fly zone 23",3 "id": "aaab6d78-1738-45bd-a78b-ff3a7ba839f3",4 "type": "Feature",5 "geometry": {6 "radius": 75,7 "type": "Point",8 "shapeType": "Circle",9 "coordinates": [-67.137343, 45.137451]10 },11 "properties": {12 "maxSpeedKmh": 7013 }14}