Overview
The On Geofence Leave automation event triggers when a field worker’s GPS position leaves a geofence they had previously entered. The automation sends the crossing to an external HTTP endpoint, so an operations dashboard, WMS, or ERP can react the moment a worker departs a store, warehouse, customer site, or restricted area. It is the counterpart to On Geofence Entry and is configured the same way, on the same geofence group.Required permission:
- View Automation
- Create Automation
- View Geofence
Availability
Geofence is not generally available yet. It is enabled for MileApp internal staff and for pilot organizations that have been explicitly allowlisted. If your organization is not in the rollout, the geofence menus and the geofence API return 404 Not Found, and the On Geofence Leave option does not appear in the event dropdown. Contact MileApp support if you would like your organization included.Constraints
Two constraints apply to this event and are enforced by the API:- Webhook only.
Webhookis the only automation type accepted. Create Task, Create and Assign Task, Move Task, Assign Task, Update Task, Create or Update Data Source, and Notification are all rejected with400 Bad Request. - A geofence group is required. The automation is scoped to exactly one geofence group, chosen in the Geofence Group picker. Saving without one fails validation.
When Does This Event Trigger?
- The field worker’s mobile app reports a GPS position outside a geofence they were recorded as inside.
- MileApp checks whether the matching entry for that geofence was announced.
- If it was, the leave event fires and the webhook is sent. If it was not, nothing is sent.
Setting Up On Geofence Leave Automation
Step 1: Create the Geofence and Group
- Draw the geofences you want to watch and place them in a geofence group
- Set each geofence’s dwell time, this still governs whether the paired entry fires
- Make sure each geofence is active, inactive geofences are ignored
Step 2: Create the Automation
- Log in to the MileApp web portal
- Click Flow in the main navigation, then open the Automation tab
- Click New
- Automation Name: a descriptive name, for example “Notify WMS on store departure”
- Event: select On Geofence Leave
- Geofence Group: select the group to watch (required)
- Automation Type: Webhook (the only option for this event)
Step 3: Configure the Webhook
- URL: the endpoint that should receive the crossing. Required, and must be a valid URL
- Header (Optional): custom HTTP headers, for example
Authorization - Value (Optional): the matching header value
Step 4: Save and Activate
- Click Submit
- Confirm the automation toggle is Active
- Test by having a field worker enter one of the group’s geofences, stay past the dwell time, then leave
Webhook Payload
MileApp sends a POST request whose body is the location history record with the geofence details merged onto it. The shape is identical to On Geofence Entry apart fromeventName.
Geofence Fields
geofenceGroup is the group name meant for display; geofenceGroupId is the id used for matching. They are different fields, do not treat them as interchangeable.
Location Fields
Response
Your endpoint must return an HTTP 200 status code to acknowledge receipt:Tracking List Markers
When a geofence leave matches one of your automations, MileApp also writes a marker into the worker’s Tracking List slider so the crossing is visible in the web portal. The marker is written only when an automation matched. An organization with geofences drawn but no On Geofence Leave automation on that group sees no markers. A worker with no task on the selected day shows nothing in the slider at all, which is normal slider behaviour and not related to geofence.Monitoring and Troubleshooting
Viewing Automation Logs
- Go to Flow > Automation
- Find your automation in the list
- Click the clock history icon to view execution logs
- Review successful executions and errors
Common Issues
Issue: The leave event never fires Possible Causes:- The paired entry never fired, because the worker did not stay past the dwell time
- The automation is not Active
- The geofence belongs to a different group than the one selected on the automation
- The mobile app stopped reporting positions before the worker left the geofence
- Your organization is not in the geofence rollout
- Confirm you received the matching On Geofence Entry first, no entry means no leave
- Confirm the automation toggle is ON and the geofence is active
- Check that the geofence sits in the selected group
- Check that the app was reporting positions for the whole visit
- Incorrect webhook URL
- Authentication headers missing or incorrect
- The external endpoint is down or unreachable
- Verify the URL is reachable from the public internet
- Check the authentication credentials
- Review the automation logs for the response status and body
Related Documentation
Frequently Asked Questions
Q: Do I need a separate automation for entry and leave? A: Yes. Entry and leave are two events, so each needs its own automation. Both can point at the same geofence group and the same webhook URL, and you can tell them apart byeventName.
Q: Can one automation watch several geofence groups?
A: No. Each automation is scoped to exactly one group. Create one automation per group.
Q: Does the payload tell me how long the worker stayed inside?
A: No. dwellMinutes is the geofence’s configured threshold. To measure the visit, compare createdTime on the leave payload against createdTime on the matching entry payload.
Q: Can I use Create Task or Notification with this event?
A: No. Webhook is the only automation type accepted, and any other type is rejected with a 400 error.