# Maps Branch Exception Escalation Audit (`practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit`) Actor

Reconcile an existing places export with your branch maintenance roster and list missing records, duplicate identifiers and stale review dates by owner.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** Lead generation, SEO tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 audit completeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Maps Branch Exception Escalation Audit

Reconcile a places export you already hold with your internal branch maintenance roster. The Actor lists the gaps as owner-actionable exceptions:

- **missing_branch_record**: a roster branch has no record in the places data.
- **duplicate_identifier**: the same place identifier repeats in the places data, or a branch/place identifier repeats in the roster.
- **stale_review_date**: the newest review for a matched branch is older than your threshold.
- **missing_review_date**: a matched branch has no usable review date.
- **ambiguous_branch_match**: a name-based match points to several different places.
- **unrostered_place** (optional): a place has no roster branch.

Each exception carries a severity, an escalation tier (`owner_review` or `escalate_now`), the owner and escalation labels from your roster, and a plain-language recommended action.

### What it does not do

- It does not scrape or visit Google Maps or any other website. It runs offline on the rows you paste into the input.
- It does not contact, notify, or publish anything. Owner and escalation values are only labels in the output.
- It does not verify that a branch is open or that review data is correct.

Use it only with data you are authorized to process.

### Input

| Field | Description |
| --- | --- |
| `places` | Array of place rows. Recognised fields: `placeId`, `title`, `postalCode`, `city`, `lastReviewDate`. |
| `roster` | Array of roster rows. Recognised fields: `branchId`, `placeId`, `branchName`, `postalCode`, `city`, `owner`, `escalateTo`. |
| `staleDays` | Review age limit in days (default 180). |
| `escalationGraceDays` | Days beyond the limit before a stale branch becomes `escalate_now` (default 90). |
| `referenceDate` | `YYYY-MM-DD` used to compute age. Empty means today. Set it for reproducible reports. |
| `defaultOwner` | Label for exceptions without a roster owner. |
| `includeUnrosteredPlaces` | Report places missing from the roster (default true). |
| `placeFieldMap`, `rosterFieldMap` | Rename columns, e.g. `{"id": "google_id"}`. |

#### Sample input

```json
{
  "places": [
    {"placeId": "SAMPLE-PLACE-001", "title": "Example Fixtures Harbor", "postalCode": "10001", "city": "Harborview", "lastReviewDate": "2026-10-20"},
    {"placeId": "SAMPLE-PLACE-002", "title": "Example Fixtures Riverside", "postalCode": "10002", "city": "Harborview", "lastReviewDate": "2025-12-15"},
    {"placeId": "SAMPLE-PLACE-003", "title": "Example Fixtures Uptown", "postalCode": "10003", "city": "Harborview", "lastReviewDate": "2026-03-01"},
    {"placeId": "SAMPLE-PLACE-003", "title": "Example Fixtures Uptown", "postalCode": "10003", "city": "Harborview", "lastReviewDate": "2026-02-01"}
  ],
  "roster": [
    {"branchId": "BR-001", "placeId": "SAMPLE-PLACE-001", "owner": "Facilities North", "escalateTo": "Regional Operations"},
    {"branchId": "BR-002", "placeId": "SAMPLE-PLACE-002", "owner": "Facilities South", "escalateTo": "Regional Operations"},
    {"branchId": "BR-003", "placeId": "SAMPLE-PLACE-003", "owner": "Facilities North", "escalateTo": "Regional Operations"},
    {"branchId": "BR-004", "placeId": "SAMPLE-PLACE-004", "owner": "Facilities West", "escalateTo": "Regional Operations"}
  ],
  "staleDays": 180,
  "escalationGraceDays": 90,
  "referenceDate": "2026-11-01"
}
```

### Output

