# Broken Url Monitor (`datawinder/broken-url-monitor`) Actor

Stateful sitemap-based broken URL monitor that detects link failures, redirects, and regressions over time for SEO and automated website monitoring.

- **URL**: https://apify.com/datawinder/broken-url-monitor.md
- **Developed by:** [DatawinderLabs](https://apify.com/datawinder) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $25.00 / 1,000 run monitorings

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

## Broken URL Monitor

Stateful sitemap-based URL monitoring Actor.

This Actor continuously checks all URLs listed in a sitemap and detects **regressions and changes over time**, not just one-off failures.

***

### What it does

- Parses sitemap files and sitemap indexes (nested sitemaps supported)
- Validates all URLs using HTTP `HEAD` (automatic fallback to `GET`)
- Stores a **baseline snapshot** on first run
- Compares subsequent runs against the previous snapshot
- Reports **only meaningful changes**, classified by severity

***

### Detected changes

- Broken URLs (4xx / 5xx)
- Status code changes
- Newly introduced redirects
- URL recoveries (error → OK)
- Large response time regressions

***

### Why this Actor

Most link checkers:

- Run once
- Dump raw status codes
- Require manual comparison

This Actor:

- Is **stateful**
- Safe to run repeatedly or on a schedule
- Produces **diff-based output**
- Designed for monitoring, not crawling

***

### Input

| Field | Type | Required | Default | Description |
|----|----|----|----|----|
| `sitemapUrl` | string | ✅ | – | URL of a sitemap or sitemap index |
| `requestMethod` | string | ❌ | `head` | HTTP method (`head` or `get`) |
| `followRedirects` | boolean | ❌ | `true` | Follow HTTP redirects |
| `timeoutMs` | number | ❌ | `10000` | Request timeout in milliseconds |
| `maxConcurrency` | number | ❌ | `10` | Number of parallel URL checks |

***

### First run (baseline)

On the first execution:

- All URLs are checked
- Results are stored as a baseline
- No diffs are reported

Example output:

```json
{
  "baseline": true,
  "summary": {
    "total": 84,
    "ok": 84,
    "redirect": 0,
    "clientError": 0,
    "serverError": 0
  },
  "message": "Baseline stored. Monitoring is now active."
}
```

This allows you to validate a sitemap once for free before committing to monitoring.

***

### Subsequent runs (monitoring)

On later executions:

- URLs are rechecked
- Results are compared against the previous snapshot
- Only changes are reported

Example output:

```json
{
  "baseline": false,
  "summary": {
    "total": 84,
    "ok": 82,
    "errors": 2
  },
  "changes": {
    "critical": [
      {
        "url": "https://example.com/page",
        "previous": { "status": 200 },
        "current": { "status": 404 }
      }
    ],
    "warning": [],
    "info": []
  },
  "unchangedCount": 82
}
```

***

### Severity levels

- **critical**
  - Status code regressions (e.g. 200 → 404)
- **warning**
  - Newly introduced redirects
  - Response time regressions (>4× increase)
- **info**
  - URL recoveries
  - Newly added URLs

***

### Request Strategy (HEAD → GET Fallback)

To reduce false positives and unnecessary bandwidth usage:

1. URLs are checked using HEAD requests by default
2. If a server responds with 405 or fails:

- The Actor automatically retries using GET

This handles:

- Servers that block HEAD
- Misconfigured CDNs
- Legacy infrastructure

***

### Recommended usage

- Run on a schedule (daily or hourly)
- Use Apify webhooks or integrations for alerts
- One Actor run equals one monitoring snapshot

Ideal for:

- SEO monitoring
- Content audits
- Website migrations
- Regression detection after deployments

***

### Notes

- Each sitemap is monitored independently
- State is stored automatically per sitemap
- Safe to rerun indefinitely
- No proxies required for most sites

***

### Webhook & Alerts

This Actor is designed to be used with Apify webhooks.

#### Example: Alert on broken URLs

Trigger condition:

- Event: ACTOR.RUN.SUCCEEDED
- Payload filter (pseudo):

```js
payload.OUTPUT.baseline === false &&
payload.OUTPUT.changes.critical.length > 0
```

#### Example: Slack alert message (JSON)

```json
{
  "text": ":rotating_light: Broken URLs detected",
  "attachments": [
    {
      "fields": [
        { "title": "Sitemap", "value": "{{sitemapUrl}}" },
        { "title": "Critical changes", "value": "{{criticalChanges}}" },
        { "title": "Warnings", "value": "{{warningChanges}}" }
      ]
    }
  ]
}
```

#### Example: Email summary

Send when:

- baseline === false
- criticalChanges > 0
  Include:
- sitemap URL
- number of broken URLs
- link to Actor run

# Actor input Schema

## `sitemapUrl` (type: `string`):

Absolute URL of the sitemap XML to monitor

## `requestMethod` (type: `string`):

HTTP method to use when checking URLs; HEAD is preferred and GET is fallback.

## `followRedirects` (type: `boolean`):

Whether to follow HTTP redirects when checking URLs.

## `timeoutMs` (type: `integer`):

Request timeout in milliseconds for URL checks.

## `maxConcurrency` (type: `integer`):

Maximum number of concurrent requests to perform.

## Actor input object example

```json
{
  "sitemapUrl": "https://www.sitemaps.org/sitemap.xml",
  "requestMethod": "head",
  "followRedirects": true,
  "timeoutMs": 10000,
  "maxConcurrency": 10
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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("datawinder/broken-url-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("datawinder/broken-url-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 datawinder/broken-url-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datawinder/broken-url-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/BSYhOsydKCkZuNkys/builds/ur95L9ibwHhG7jxYJ/openapi.json
