Add Geofence

The /Geofence POST request allows you to create a geofence inside an existing geofence set.

Request

POST https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/Geofence

Request Element

The Add Geofence operation requires JSON format data in the Post body.

ElementDefinitionRequired
SetIdThe Id of the set you are adding this geofence to.Y
NameThe name of your geofence.Y
LabelThe optional label of your geofence. Max length is 255.N
ShapeTypeThe shape of this geofence.
1 = circle
5 = polygon
Y
RadiusThe radius in miles for a circular geofence.Y - if defining a circle geofence
ShapePointsAn array of latitude and longitude coordinates that represent the border of the fence. The first and last points in the array must match.
For circle geofences, use a single point as the center of the geofence.
Y
StartTimeThe date/time indicating the beginning of a time window during which this geofence will be active. The time should be formatted according to the ISO 8601 Standard (YYYY-MM-DDTHH:MM:SSZ)N
EndTimeThe date/time indicating the end of a time window during which this geofence will be active. The time should be formatted according to the ISO 8601 Standard (YYYY-MM-DDTHH:MM:SSZ)N

Sample JSON Post Body

{
  "SetId": 1013,
  "Name": "myFence",
  "Label": "my label",
  "ShapeType": 5,
  "ShapePoints": [
    [-75.152955714212, 39.204307443124],
    [-75.129804285788, 39.204307443124],
    [-75.129804285788, 39.18629254291],
    [-75.152955714212, 39.18629254291],
    [-75.152955714212, 39.204307443124]
  ],
  "StartTime": "2017-01-06T14:59:36-04:00",
  "EndTime": "2018-01-06T14:59:36-04:00"
}

Response

The return from this operation is the ID of your newly created geofence.

1013

Errors

Data ElementDescriptionData TypeValue/Example
TypeIndicates whether the error is an exception or warningEnumWarning Exception
CodeError codeEnumPlease refer to Appendix for complete list
LegacyErrorCodeThe legacy error code with is an integer valued code that would have been returned in PC*MILER Web Services v25 and earlier.int
DescriptionThe detailed error description.string