- **Dataset**: one item per exception (`exceptionId`, `type`, `severity`, `escalationTier`, `owner`, `escalateTo`, `branchId`, `placeId`, `branchName`, `summary`, `recommendedAction`, `details`). Items are sorted by severity, then type. IDs are stable for the same input.
- **Key-value store `SUMMARY`**: counts by type, severity, tier and owner, match rate, thresholds, notes and limitations.

If everything reconciles, the dataset is empty and `SUMMARY` says so.

### Matching rules

1. If a roster row has `placeId`, it matches places with that exact identifier. No name fallback is used when an identifier is given.
2. Otherwise it matches on normalised branch name plus postal code, then plus city. Several different candidates produce `ambiguous_branch_match`.

### Limitations and sample-size caveats

- Results are only as good as the supplied rows. Missing identifiers or inconsistent names reduce match quality.
- Name-based matching is heuristic; check those matches before acting.
- A review date shows listing recency, not branch maintenance quality.
- With fewer than 30 roster rows, percentages in `SUMMARY` are indicative only; the Actor adds a note when this applies.
- Limits: 50,000 place rows and 20,000 roster rows per run, and the Apify input size cap applies to inline input.
- A broad market of Maps data users does not prove demand for this specific audit.

### Pricing

The code defines one pricing event, `audit-completed`, charged once after a successful run. Failed runs and rejected input are never charged. No payable plan is configured in this project.

### Local tests

The tests are offline and use only the standard library:

```
python -m unittest discover -s tests -t .
```

# Actor input Schema

## `places` (type: `array`):

Rows from a places export you are authorized to use. Recognised fields: placeId, title, postalCode, city, lastReviewDate (YYYY-MM-DD). Use the field maps below for other column names.

## `roster` (type: `array`):

One row per branch. Recognised fields: branchId, placeId, branchName, postalCode, city, owner (team or role label), escalateTo (team or role label). Use team labels, not personal contact details.

## `staleDays` (type: `integer`):

A matched branch is flagged when its newest review is older than this many days.

## `escalationGraceDays` (type: `integer`):

Stale branches that exceed the threshold by at least this many days move to the escalate_now tier.

## `referenceDate` (type: `string`):

Date used to compute review age (YYYY-MM-DD). Leave empty to use today's date. Set it to make a report reproducible.

## `defaultOwner` (type: `string`):

Owner label for exceptions without a roster owner, such as unrostered places.

## `includeUnrosteredPlaces` (type: `boolean`):

Add low-severity exceptions for place records that match no roster branch.

## `placeFieldMap` (type: `object`):

Override column names, for example {"id": "google_id", "review": "last_seen_review"}. Keys: id, name, postal, city, review.

## `rosterFieldMap` (type: `object`):

Override column names, for example {"branch": "store_code"}. Keys: branch, place, name, postal, city, owner, escalate.

## Actor input object example

```json
{
  "places": [
    {
      "placeId": "SAMPLE-PLACE-001",
      "title": "Example Fixtures Harbor",
      "postalCode": "10001",
      "city": "Harborview",
      "lastReviewDate": "2026-10-20"
    },
    {
      "placeId": "SAMPLE-PLACE-002",
      "title": "Example Fixtures Riverside",
      "postalCode": "10002",
      "city": "Harborview",
      "lastReviewDate": "2025-12-15"
    },
    {
      "placeId": "SAMPLE-PLACE-003",
      "title": "Example Fixtures Uptown",
      "postalCode": "10003",
      "city": "Harborview",
      "lastReviewDate": "2026-03-01"
    },
    {
      "placeId": "SAMPLE-PLACE-003",
      "title": "Example Fixtures Uptown",
      "postalCode": "10003",
      "city": "Harborview",
      "lastReviewDate": "2026-02-01"
    },
    {
      "placeId": "SAMPLE-PLACE-005",
      "title": "Example Fixtures Lakeside",
      "postalCode": "10005",
      "city": "Harborview"
    },
    {
      "placeId": "SAMPLE-PLACE-009",
      "title": "Example Fixtures Airport",
      "postalCode": "10009",
      "city": "Harborview",
      "lastReviewDate": "2026-09-01"
    }
  ],
  "roster": [
    {
      "branchId": "BR-001",
      "placeId": "SAMPLE-PLACE-001",
      "owner": "Facilities North",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-002",
      "placeId": "SAMPLE-PLACE-002",
      "owner": "Facilities South",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-003",
      "placeId": "SAMPLE-PLACE-003",
      "owner": "Facilities North",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-004",
      "placeId": "SAMPLE-PLACE-004",
      "owner": "Facilities West",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-005",
      "placeId": "SAMPLE-PLACE-005",
      "owner": "Facilities South",
      "escalateTo": "Regional Operations"
    }
  ],
  "staleDays": 180,
  "escalationGraceDays": 90,
  "referenceDate": "2026-11-01",
  "defaultOwner": "unassigned",
  "includeUnrosteredPlaces": true
}
```

