AirTags Geofencing API | Create Virtual Boundaries for AirTags

Comprehensive guide to implementing geofencing with AirTags. Learn how to set up virtual boundaries, receive notifications, and integrate geofence alerts into your applications with the AirPinpoint API.


Business Feature: AirTags geofencing capabilities are fully available for all business users. Updated: 2024-01-09 - Added support for multiple airtags and devices in a single geofence.

AirTags Geofencing: Complete Implementation Guide

Geofencing allows you to create virtual boundaries around geographical areas and receive notifications when your AirTags enter or exit these boundaries. This powerful feature enables businesses to automate location-based actions, enhance security, and improve operational efficiency.

What is AirTags Geofencing?

AirTags geofencing creates invisible boundaries around physical locations. When an AirTag crosses these boundaries, the AirPinpoint platform detects this transition and can:

  • Send real-time notifications to your application
  • Trigger webhook events for automated workflows
  • Log entry and exit events for auditing and analytics

Geofence notifications are intelligently managed to prevent notification fatigue, with triggers limited to once every 30 minutes per device.

Key Benefits of AirTags Geofencing

  • Asset Security: Get alerts when valuable assets leave designated areas
  • Logistics Optimization: Automate warehouse and delivery workflows
  • Inventory Management: Track when items move between storage locations
  • Compliance Monitoring: Ensure equipment stays within approved zones
  • Customer Experience: Enable location-based services and notifications

Geofencing API Endpoints

List Geofences

Retrieve a list of all geofences configured for your AirTags.

Endpoint

GET /v1/geofences

Query Parameters

  • skip: Number of items to skip (for pagination, default: 0)
  • limit: Maximum number of items to return (1-100, default: 20)
  • trackable_id: Optional ID to filter geofences for a specific AirTag

Example Request

curl -X GET "https://api.airpinpoint.com/v1/geofences?limit=20&trackable_id=tag_123456" \
     -H "Authorization: Bearer YOUR_API_KEY"

Example Response

[
  {
    "id": "geofence_789012",
    "name": "Home",
    "authUserId": "user_123",
    "latitude": 37.7749,
    "longitude": -122.4194,
    "radius": 100,
    "createdAt": "2023-06-15T17:00:00Z",
    "updatedAt": "2023-06-15T17:00:00Z",
    "trackableId": ["tag_123456", "tag_789012"],
  }
]

Create a Geofence for AirTags

Create a new geofence for multiple AirTags or other trackable devices of the same type.

Endpoint

POST /v1/geofences

Request Body

{
  name: string;              // Descriptive name for the geofence
  latitude: number;          // Center latitude of the geofence
  longitude: number;         // Center longitude of the geofence
  radius: number;            // Radius in meters (10-5000)
  trackableId: string[];     // Array of AirTag IDs to monitor
  notifyType?: string;       // Optional: "enter", "exit", or "both" (default: "both")
  notifyDestination?: string;  // Optional: Email or webhook URL for notifications
}

Example Request

curl -X POST "https://api.airpinpoint.com/v1/geofences" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "name": "Warehouse Zone A",
       "latitude": 37.7749,
       "longitude": -122.4194,
       "radius": 100,
       "trackableId": ["tag_123456", "tag_789012"],
       "notifyType": "both",
       "notifyDestination": "https://yourapp.com/webhooks/geofence"
     }'

Example Response

{
  "id": "geofence_789012",
  "name": "Warehouse Zone A",
  "authUserId": "user_123",
  "latitude": 37.7749,
  "longitude": -122.4194,
  "radius": 100,
  "createdAt": "2023-06-15T17:00:00Z",
  "updatedAt": "2023-06-15T17:00:00Z",
  "trackableId": ["tag_123456", "tag_789012"],
  "notifyType": "both",
  "notifyDestination": "https://yourapp.com/webhooks/geofence"
}

Delete a Geofence

Remove a geofence when it's no longer needed.

Endpoint

DELETE /v1/geofences/{geofence_id}

Example Request

curl -X DELETE "https://api.airpinpoint.com/v1/geofences/geofence_789012" \
     -H "Authorization: Bearer YOUR_API_KEY"

Example Response

{
  "message": "Geofence deleted successfully"
}

Geofence Notification Webhooks

When an AirTag enters or exits a geofence, AirPinpoint can send a webhook notification to your application. This enables real-time reactions to location changes.

Webhook Payload Format

{
  "event": "geofence_triggered",
  "geofenceId": "geofence_789012",
  "geofenceName": "Warehouse Zone A",
  "trackableId": "tag_123456",
  "trackableName": "Forklift #3",
  "action": "enter", // or "exit"
  "timestamp": "2023-06-15T17:30:00Z",
  "location": {
    "latitude": 37.7752,
    "longitude": -122.4192,
    "accuracy": 10
  }
}

Setting Up Webhook Handlers

Create an endpoint in your application to receive these notifications:

// Example Express.js webhook handler
app.post('/webhooks/geofence', (req, res) => {
  const { event, geofenceName, trackableName, action, timestamp } = req.body;
  
  console.log(`${trackableName} ${action}ed ${geofenceName} at ${timestamp}`);
  
  // Trigger your business logic here
  if (action === 'enter') {
    // Handle entry event
    notifyWarehouseManager(trackableName, geofenceName);
  } else if (action === 'exit') {
    // Handle exit event
    logDeviceExit(trackableName, geofenceName, timestamp);
  }
  
  res.status(200).send('Webhook received');
});

Real-World AirTags Geofencing Use Cases

Retail Inventory Management

Create geofences around stockrooms, sales floors, and loading docks to track the movement of high-value inventory tagged with AirTags. Get notifications when items move between zones unexpectedly.

Construction Equipment Tracking

Set up geofences around construction sites to ensure valuable equipment stays on-site. Receive alerts if tools or machinery leave the designated area after hours.

Fleet Management

Monitor vehicle movements by attaching AirTags to delivery vehicles or service trucks. Create geofences around service areas, customer locations, and company facilities to optimize routing and track compliance.

Event Management

Attach AirTags to valuable equipment at events and create geofences around the venue. Get notified if equipment moves outside designated areas, preventing loss and theft.

Best Practices for AirTags Geofencing

  1. Appropriate Radius Size: Set geofence radii appropriate to your use case. Smaller radii (10-50m) work well for precise indoor tracking, while larger radii (100-1000m) are better for general area monitoring.

  2. Battery Considerations: More frequent geofence checks will consume more battery. The AirPinpoint platform balances accuracy and battery life.

  3. Notification Management: Use the notifyType parameter to control when you receive alerts, reducing notification fatigue.

  4. Logical Grouping: Group related AirTags within the same geofence for more efficient management.

  5. Location Accuracy: Remember that AirTag location accuracy varies based on the environment. In dense urban areas with many Apple devices, accuracy is higher.

Limitations and Considerations

  • Geofences require a minimum radius of 10 meters
  • Maximum radius is limited to 5000 meters (5 km)
  • All trackables in a geofence must be of the same type (airtag, device, or beacon)
  • A trackable must have location data available before it can be added to a geofence
  • Each account has a default limit of 100 geofences (contact support for higher limits)
  • Multiple trackables can be added to a single geofence

Advanced AirTags Geofencing

For enterprise users, advanced geofencing features are available:

  • Polygon Geofences: Create custom-shaped geofences beyond simple circles
  • Time-based Geofences: Activate geofences only during specific hours or days
  • Nested Geofences: Create hierarchical geofences for complex environments
  • Analytics Dashboard: View historical geofence activity and trends

Contact our sales team to learn more about these enterprise capabilities.