fencemaker
HomePricingUse CasesMigrate from RadarLive DemoQuickstartIntegrate with Android/iOS NEWPrompts for AI NEWMCP NEWDocsOperations Portal
Fencemaker API

Territory-based lead assignment

Multi-territory lookup. Given one lat/lon, find which territory polygon(s) contain it, then map territory → owner.

1

Create Fencemaker account, get API key

Free tier: 1,000 lookups/day. Growth plan covers 35,000 lookups/day for high-volume routing.

2

Define one territory per rep/region

Create multiple territories (one per rep/region):
• Bulk import: Upload a .geojson FeatureCollection with all territories at once (fastest for 10+ zones)
• Dashboard: Draw each region manually if you have <5 territories
• API: POST /api/v1/territories in a loop for programmatic creation from your CRM's territory definitions

Store the mapping in your DB: territory-uuid → rep_id.
The /pip?multi=true response returns territory objects with id, name, code — you look up who owns each.

3

On new lead: geocode → call /pip?multi=true

GET /api/v1/pip?lat={lat}&lon={lon}&multi=true returns ALL matching territories (handles overlapping regions).

4

Map territory → owner, create assignment

Store territory_id → rep_id mapping in your DB. Use first match or priority rules for overlaps.

// Lead arrives: "123 Main St, Austin, TX"
const { lat, lon } = await geocode(leadAddress);

// Find which territory polygon(s) contain this location
const res = await fetch(
  `https://fencemaker.app/api/v1/pip?lat=${lat}&lon=${lon}&multi=true`,
  { headers: { 'X-API-Key': 'YOUR_KEY' } }
);
const data = await res.json();
// data.territories → [{ id: 'uuid-alice', name: 'East Zone', code: 'ZONE-A' }, ...]

// Map territory_id → rep_id from your database
const territoryMap = {
  'uuid-alice': 'rep_alice',
  'uuid-bob':   'rep_bob'
};

const assignedRep = territoryMap[data.territories[0]?.id]; // or apply priority rules

// Create task assignment
await createTask(assignedRep, {
  type: 'sales_lead',
  address: leadAddress,
  coordinates: { lat, lon }
});

Watch out:

A point can fall inside multiple territories (overlapping regions). GET /api/v1/pip?multi=true returns ALL matches as an array of territory objects. You decide the tiebreaker — first match, priority rank, load balancing, or split assignment. Don't assume a single result.