# FMCSA SAFER Risk Event Monitor (`plym-actor-factory/fmcsa-safer-risk-event-monitor`) Actor

Watch a book of USDOT numbers and emit typed FMCSA risk events (insurance, OOS, safety rating, SMS BASIC alerts, authority, MCS-150 stale) from official public SAFER / census / Motus open data. Scheduled poll — not real-time. Pay only for unique delivered risk events.

- **URL**: https://apify.com/plym-actor-factory/fmcsa-safer-risk-event-monitor.md
- **Developed by:** [Daniel Witney](https://apify.com/plym-actor-factory) (community)
- **Categories:** Automation, AI, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $25.00 / 1,000 risk event delivereds

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

## FMCSA SAFER Risk Event Monitor

Watch a **book of USDOT numbers** and receive **typed risk events** when official FMCSA public data shows material changes — insurance filings, out-of-service (OOS), safety rating, SMS BASIC alerts (optional QCMobile), operating authority, and MCS-150 staleness — not another census dump and not an insurance/authority-only clone.

**Honest title:** this is a **scheduled poll / catch-up monitor**, not a real-time push feed. Detection latency ≈ your schedule interval + FMCSA open-data lag (often ~24h for Motus / census).

### Value proposition

- **Multi-signal** events: `INSURANCE_*`, `OOS_*`, `SAFETY_RATING_*`, `SMS_*`, `AUTHORITY_*`, `MCS150_*` — broader than insurance/authority-only Store ghosts.
- Official / public HTTP only (SAFER Company Snapshot, DOT census SODA, Motus InsHist / AuthHist / RevokeSuspend). Optional free QCMobile `webKey` for SMS BASICs. **No paid CarrierOK.**
- **Pay only for unique delivered risk events.** First observation stores a baseline (no charge). Quiet days ≈ $0.
- Durable KVS checkpoint + `event_uid` dedupe.

### PRODUCTION USE (required for real monitoring)

> **Store default ≠ product.** Schema defaults use `sourceMode=fixture` so Apify Store daily auto-tests leave a non-empty health dataset **without** calling FMCSA. That fixture path only writes a non-billable `RUN_STATUS` / `FIXTURE_HEALTH` row. It is **not** carrier monitoring.

For **production monitoring** you **must**:

1. Set **`sourceMode` = `live`**
2. Provide your `usdotNumbers` watchlist / book
3. Schedule short runs (e.g. daily or every few hours) with fair-use `requestPaceMs`
4. Optionally add secret **`fmcsaQcMobileWebKey`** for SMS BASIC enrichment ([QCMobile developer site](https://mobile.fmcsa.dot.gov/QCDevsite/docs/getStarted))

Official references:

- [SAFER Company Snapshot](https://safer.fmcsa.dot.gov/CompanySnapshot.aspx)
- [FMCSA Open Data / SMS Tools Downloads](https://ai.fmcsa.dot.gov/SMS/Tools/Downloads.aspx)
- DOT Data Portal Motus datasets (InsHist, AuthHist, RevokeSuspend) and MCMIS census (`az4n-8mr2`)

### Data limitations (read before buying)

- **Not real-time.** Open-data tables and SAFER HTML update on FMCSA schedules; Motus incremental feeds are typically next-day.
- **SMS BASICs** require a free QCMobile webKey; without it, SMS\_\* events are not emitted.
- **SAFER HTML** layout can change; parsing is best-effort and may miss fields for inactive / unusual entities.
- **First run** stores baselines only — you will not be charged for “current state” snapshots.
- **MCS150\_STALE** uses the official MCS-150 form date vs `mcs150StaleMonths` (default 24). It is a justified heuristic from public filing dates, not a separate FMCSA “stale” flag.
- Fair-use pacing applies; large books need longer `maxRunSeconds` or more frequent smaller batches.
- We cite FMCSA / U.S. DOT as the data origin. This Actor is not affiliated with or endorsed by FMCSA.

### Apify Store daily auto-test / default input

| Field | Default |
|-------|---------|
| `usdotNumbers` | `["44110","294837"]` |
| `signalGroups` | all six |
| `sourceMode` | `fixture` |
| `emitFixtureDemoEvents` | `false` |
| `maxRunSeconds` | `55` |
| `maxEvents` | `500` |

On that path the Actor **SUCCEEDS** quickly, pushes exactly one `RUN_STATUS` / `FIXTURE_HEALTH` row (`billable: false`), and does **not** charge `risk-event-delivered`.

### Input (summary)

| Field | Notes |
|-------|--------|
| `usdotNumbers` | Watchlist (required) |
| `signalGroups` | `insurance`, `oos`, `safety_rating`, `sms`, `authority`, `mcs150` |
| `mcs150StaleMonths` | Default 24 |
| `smsAlertPercentile` | Default 65 (QCMobile path) |
| `sourceMode` | `fixture` (default) or `live` |
| `emitFixtureDemoEvents` | Default **false** |
| `fmcsaQcMobileWebKey` | Optional secret |
| `maxRunSeconds` / `maxEvents` | Budgets |
| `resumeFromCheckpoint` | Default true |
| `requestPaceMs` | Fair-use delay (default 400) |

#### Production example

```json
{
  "usdotNumbers": ["44110", "294837", "1000287"],
  "signalGroups": ["insurance", "oos", "safety_rating", "sms", "authority", "mcs150"],
  "sourceMode": "live",
  "maxRunSeconds": 120,
  "requestPaceMs": 400,
  "resumeFromCheckpoint": true
}
```

### Output

#### Risk events (billable under PPE)

Typed rows include: `usdot_number`, `legal_name`, `event_type`, `event_subtype`, `changed_fields`, `previous_value`, `new_value`, `effective_date`, `evidence`, `summary`, `source_url`, `event_uid`, `billable: true`.

#### RUN\_STATUS (never billed)

Every successful run pushes one health row (`FIXTURE_HEALTH` | `MONITOR_IDLE` | `CATCHUP_COMPLETE` | `HEALTH_OK`).

### Pricing

Pay-per-event: **`risk-event-delivered`** at **$0.025** per delivered unique risk event ($25 / 1,000). Single tier (see `docs/monetization.md` and ADR 0010). Health / baseline / duplicate / fixture rows are never charged.

### Local development

```bash
cd actors/fmcsa-safer-risk-event-monitor
npm install
npm test
npm run build
## Store-safe fixture health:
apify run -p
## Demo typed events locally:
## set input emitFixtureDemoEvents=true (still sourceMode=fixture)
```

### Attribution

Data originates from the **Federal Motor Carrier Safety Administration (FMCSA)** and U.S. DOT open data. Not an official FMCSA product.

# Actor input Schema

## `usdotNumbers` (type: `array`):

USDOT numbers to monitor (digits only after normalize). Invalid entries are skipped with no charge.

## `signalGroups` (type: `array`):

Which risk signal groups to evaluate: insurance, oos, safety\_rating, sms, authority, mcs150. Default: all.

## `mcs150StaleMonths` (type: `integer`):

Emit MCS150\_STALE when the official MCS-150 form date is older than this many months (FMCSA biennial filing is typically 24).

## `smsAlertPercentile` (type: `integer`):

When QCMobile webKey is set, emit SMS\_BASIC\_ALERT when a BASIC percentile is at or above this value (or when the API marks alert).

## `maxRunSeconds` (type: `integer`):

Wall-clock budget for this scheduled poll.

## `maxEvents` (type: `integer`):

Stop after this many unique risk events are delivered (does not include RUN\_STATUS).

## `resumeFromCheckpoint` (type: `boolean`):

If true, resume carrier snapshots, Motus high-water, and seen event\_uids from the default Key-Value Store.

## `sourceMode` (type: `string`):

fixture = local/CI / Apify Store daily auto-test default (no network; emits RUN\_STATUS only unless emitFixtureDemoEvents=true). live = official FMCSA SAFER / census SODA / Motus open data (+ optional QCMobile).

## `emitFixtureDemoEvents` (type: `boolean`):

When sourceMode=fixture, if true push fabricated risk events from local fixtures (unit/local demos only). Default false so Store daily auto-tests never emit fake risk events or charge risk-event-delivered. Production: leave false and use sourceMode=live.

## `fmcsaQcMobileWebKey` (type: `string`):

Optional free QCMobile developer webKey for SMS BASIC / structured OOS enrichment. Not required for census, SAFER, or Motus open-data signals. Never logged. Get a key at mobile.fmcsa.dot.gov QCDevsite.

## `maxTotalChargeUsd` (type: `number`):

Optional soft budget hint for delivered risk events. Platform ACTOR\_MAX\_TOTAL\_CHARGE\_USD also applies when set.

## `requestPaceMs` (type: `integer`):

Minimum delay between outbound official HTTP requests (fair-use pacing).

## Actor input object example

```json
{
  "usdotNumbers": [
    "44110",
    "294837"
  ],
  "signalGroups": [
    "insurance",
    "oos",
    "safety_rating",
    "sms",
    "authority",
    "mcs150"
  ],
  "mcs150StaleMonths": 24,
  "smsAlertPercentile": 65,
  "maxRunSeconds": 55,
  "maxEvents": 500,
  "resumeFromCheckpoint": true,
  "sourceMode": "fixture",
  "emitFixtureDemoEvents": false,
  "requestPaceMs": 400
}
```

# Actor output Schema

## `OUTPUT` (type: `string`):

JSON summary: delivered, charged, runStatus, checkpoint, stats

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("plym-actor-factory/fmcsa-safer-risk-event-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("plym-actor-factory/fmcsa-safer-risk-event-monitor").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 '{}' |
apify call plym-actor-factory/fmcsa-safer-risk-event-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plym-actor-factory/fmcsa-safer-risk-event-monitor"
        }
    }
}
```

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/PSV2x9nfgSirwPcUD/builds/n8PH9rklAsbqDt77J/openapi.json
