# UK Insolvency Notice Monitor - The Gazette (`minimal_ricegrass/uk-insolvency-monitor`) Actor

Watches The Gazette for new UK insolvency notices - corporate winding-up, administration, liquidation, receivership, or personal bankruptcy/IVA. Each scheduled run emits only notices published since the last run, with company name and number, plus optional webhook POST.

- **URL**: https://apify.com/minimal\_ricegrass/uk-insolvency-monitor.md
- **Developed by:** [FJ Banks](https://apify.com/minimal_ricegrass) (community)
- **Categories:** Lead generation, Business
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.02 / actor start

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## UK Insolvency Notice Monitor — The Gazette

Watches **The Gazette** (the UK's official public record) for **new insolvency
notices** and, on every scheduled run, emits **only the notices published since
the last run** — deduplicated, with the company name/number and a direct link.
Optional webhook POST to Slack, Zapier, Make or n8n.

Choose **corporate** insolvency (winding-up, administration, liquidation,
receivership), **personal** insolvency (bankruptcy orders, IVAs), or **all**.

### Who it's for

| Buyer | Use |
|---|---|
| Debt collection / recovery agencies | New corporate liquidations = act before the pool of assets shrinks |
| Credit insurers & credit-control teams | Real-time risk signal on customers and their customers |
| Insolvency practitioners / turnaround advisors | Petitions to wind up = a company that may still be saveable |
| Commercial landlords & suppliers | A tenant/customer entering administration, the day it's gazetted |
| Competitors | A rival winding down — their customers and staff are in play |
| Journalists & researchers | Company-failure rate by sector or region |
| Asset buyers / auctioneers | Liquidations mean plant, stock and IP coming to market |

### Quick start

1. Paste nothing — **there is no API key**. The Gazette is a free public record.
2. Pick a **scope** (`corporate` / `personal` / `all`) and optionally a **text**
   filter (a town, a sector keyword, an insolvency practitioner's name).
3. Run once to seed state (`firstRunLookbackDays` controls the backfill).
4. **Schedule** it (Apify Console → Schedules) — daily, or a few times a day for
   speed-to-lead. Later runs are incremental automatically.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `scope` | `corporate` | `personal` | `all` | `corporate` | Which insolvency notices to track. |
| `text` | string | — | Optional free-text filter across the whole notice (company name, town, court, practitioner). |
| `includeDetail` | boolean | `true` | Fetch each notice's linked-data record for company number / court / case number (1 extra request per notice). |
| `firstRunLookbackDays` | integer 1–30 | `3` | First run only: how many days of notices to fetch. |
| `webhookUrl` | string | — | POST `{source, scope, window, count, notices[]}` here each run. |
| `maxResults` | integer 1–5000 | `500` | Cap per run. Excess rolls to the next run. |

### Output

One dataset item per new notice:

| Field | Example |
|---|---|
| `notice_id` | `"5203210"` |
| `notice_code` | `"2441"` |
| `notice_type` | `"Resolutions for Winding-up"` |
| `is_corporate` | `true` |
| `title` | `"TRINITY EUROPE LIMITED"` |
| `published` | `"2026-09-03T01:05:22"` |
| `company_name` | `"TRINITY EUROPE LIMITED"` |
| `company_number` | `"06763121"` |
| `court` | `"High Court of Justice"` *(when in the notice)* |
| `case_number` | `"CR-2026-001234"` *(when in the notice)* |
| `registered_office` | *(when in the notice)* |
| `notice_url` | `https://www.thegazette.co.uk/notice/5203210` |
| `scraped_at` | `"2026-09-03T09:00:00.000Z"` |

#### Webhook payload

```
POST <webhookUrl>
{ "source": "uk-insolvency-monitor", "scope": "corporate",
  "window": { "from": "2026-09-02", "to": "2026-09-03" },
  "count": 7, "notices": [ /* same objects as dataset items */ ] }
```

Webhook failure is logged, not fatal — the data is still in the dataset.

### How incremental mode works

Cross-run state (seen notice IDs + last-run time) lives in a **named** key-value
store, `uk-insolvency-monitor-state`, namespaced by a hash of `scope` + `text` so
multiple schedules on this actor keep separate state. Runs after the first fetch
from the day before the previous run up to today (Gazette publish dates), then
drop every notice ID already seen. The seen-set is capped at 30,000 IDs
(~2 weeks of all UK insolvency notices).

### Notes on The Gazette API

- No key, no auth, free — data published under the Open Government Licence.
- The API returns intermittent HTTP 500s; this actor retries transient failures
  (3 attempts, exponential backoff) and, if it still fails mid-run, pushes what
  it has and resumes from there next run (`partial: true` in the summary).
- Corporate vs personal is a client-side filter on the notice code
  (`24xx` = corporate, `25xx` = personal) because the Gazette search API only
  accepts one notice-type per request.

### Local development

```bash
npm install
npm test    # 15 unit tests, fully mocked
echo '{"scope":"corporate","firstRunLookbackDays":3}' > storage/key_value_stores/default/INPUT.json
npm start
```

### Deploy your own copy

```bash
npm i -g apify-cli && apify login && apify push
```

### Data source & licensing

Data comes from **The Gazette** (`thegazette.co.uk`), the UK's official public
record of record, published by The Stationery Office on behalf of HM Government.
Notices are Crown copyright, published under the
[Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

### Related actors

Part of a small suite of UK public-register monitors, same publisher, same
pattern (incremental, no duplicates, webhook-ready):

- **[UK New Company Monitor](https://apify.com/minimal_ricegrass/uk-newco-monitor)** — new incorporations by SIC / location
- **[UK Food Business Monitor](https://apify.com/minimal_ricegrass/uk-food-monitor)** — new food businesses + hygiene-rating changes (FSA)
- **[UK Public Tender Monitor](https://apify.com/minimal_ricegrass/uk-tender-monitor)** — public-sector tenders by CPV / value (Contracts Finder)
- **[UK Company Change Monitor](https://apify.com/minimal_ricegrass/uk-company-change-monitor)** — watchlist diffing: status, charges, officers, filings

***

### Changelog

- **0.1** — Initial release: corporate/personal/all scope, text filter,
  incremental dedup, notice-detail enrichment, webhook, transient-error retry.

# Actor input Schema

## `scope` (type: `string`):

corporate = companies (winding-up, administration, liquidation, receivership); personal = individuals (bankruptcy, IVA); all = both.

## `text` (type: `string`):

Optional free-text filter across the notice (company name, town, insolvency practitioner, court).

## `includeDetail` (type: `boolean`):

Fetch each notice's linked-data record for company number, court and case number (1 extra request per notice).

## `firstRunLookbackDays` (type: `integer`):

On the first run only, how many days of notices to fetch. Later runs are incremental.

## `webhookUrl` (type: `string`):

POST the new notices from each run to this URL (Slack, Zapier, Make, n8n, custom).

## `maxResults` (type: `integer`):

Safety cap on notices emitted in a single run. Any excess is picked up on the next run.

## Actor input object example

```json
{
  "scope": "corporate",
  "includeDetail": true,
  "firstRunLookbackDays": 3,
  "maxResults": 500
}
```

# Actor output Schema

## `notices` (type: `string`):

Insolvency notices published since the last run.

## `noticesTable` (type: `string`):

No description

## `runSummary` (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("minimal_ricegrass/uk-insolvency-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("minimal_ricegrass/uk-insolvency-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 minimal_ricegrass/uk-insolvency-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,minimal_ricegrass/uk-insolvency-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/8Q987HC8D9BhHCdgf/builds/4EXe2Jzb7B1c3UHAc/openapi.json
