Add new fence to a project
Decommission notice
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
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}/projects/{projectId}/fence?key={Your_API_Key}&adminKey={Your_Admin_Key}'POST request body format
{ "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.
- 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
{ "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 | 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_KeyPOST request body example
{ "name": "No-fly zone 23", "type": "Feature", "geometry": { "radius": 75, "type": "Point", "shapeType": "Circle", "coordinates": [-67.137343, 45.137451] }, "properties": { "maxSpeedKmh": 70 }}Response body example
{ "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 }}