Sorry, you need to enable JavaScript to visit this website.

Edit fence

 

Service version: 1 (Public Preview)
Last edit: 2019.03.27

On this page

Purpose

The Edit fence endpoint provides new values for fence attributes. An Admin may only send the values that need to be updated.

Request data

HTTP method: PUT

URL format

For ease of viewing and identification:

  • Required constants and parameters are shown in bold text.
  • Optional parameters are shown in plain text.
PUT https://baseURL/geofencing/versionNumber/fences/fenceId?key=Your_API_Key&adminKey=Your_Admin_Key

curl command

curl -XPUT -H "Content-type: application/json" -d '{
    "name": "fence_name","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"
    }
}' 'https://baseURL/geofencing/versionNumber/fences/fenceId?key=Your_API_Key&adminKey=Your_Admin_Key'

PUT Request body (JSON)

{
  "name": "fence_name","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"
  }
}
PUT body fields
Field name Description
name
string
Unique name
Value: A unique name.
projects
array
A list of projects (array), it has to contain at least one entry.
Editing the list (array) of projects works like this:

  • Projects that were not linked before are linked.
  • Projects that were linked before are not changed.
  • projects that are not listed and were linked before are unlinked.

Value: A list (array) of projects containing at least one entry.

geometry
object
Fence geometry: An Admin has to provide the whole block, not only the edited attributes.
Value: The whole block with the edited attributes.
properties
object
All properties are updated.

  • An Admin has to provide all properties.
  • Any properties that already exist but are not listed are deleted.

Value: All properties.

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
fenceId
string
The Id of the fence to edit.
Value: UUID
key
string
An API Key valid for the requested service.
Value: Your valid API Key.
adminKey
string
An Admin key valid for the provided API key.
Value: Your valid Admin Key.
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

▲ Return to top

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 table describes all of the Response fields.

Primary fields
Field Description
name
string
Name of the fence.
id
string
UUID of the fence.
type
string
In the current version it is always "Feature".
projects[]
array
The list of projects the fence is 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. It's content varies between fences.
projects[] array
Field Description
id
string
UUID of a project.
name
string
Name of a project.

HTTP Response codes

Code Meaning and possible causes
200 OK
400 Bad request:

  • Fence with the given name already exists.
  • Fence geometry is invalid.
  • At least one project has to be defined for a fence.
  • No such project.
  • Invalid geometry.
403 Forbidden:

  • Provided Admin Key is invalid.
  • Admin Key is missing.
404 Not found:

  • Fence with the specified id does not exist.
  • Project with the specified id does not exist.

▲ Return to top

Examples

Request URL

PUT https://api.tomtom.com/geofencing/1/fences/aaab6d78-1738-45bd-a78b-ff3a7ba839f3?key=Your_API_Key&adminKey=Your_Admin_Key

PUT Request body

{"name": "No-fly zone","properties": {"maxAmountOfCars": 10}}

Response body (JSON)

{
    "name": "No-fly zone",
    "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": {
        "maxAmountOfCars": 10
    }
}

▲ Return to top

You are here