# Actor output Schema

## `results` (type: `string`):

Download rows from the latest run in JSON/CSV.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "places": [
        {
            "placeId": "SAMPLE-PLACE-001",
            "title": "Example Fixtures Harbor",
            "postalCode": "10001",
            "city": "Harborview",
            "lastReviewDate": "2026-10-20"
        },
        {
            "placeId": "SAMPLE-PLACE-002",
            "title": "Example Fixtures Riverside",
            "postalCode": "10002",
            "city": "Harborview",
            "lastReviewDate": "2025-12-15"
        },
        {
            "placeId": "SAMPLE-PLACE-003",
            "title": "Example Fixtures Uptown",
            "postalCode": "10003",
            "city": "Harborview",
            "lastReviewDate": "2026-03-01"
        },
        {
            "placeId": "SAMPLE-PLACE-003",
            "title": "Example Fixtures Uptown",
            "postalCode": "10003",
            "city": "Harborview",
            "lastReviewDate": "2026-02-01"
        },
        {
            "placeId": "SAMPLE-PLACE-005",
            "title": "Example Fixtures Lakeside",
            "postalCode": "10005",
            "city": "Harborview"
        },
        {
            "placeId": "SAMPLE-PLACE-009",
            "title": "Example Fixtures Airport",
            "postalCode": "10009",
            "city": "Harborview",
            "lastReviewDate": "2026-09-01"
        }
    ],
    "roster": [
        {
            "branchId": "BR-001",
            "placeId": "SAMPLE-PLACE-001",
            "owner": "Facilities North",
            "escalateTo": "Regional Operations"
        },
        {
            "branchId": "BR-002",
            "placeId": "SAMPLE-PLACE-002",
            "owner": "Facilities South",
            "escalateTo": "Regional Operations"
        },
        {
            "branchId": "BR-003",
            "placeId": "SAMPLE-PLACE-003",
            "owner": "Facilities North",
            "escalateTo": "Regional Operations"
        },
        {
            "branchId": "BR-004",
            "placeId": "SAMPLE-PLACE-004",
            "owner": "Facilities West",
            "escalateTo": "Regional Operations"
        },
        {
            "branchId": "BR-005",
            "placeId": "SAMPLE-PLACE-005",
            "owner": "Facilities South",
            "escalateTo": "Regional Operations"
        }
    ],
    "referenceDate": "2026-11-01"
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "places": [
        {
            "placeId": "SAMPLE-PLACE-001",
            "title": "Example Fixtures Harbor",
            "postalCode": "10001",
            "city": "Harborview",
            "lastReviewDate": "2026-10-20",
        },
        {
            "placeId": "SAMPLE-PLACE-002",
            "title": "Example Fixtures Riverside",
            "postalCode": "10002",
            "city": "Harborview",
            "lastReviewDate": "2025-12-15",
        },
        {
            "placeId": "SAMPLE-PLACE-003",
            "title": "Example Fixtures Uptown",
            "postalCode": "10003",
            "city": "Harborview",
            "lastReviewDate": "2026-03-01",
        },
        {
            "placeId": "SAMPLE-PLACE-003",
            "title": "Example Fixtures Uptown",
            "postalCode": "10003",
            "city": "Harborview",
            "lastReviewDate": "2026-02-01",
        },
        {
            "placeId": "SAMPLE-PLACE-005",
            "title": "Example Fixtures Lakeside",
            "postalCode": "10005",
            "city": "Harborview",
        },
        {
            "placeId": "SAMPLE-PLACE-009",
            "title": "Example Fixtures Airport",
            "postalCode": "10009",
            "city": "Harborview",
            "lastReviewDate": "2026-09-01",
        },
    ],
    "roster": [
        {
            "branchId": "BR-001",
            "placeId": "SAMPLE-PLACE-001",
            "owner": "Facilities North",
            "escalateTo": "Regional Operations",
        },
        {
            "branchId": "BR-002",
            "placeId": "SAMPLE-PLACE-002",
            "owner": "Facilities South",
            "escalateTo": "Regional Operations",
        },
        {
            "branchId": "BR-003",
            "placeId": "SAMPLE-PLACE-003",
            "owner": "Facilities North",
            "escalateTo": "Regional Operations",
        },
        {
            "branchId": "BR-004",
            "placeId": "SAMPLE-PLACE-004",
            "owner": "Facilities West",
            "escalateTo": "Regional Operations",
        },
        {
            "branchId": "BR-005",
            "placeId": "SAMPLE-PLACE-005",
            "owner": "Facilities South",
            "escalateTo": "Regional Operations",
        },
    ],
    "referenceDate": "2026-11-01",
}

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "places": [
    {
      "placeId": "SAMPLE-PLACE-001",
      "title": "Example Fixtures Harbor",
      "postalCode": "10001",
      "city": "Harborview",
      "lastReviewDate": "2026-10-20"
    },
    {
      "placeId": "SAMPLE-PLACE-002",
      "title": "Example Fixtures Riverside",
      "postalCode": "10002",
      "city": "Harborview",
      "lastReviewDate": "2025-12-15"
    },
    {
      "placeId": "SAMPLE-PLACE-003",
      "title": "Example Fixtures Uptown",
      "postalCode": "10003",
      "city": "Harborview",
      "lastReviewDate": "2026-03-01"
    },
    {
      "placeId": "SAMPLE-PLACE-003",
      "title": "Example Fixtures Uptown",
      "postalCode": "10003",
      "city": "Harborview",
      "lastReviewDate": "2026-02-01"
    },
    {
      "placeId": "SAMPLE-PLACE-005",
      "title": "Example Fixtures Lakeside",
      "postalCode": "10005",
      "city": "Harborview"
    },
    {
      "placeId": "SAMPLE-PLACE-009",
      "title": "Example Fixtures Airport",
      "postalCode": "10009",
      "city": "Harborview",
      "lastReviewDate": "2026-09-01"
    }
  ],
  "roster": [
    {
      "branchId": "BR-001",
      "placeId": "SAMPLE-PLACE-001",
      "owner": "Facilities North",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-002",
      "placeId": "SAMPLE-PLACE-002",
      "owner": "Facilities South",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-003",
      "placeId": "SAMPLE-PLACE-003",
      "owner": "Facilities North",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-004",
      "placeId": "SAMPLE-PLACE-004",
      "owner": "Facilities West",
      "escalateTo": "Regional Operations"
    },
    {
      "branchId": "BR-005",
      "placeId": "SAMPLE-PLACE-005",
      "owner": "Facilities South",
      "escalateTo": "Regional Operations"
    }
  ],
  "referenceDate": "2026-11-01"
}' |
apify call practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-maps-branch-exception-escalation-audit"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/71Idfl36BI3IVCHsA/builds/Q6sPgIATubw7F1AwG/openapi.json
