

# Amazon Location Service Geofences
<a name="geofences"></a>

![\[An overview of Amazon Location Service Geofences.\]](http://docs.aws.amazon.com/location/latest/developerguide/images/geofences-overview.png)


Geofence collection resources allow you to store and manage geofences - virtual boundaries on a map. You can evaluate locations against a geofence collection resource and receive notifications when the location update crosses the boundary of any of the geofences in the collection.

**Geofences and geofence collection **

A geofence is a circle, polygon, or multipolygon geometry that defines a virtual boundary on a map. A geofence collection contains zero or more geofences. It's capable of geofence monitoring by emitting `ENTER` and `EXIT` events, when requested, to evaluate a device position against its geofences. 

**Geofence events **

Locations for positions you're monitoring are referenced by an ID called a `DeviceId`. The positions are referred to as device positions. You can send a list of device positions to evaluate directly to the geofence collection resource, or you can use a tracker. For more information about using trackers, see [Amazon Location Service trackers](trackers.md). 

You receive events (via Amazon EventBridge) only when a device enters or exits a geofence, not for every position change. This means that you will typically receive events and have to respond to them much less frequently than every device position update. 

**Note**  
For the first location evaluation for a specific `DeviceID`, it is assumed that the device was previously not in any geofences. So the first update will generate an `ENTER` event, if inside a geofence in the collection, and no event if not.   
In order to calculate whether a device has entered or exited a geofence, Amazon Location Service must keep previous position state for the device. This position state is stored for 30 days. After 30 days without an update for a device, a new location update will be treated as the first position update. 

## Use cases for Amazon Location Service Geofences
<a name="geofence-use-cases"></a>

The following are a few common uses for Amazon Location Service Geofences.

**Improve field service operations**

Keep a pulse on your mobile workforce with real-time tracking. Set geofences around customer sites and service areas to receive alerts when staff arrive and depart. Use location data to optimize scheduling, dispatch the nearest available technician, and reduce response times. Empower your field teams (such as a your plumbing or HVAC repair business) to work more efficiently, while enhancing the customer experience. 

**Monitor and control critical assets**

Utilize Amazon Location Service to track the real-time location and status of your valuable equipment, inventory, and other mobile assets. Set up geofences to receive alerts on unauthorized movements or removals, enhancing security and compliance. Use this location visibility to improve asset utilization, optimize maintenance schedules, and ensure your critical resources are accounted for at all times. Always monitor your heavy machinery, IT hardware, or retail inventory with precision, reduce losses, and make more informed operational decisions. 

**Enhance supply chain visibility**

Leverage Amazon Location Service to track shipments and deliveries across your entire supply chain. Define geofences around distribution centers, stores, and other key facilities to monitor the movement of inventory and assets. Use real-time location data to improve inventory management, optimize logistics planning, and deliver a superior customer experience. Gain end-to-end visibility into your supply chain operations, identify bottlenecks, and make data-driven decisions that drive efficiency and responsiveness. 

**Strengthen safety and security**

Geofencing enables you to set up virtual boundaries around secure areas, restricted zones, and other critical locations. Receive instant alerts when unauthorized personnel or assets enter or exit these predefined geofences. Leverage this real-time location monitoring to enhance workplace safety, deter trespassing, and ensure regulatory compliance. Whether you manage a manufacturing facility, construction site, or corporate campus, geofencing empowers you to maintain tighter control over access, improve incident response, and protect your people, property, and assets. 

**Location-based marketing**

Unlock the power of location data to supercharge your geomarketing efforts. Use Amazon Location Service to set virtual boundaries around competitor locations, events, and high-traffic areas. Trigger personalized ads, offers, and notifications when customers enter these geofenced zones. Analyze foot traffic patterns to optimize ad placements and uncover prime sites for new business locations. Monitor customer movements within your own geofenced spaces to gain deeper insights on browsing behaviors and path-to-purchase. Combine real-time location tracking with precision geofencing to deliver hyper-targeted, contextual engagement that drives sales and loyalty in the physical world. 

# Geofence concepts
<a name="geofence-components"></a>

This section describes some common geofence concepts, including common terminology and how to manage geofences.

## Amazon Location Service geofence terminology
<a name="geofence-terminology"></a>

Geofence  
A virtual boundary for a geographical area on a map.

Geofence collection  
A group of geofences that is capable of emitting `Entry` and `Exit` events, when requested, to evaluate a device's position against its component geofences.

Geofence geometry  
A geometric shape or set of shapes that define the areas to be included or excluded from a geofence. A geofence geometry can be represented as a `Circle`, `Polygon`, or `MultiPolygon`.  
A `Circle` is a point with a distance around it. Use a circle when you want to be notified if a device is within a certain distance of a location.  
A `Polygon` is a list of linear rings which represent the shape of a geofence. This list *must* include an exterior ring representing the outer perimeter of the geofence, and can optionally include multiple interior rings representing polygonal spaces within the perimeter, which are excluded from the geofence area.  
A `MultiPolygon` is a list `Polygon` elements which represent the shape of a geofence. The `Polygon` components of a `MultiPolygon` geometry can define separate geographical areas that are considered part of the same geofence, perimeters of larger exterior areas with smaller interior spaces that are excluded from the geofence, or some combination of these use cases to form complex geofence boundaries.  
For more information about defining geofence geometries, including syntax requirements, limitations, and examples, see [GeofenceGeometry](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_GeofenceGeometry.html) in the *Amazon Location Service API Reference*.

# Get started with Amazon Location Service Geofences
<a name="geofence-gs"></a>

Geofences are powerful tools for defining geographic boundaries and triggering actions based on location updates. This guide walks you through the process of creating and using geofence collection resources in Amazon Location. By setting up geofences and evaluating locations against them, you can monitor movement and generate automated events, such as notifications when a device enters or exits a defined area. These features are ideal for applications like fleet tracking, location-based notifications, and more.

1. Create a geofence collection resource in your AWS account.

1. Add geofences to the collection. You can use the geofence upload tool on the Amazon Location console or the Amazon Location Geofences API. For more information about available options, see [Authenticate with Amazon Location Service](access.md). A geofence can be defined as a `Circle`, `Polygon`, or `MultiPolygon`. Use a `Polygon` or `MultiPolygon` to determine when a device enters a specific area. Use a `Circle` to determine when a device comes within a certain distance (radius) of a point. For more information, see [Amazon Location Service geofence terminology](https://docs.aws.amazon.com/location/latest/developerguide/geofence-components.html#geofence-terminology).

1. You can start evaluating locations against all your geofences. When a location update crosses the boundaries of one or more geofences, your geofence collection resource emits one of the following geofence event types on Amazon EventBridge:
   + **ENTER** – One event is generated for each geofence where the location update crosses its boundary by entering it.
   + **EXIT** – One event is generated for each geofence where the location update crosses its boundary by exiting it.

   For more information, see [React to Amazon Location Service events with Amazon EventBridge](location-events.md). You can also integrate monitoring using services such as Amazon CloudWatch and AWS CloudTrail. For more information see, [Monitor with Amazon CloudWatch](cloudwatch.md) and [Monitor and log with AWS CloudTrail](cloudtrail.md).

For example, you are tracking a fleet of trucks and want to be notified when a truck comes within a certain area of any of your warehouses. Create a geofence for the area around each warehouse. When the trucks send you updated locations, use Amazon Location Service to evaluate those positions and see if a truck has entered (or exited) one of the geofence areas.

**Note**  
You're billed by the number of geofence collections you evaluate against. Your bill is not affected by the number of geofences in each collection. Since each geofence collection may contain up to 50,000 geofences, you may want to combine your geofences into fewer collections, where possible, to reduce your cost of geofence evaluations. The events generated will include the ID of the individual geofence in the collection, as well as the ID of the collection.

# How to work with Amazon Location Service Geofences
<a name="geofence-how-to"></a>

This section provides step-by-step guidance for working with geofence-related tasks in Amazon Location. Learn how to evaluate device positions against geofences, respond to geofence events using Amazon EventBridge, and effectively manage your geofence resources. These tutorials are designed to help you implement key functionality for tracking and managing location-based events with ease.

**Topics**
+ [Evaluate device positions against geofences](evaluate-geofences.md)
+ [React to Amazon Location Service events with Amazon EventBridge](location-events.md)
+ [Manage your geofence collection resources](managing-geofence-collections.md)

# Evaluate device positions against geofences
<a name="evaluate-geofences"></a>

There are two ways to evaluate positions against geofences to generate geofence events: 
+ You can link Trackers and Geofence Collections. For more information, see the section: [Link a tracker to a geofence collection](associate-consumer.md).
+ You can make a direct request to the geofence collection resource to evaluate one or more positions. 

If you also want to track your device location history or display locations on a map, link the tracker with a geofence collection. Alternatively, you may not want to evaluate all location updates, or you don't intend to store location data in a tracker resource. If either of these is the case, you can make a direct request to the geofence collection and evaluate one or more device positions against its geofences.

Evaluating device positions against geofences generates events. You can react to these events and route them to other AWS services. For more information about actions that you can take when receiving geofence events, see [Reacting to Amazon Location Service events with Amazon EventBridge](https://docs.aws.amazon.com/location/latest/developerguide/location-events.html).

An Amazon Location event includes the attributes of the device position update that generates it, including the time, position, accuracy, and key-value metadata, and some attributes of the geofence that is entered or exited. For more information about the data included in a geofence event, see [Amazon EventBridge event examples for Amazon Location Service](location-events.md#example-event).

The following examples use the AWS CLI, or the Amazon Location APIs.

------
#### [ API ]

**To evaluate device positions against the position of geofences using the Amazon Location APIs**

Use the `[BatchEvaluateGeofences](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchEvaluateGeofences.html)` operation from the Amazon Location Geofences APIs. 

The following example uses an API request to evaluate the position of device *ExampleDevice* to an associated geofence collection *ExampleGeofenceCollection*. Replace these values with your own geofence and device IDs.

```
POST /geofencing/v0/collections/ExampleGeofenceCollection/positions HTTP/1.1
Content-type: application/json

{
   "DevicePositionUpdates": [ 
      { 
         "DeviceId": "ExampleDevice",
         "Position": [-123.123, 47.123],
         "SampleTime": "2021-11-30T21:47:25.149Z",
         "Accuracy": {
            "Horizontal": 10.30
         },
         "PositionProperties": {
            "field1": "value1",
            "field2": "value2"
         }
      }
   ]
}
```

------
#### [ AWS CLI ]

**To evaluate device positions against the position of geofences using AWS CLI commands**

Use the `[batch-evaluate-geofences](https://docs.aws.amazon.com/cli/latest/reference/location/batch-evaluate-geofences.html)` command. 

The following example uses an AWS CLI to evaluate the position of *ExampleDevice* against an associated geofence collection *ExampleGeofenceCollection*. Replace these values with your own geofence and device IDs.

```
aws location \
    batch-evaluate-geofences \
        --collection-name ExampleGeofenceCollection \
        --device-position-updates '[{"DeviceId":"ExampleDevice","Position":[-123.123,47.123],"SampleTime":"2021-11-30T21:47:25.149Z","Accuracy":{"Horizontal":10.30},"PositionProperties":{"field1":"value1","field2":"value2"}}]'
```

------

# React to Amazon Location Service events with Amazon EventBridge
<a name="location-events"></a>

Amazon EventBridge is a serverless event bus that efficiently connects applications together using data from AWS services like Amazon Location. EventBridge receives events from Amazon Location and routes that data to targets like AWS Lambda. You can set up routing rules to determine where to send your data to build application architectures that react in real time.

Only geofence events (`ENTER` and `EXIT` events, as devices enter or leave the geofenced areas) are sent to EventBridge by default. You can also enable all filtered position update events for a tracker resource. For more information, see [Enable update events for a tracker](#enable-update-events).

For more information, see [the Events and Event Patterns](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html) in *the Amazon EventBridge User Guide*.

**Topics**
+ [Enable update events for a tracker](#enable-update-events)
+ [Create event rules for Amazon Location](#create-event-rule)
+ [Amazon EventBridge event examples for Amazon Location Service](#example-event)

## Enable update events for a tracker
<a name="enable-update-events"></a>

By default, Amazon Location sends only `ENTER` and `EXIT` geofence events to EventBridge. You can enable all filtered position `UPDATE` events for a tracker to be sent to EventBridge. You can do this when you [create](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointTracking_CreateTracker.html) or [update](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointTracking_UpdateTracker.html) a tracker.

For example, to update an existing tracker using the AWS CLI, you can use the following command (use the name of your tracker resource in place of *MyTracker*).

```
aws location update-tracker --tracker-name MyTracker --event-bridge-enabled
```

To turn off position events for a tracker, you must use the API or the Amazon Location Service console.

## Create event rules for Amazon Location
<a name="create-event-rule"></a>

You can create [up to 300 rules per event bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-quota.html) in EventBridge to configure actions taken in response to an Amazon Location event. 

For example, you can create a rule for geofence events where a push notification will be sent when a phone is detected within a geofenced boundary.

**To create a rule for Amazon Location events**

Using the following values, [create an EventBridge rule](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-visual.html) based on Amazon Location events:
+ For **Rule type**, choose **Rule with an event pattern**.
+ In the **Event pattern** box, add the following pattern:

  ```
  {
    "source": ["aws.geo"],
    "detail-type": ["Location Geofence Event"]
  }
  ```

  To create a rule for tracker position updates, you can instead use the following pattern:

  ```
  {
    "source": ["aws.geo"],
    "detail-type": ["Location Device Position Event"]
  }
  ```

  You can optionally specify only `ENTER` or `EXIT` events by adding a `detail` tag (if your rule is for tracker position updates, there is only a single `EventType`, so there is no need to filter on it):

  ```
  {
    "source": ["aws.geo"],
    "detail-type": ["Location Geofence Event"],
    "detail": {
      "EventType": ["ENTER"]
    }
  }
  ```

  You can also optionally filter on properties of the position or geofence:

  ```
  {
    "source": ["aws.geo"],
    "detail-type": ["Location Geofence Event"],
    "detail": {
      "EventType": ["ENTER"],
      "GeofenceProperties": {
        "Type": "LoadingDock"
      },
      "PositionProperties": {
        "VehicleType": "Truck"
      }
    }
  }
  ```
+ For **Select targets**, choose the target action to take when an event is received from Amazon Location Service.

  For example, use an Amazon Simple Notification Service (SNS) topic to send an email or text message when an event occurs. You first need to create an Amazon SNS topic using the Amazon SNS console. For more information, see [Using Amazon SNS for user notifications](https://docs.aws.amazon.com/sns/latest/dg/sns-user-notifications.html).

**Warning**  
It's best practice to confirm that the event rule was successfully applied or your automated action may not initiate as expected. To verify your event rule, initiate conditions for the event rule. For example, simulate a device entering a geofenced area. 

You can also capture all events from Amazon Location, by just excluding the `detail-type` section. For example:

```
{
  "source": [
    "aws.geo"
  ]
}
```

**Note**  
The same event may be delivered more than one time. You can use the event id to de-duplicate the events that you receive.

## Amazon EventBridge event examples for Amazon Location Service
<a name="example-event"></a>

The following is an example of an event for entering a geofence initiated by calling `BatchUpdateDevicePosition`.

```
{
  "version": "0",
  "id": "aa11aa22-33a-4a4a-aaa5-example",
  "detail-type": "Location Geofence Event",
  "source": "aws.geo",
  "account": "636103698109",
  "time": "2020-11-10T23:43:37Z",
  "region": "eu-west-1",
  "resources": [
    "arn:aws:geo:eu-west-1:0123456789101:geofence-collection/GeofenceEvents-GeofenceCollection_EXAMPLE",
    "arn:aws:geo:eu-west-1:0123456789101:tracker/Tracker_EXAMPLE"
  ],
  "detail": {
    "EventType": "ENTER",
    "GeofenceId": "polygon_14",
    "DeviceId": "Device1-EXAMPLE",
    "SampleTime": "2020-11-10T23:43:37.531Z",
    "Position": [
      -123.12390073297821,
      49.23433613216247
    ],
    "Accuracy": {
      "Horizontal": 15.3
    },
    "GeofenceProperties": {
      "ExampleKey1": "ExampleField1",
      "ExampleKey2": "ExampleField2"
    },
    "PositionProperties": {
      "ExampleKey1": "ExampleField1",
      "ExampleKey2": "ExampleField2"
    }
  }
}
```

The following is an example of an event for exiting a geofence initiated by calling `BatchUpdateDevicePosition`.

```
{
  "version": "0",
  "id": "aa11aa22-33a-4a4a-aaa5-example",
  "detail-type": "Location Geofence Event",
  "source": "aws.geo",
  "account": "123456789012",
  "time": "2020-11-10T23:41:44Z",
  "region": "eu-west-1",
  "resources": [
    "arn:aws:geo:eu-west-1:0123456789101:geofence-collection/GeofenceEvents-GeofenceCollection_EXAMPLE",
    "arn:aws:geo:eu-west-1:0123456789101:tracker/Tracker_EXAMPLE"
  ],
  "detail": {
    "EventType": "EXIT",
    "GeofenceId": "polygon_10",
    "DeviceId": "Device1-EXAMPLE",
    "SampleTime": "2020-11-10T23:41:43.826Z",
    "Position": [
      -123.08569321875426,
      49.23766166742559
    ],
    "Accuracy": {
      "Horizontal": 15.3
    },
    "GeofenceProperties": {
      "ExampleKey1": "ExampleField1",
      "ExampleKey2": "ExampleField2"
    },
    "PositionProperties": {
      "ExampleKey1": "ExampleField1",
      "ExampleKey2": "ExampleField2"
    }
  }
}
```

The following is an example of an event for a position update, initiated by calling `BatchUpdateDevicePosition`.

```
{
  "version": "0",
  "id": "aa11aa22-33a-4a4a-aaa5-example",
  "detail-type": "Location Device Position Event",
  "source": "aws.geo",
  "account": "123456789012",
  "time": "2020-11-10T23:41:44Z",
  "region": "eu-west-1",
  "resources": [
    "arn:aws:geo:eu-west-1:0123456789101:tracker/Tracker_EXAMPLE"
  ],
  "detail": {
    "EventType": "UPDATE",
    "TrackerName": "tracker_2",
    "DeviceId": "Device1-EXAMPLE",
    "SampleTime": "2020-11-10T23:41:43.826Z",
    "ReceivedTime": "2020-11-10T23:41:39.235Z",
    "Position": [
      -123.08569321875426,
      49.23766166742559
    ],
    "Accuracy": {
      "Horizontal": 15.3
    },
    "PositionProperties": {
      "ExampleKey1": "ExampleField1",
      "ExampleKey2": "ExampleField2"
    }
  }
}
```

# Manage your geofence collection resources
<a name="managing-geofence-collections"></a>

Manage your geofence collections using the Amazon Location console, the AWS CLI, or the Amazon Location APIs.

## List your geofence collection resources
<a name="viewing-geofence-collections"></a>

You can view your geofence collection list using the Amazon Location console, the AWS CLI, or the Amazon Location APIs:

------
#### [ Console ]

**To view a list of geofence collections using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. View a list of your geofence collections under **My geofence collections**.

------
#### [ API ]

Use the `[ListGeofenceCollections](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_ListGeofenceCollections.html)` operation from the Amazon Location Geofences APIs. 

The following example is an API request to get a list of geofence collections in the AWS account. 

```
POST /geofencing/v0/list-collections
```

The following is an example response for `ListGeofenceCollections`:

```
{
    "Entries": [ 
    { 
        "CollectionName": "ExampleCollection",
        "CreateTime": 2020-09-30T22:59:34.142Z,
        "Description": "string",
        "UpdateTime": 2020-09-30T23:59:34.142Z
    },
    "NextToken": "1234-5678-9012"
}
```

------
#### [ CLI ]

Use the `[list-geofence-collections](https://docs.aws.amazon.com/cli/latest/reference/location/list-geofence-collections.html)` command.

The following example is an AWS CLI to get a list of geofence collections in the AWS account. 

```
aws location list-geofence-collections
```

------

## Get geofence collection details
<a name="get-geofence-collection-details"></a>

You can get details about any geofence collection resource in your AWS account using the Amazon Location console, the AWS CLI, or the Amazon Location APIs:

------
#### [ Console ]

**To view the details of a geofence collection using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. Under **My geofence collections**, select the name link of the target geofence collection. 

------
#### [ API ]

Use the `[DescribeGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_DescribeGeofenceCollection.html)` operation from the Amazon Location Geofences APIs. 

The following example is an API request to get the geofence collection details for *ExampleCollection*.

```
GET /geofencing/v0/collections/ExampleCollection
```

The following is an example response for `DescribeGeofenceCollection`:

```
{
    "CollectionArn": "arn:aws:geo:us-west-2:123456789012:geofence-collection/GeofenceCollection",
    "CollectionName": "ExampleCollection",
    "CreateTime": 2020-09-30T22:59:34.142Z,
    "Description": "string",
    "KmsKeyId": "1234abcd-12ab-34cd-56ef-1234567890ab",
    "Tags": { 
        "Tag1" : "Value1"
    },
    "UpdateTime": 2020-09-30T23:59:34.142Z
}
```

------
#### [ CLI ]

Use the `[describe-geofence-collection](https://docs.aws.amazon.com/cli/latest/reference/location/describe-geofence-collection.html)` command.

The following example is an AWS CLI to get the geofence collection details for *ExampleCollection*.

```
aws location describe-geofence-collection \
    --collection-name "ExampleCollection"
```

------

## Delete a geofence collection
<a name="delete-geofence-collection"></a>

You can delete a geofence collection from your AWS account using the Amazon Location console, the AWS CLI, or the Amazon Location APIs.

------
#### [ Console ]

**To delete a geofence collection using the Amazon Location console**

**Warning**  
This operation deletes the resource permanently.

 

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. Under **My geofence collection**, select the target geofence collection.

1. Choose **Delete geofence collection**.

------
#### [ API ]

Use the `[DeleteGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_DeleteGeofenceCollection.html)` operation from the Amazon Location APIs. 

The following example is an API request to delete the geofence collection *ExampleCollection*.

```
DELETE /geofencing/v0/collections/ExampleCollection
```

The following is an example response for `DeleteGeofenceCollection`:

```
HTTP/1.1 200
```

------
#### [ CLI ]

Use the `[delete-geofence-collection](https://docs.aws.amazon.com/cli/latest/reference/location/delete-geofence-collection.html)` command.

The following example is an AWS CLI command to delete the geofence collection *ExampleCollection*.

```
aws location delete-geofence-collection \
    --collection-name "ExampleCollection"
```

------

## List stored geofences
<a name="viewing-geofences"></a>

You can list geofences stored in a specified geofence collection using the Amazon Location console, the AWS CLI, or the Amazon Location APIs.

------
#### [ Console ]

**To view a list of geofences using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. Under **My geofence collection**, select the name link of the target geofence collection.

1. View geofences in the geofence collection under **Geofences**

------
#### [ API ]

Use the `[ListGeofences](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_ListGeofences.html)` operation from the Amazon Location Geofences APIs. 

The following example is an API request to get a list of geofences stored in the geofence collection *ExampleCollection*. 

```
POST /geofencing/v0/collections/ExampleCollection/list-geofences
```

The following is an example response for `ListGeofences`:

```
{
   "Entries": [ 
      { 
         "CreateTime": 2020-09-30T22:59:34.142Z,
         "GeofenceId": "geofence-1",
         "Geometry": { 
             "Polygon": [            
                 [-5.716667, -15.933333,
                 [-14.416667, -7.933333],
                 [-12.316667, -37.066667],
                 [-5.716667, -15.933333]
             ]
         },
         "Status": "ACTIVE",
         "UpdateTime": 2020-09-30T23:59:34.142Z
      }
   ],
   "NextToken": "1234-5678-9012"
}
```

------
#### [ CLI ]

Use the `[list-geofences](https://docs.aws.amazon.com/cli/latest/reference/location/list-geofences.html)` command.

The following example is an AWS CLI to get a list of geofences stored in the geofence collection *ExampleCollection*. 

```
aws location list-geofences \
    --collection-name "ExampleCollection"
```

------

## Get geofence details
<a name="get-geofence-details"></a>

You can get the details of a specific geofence, such as the create time, update time, geometry, and status, from a geofence collection using the Amazon Location console, AWS CLI, or the Amazon Location APIs.

------
#### [ Console ]

**To view the status of a geofence using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. Under **My geofence collection**, select the name link of the target geofence collection.

1. Under **Geofences**, you’ll be able to view the status of your geofences.

------
#### [ API ]

Use the `[GetGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_GetGeofence.html)` operation from the Amazon Location Geofences APIs. 

The following example is an API request to get the geofence details from a geofence collection *ExampleCollection*.

```
GET /geofencing/v0/collections/ExampleCollection/geofences/ExampleGeofence1
```

The following is an example response for `GetGeofence`:

```
{
   "CreateTime": 2020-09-30T22:59:34.142Z,
   "GeofenceId": "ExampleGeofence1",
   "Geometry": { 
      "Polygon": [            
          [-1,-1],
          [1,-1],
          [0,1],
          [-1,-1] 
      ]
   },
   "Status": "ACTIVE",
   "UpdateTime": 2020-09-30T23:59:34.142Z
}
```

------
#### [ CLI ]

Use the `[get-geofence](https://docs.aws.amazon.com/cli/latest/reference/location/get-geofence.html)` command.

The following example is an AWS CLI to get the geofence collection details for *ExampleCollection*.

```
aws location get-geofence \
    --collection-name "ExampleCollection" \
    --geofence-id "ExampleGeofence1"
```

------

## Delete geofences
<a name="delete-geofence"></a>

You can delete geofences from a geofence collection using the Amazon Location console, the AWS CLI, or the Amazon Location APIs.

------
#### [ Console ]

**To delete a geofence using the Amazon Location console**

**Warning**  
This operation deletes the resource permanently. 

 

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Geofence collections** from the left navigation pane.

1. Under **My geofence collection**, select the name link of the target geofence collection.

1. Under **Geofences**, select the target geofence.

1. Choose **Delete geofence**.

------
#### [ API ]

Use the `[BatchDeleteGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchDeleteGeofence.html)` operation from the Amazon Location Geofences APIs. 

The following example is an API request to delete geofences from the geofence collection *ExampleCollection*.

```
POST /geofencing/v0/collections/ExampleCollection/delete-geofences
Content-type: application/json

{
   "GeofenceIds": [ "ExampleGeofence11" ]
}
```

The following is an example success response for `[BatchDeleteGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchDeleteGeofence.html)`. 

```
HTTP/1.1 200
```

------
#### [ CLI ]

Use the `[batch-delete-geofence](https://docs.aws.amazon.com/cli/latest/reference/location/batch-delete-geofence.html)` command.

The following example is an AWS CLI command to delete geofences from the geofence collection *ExampleCollection*.

```
aws location batch-delete-geofence \
    --collection-name "ExampleCollection" \
    --geofence-ids "ExampleGeofence11"
```

------

# Manage costs and usage
<a name="geofence-whats-next"></a>

As you continue learning about Amazon Location Geofences, it's important to understand how to manage service capacity, ensure you follow usage limits, and get the best results through quota and API optimizations. By applying best practices for performance and accuracy, you can tailor your application to handle place-related queries efficiently and maximize your API requests.

**Topics**
+ [Geofences pricing](geofence-price.md)
+ [Geofences quotas and usage](geofence-quotas.md)

# Geofences pricing
<a name="geofence-price"></a>

For pricing information for tracking and geofencing APIs, see the [Amazon Location Service pricing page](https://aws.amazon.com/location/pricing/). 

**Position Evaluation**

You can use `BatchEvaluateGeofences` to evaluate device positions against the geofence geometries from a given geofence collection. One request will evaluate up to ten device positions against all geofences in a single geofence collection. Price is based on the number of device positions in your API requests. Unit price per device position evaluated is based on the total monthly usage volume. See the [Amazon Location Service pricing page](https://aws.amazon.com/location/pricing/) for details on unit price and volume tiers.

You can optimize your Position Evaluation cost by configuring the device position update frequency (also known as ping rate) from your tracking devices, and leveraging the filtering feature on Trackers to only evaluate relevant position updates.

**Geofence Management and Storage**

You can use `GetGeofence`, `PutGeofence`, `BatchPutGeofence`, and `BatchDeleteGeofence` to manage your geofences in a geofence collection. The price for these APIs is based on the number of geofences in your API requests. 

The storage for geofences will be charged monthly (only for geofences you store for more than one month). You can also manage your Geofence Collection using the following APIs: `CreateGeofenceCollection`, `DeleteGeofenceCollection`, `DescribeGeofenceCollection`, `ListGeofenceCollections`, `UpdateGeofenceCollection`, and `ListGeofences`. The price for these APIs is based on the number of API requests.

**Geofence Event Forecast**

You can use `ForecastGeofenceEvents` to forecast future geofence events that are likely to occur within a specified time horizon if a device continues moving at its current speed. The price is based on number of API requests. 

# Geofences quotas and usage
<a name="geofence-quotas"></a>

This topic provides a summary of rate limits and quotas for Amazon Location Service Geofences.

**Note**  
If you require a higher quota, you can use the Service Quotas console to [request quota increases](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) for adjustable quotas. When requesting a quota increase, select the Region you require the quota increase in, since most quotas are specific to the AWS Region. You can request up to twice the default limit for each API.  
For requests that exceed twice the default limit, your request will submit a support ticket. You can also connect to your premium support team. There are no direct charges for quota increase requests, but higher usage levels may lead to increased service costs based on the additional resources consumed. See [Manage quotas with Service Quotas](manage-quotas.md) for more information.

Service Quotas are maximum number of resources you can have per AWS account and AWS Region. Amazon Location Service denies additional requests that exceed the service quota. 

## Resources
<a name="geofence-quota-resources"></a>


| API name | Default | Max adjustable limit | 
| --- | --- | --- | 
|  Collection resources per account  |  1500  |  3000 If you need more than this, [request quota increases](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact the support team.  | 
|  Geofences per collection  |  50000  |  Contact the support team.  | 

## CRUD API
<a name="geofence-quota-crud"></a>

**Note**  
If you need a higher limit for any of these APIs, [request quota increases](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact the support team.


| API name | Default | Max adjustable limit | 
| --- | --- | --- | 
|  [CreateGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_CreateGeofenceCollection.html)  |  10  |  20  | 
|  [DeleteGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_DeleteGeofenceCollection.html)  |  10  |  20  | 
|  [DescribeGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_DescribeGeofenceCollection.html)  |  10  |  20  | 
|  [ListGeofenceCollections](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_ListGeofenceCollections.html)  |  10  |  20  | 
|  [UpdateGeofenceCollection](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_UpdateGeofenceCollection.html)  |  10  |  20  | 

## Data API
<a name="geofence-quota-data"></a>

**Note**  
If you need a higher limit for any of these APIs, [request quota increases](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas) or contact the support team.


| API name | Default | Max adjustable limit | 
| --- | --- | --- | 
|  [BatchEvaluateGeofences](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchEvaluateGeofences.html)  |  50  |  100  | 
|  [PutGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_PutGeofence.html)  |  50  |  100  | 
|  [BatchPutGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchPutGeofence.html)  |  50  |  100  | 
|  [ListGeofences](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_ListGeofences.html)  |  50  |  100  | 
|  [GetGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_GetGeofence.html)  |  50  |  100  | 
|  [BatchDeleteGeofence](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointGeofencing_BatchDeleteGeofence.html)  |  50  |  100  | 

## Other usage limits
<a name="geofence-quota-other"></a>

