# Switzerland SHAB UID Portfolio Event Monitor (`plym-actor-factory/switzerland-shab-uid-portfolio-monitor`) Actor

Watch a list of Swiss CHE UIDs and emit typed SHAB / official gazette events — new registrations, modifications, deletions, bankruptcies — from Amtsblattportal. Not a Zefix directory dump and not a Moneyhouse scrape.

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

## Pricing

from $20.00 / 1,000 shab 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

## Switzerland SHAB UID Portfolio Event Monitor

Watch a **book of Swiss CHE UIDs** and receive **typed SHAB / SOGC gazette events** the day Amtsblattportal publishes new registrations, modifications, deletions, or bankruptcy notices for those companies. **Not** a Zefix directory dump. **Not** a Moneyhouse / local.ch HTML scrape. **Not** paid register-monitoring seats.

### Value proposition

- **UID watchlist × daily official SHAB ingest** → `SHAB_NEW` (HR01), `SHAB_MODIFICATION` (HR02), `SHAB_DELETION` (HR03), `SHAB_BANKRUPTCY` (KK\*).
- Official **Amtsblattportal** public REST API (`amtsblattportal.ch`, tenant `shab`). Fair-use HTTP pacing. **No Moneyhouse / CRIF / paid Zefix reseller key.** Optional Zefix PublicREST (free EHRA Basic Auth) is documented for future enrich — not required for the gazette path.
- **Pay only for unique delivered acts on watched UIDs.** Quiet days ≈ $0. Durable KVS checkpoint + `publication_id` / `event_uid` dedupe. Events carry official gazette provenance.

### 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 Amtsblattportal. That fixture path only writes a non-billable `RUN_STATUS` / `FIXTURE_HEALTH` row. It is **not** SHAB monitoring.

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

1. Set **`sourceMode` = `live`**
2. Provide `uidNumbers` (`CHE-XXX.XXX.XXX`) and optionally `watchlistPairs` as `UID|Company name` for display
3. Schedule runs on gazette days (or use `lookbackDays` for catch-up) with fair-use `requestPaceMs`

Official references:

- [Amtsblattportal API docs](https://amtsblattportal.ch/docs/api/)
- Portal: `https://amtsblattportal.ch/`
- Optional Zefix PublicREST (EHRA credentials by email): [Swagger](https://www.zefix.admin.ch/ZefixPublicREST/swagger-ui/index.html)

### Matching note

Amtsblattportal keyword search is **full-text**. This Actor always fetches the publication detail XML and keeps only publications whose structured **company UID** matches the watchlist UID (normalized). Mentions of a UID inside another company's text do **not** generate events.

### Data limitations

- Coverage follows SHAB electronic publication lag (usually same gazette day for new acts). Honest cadence = daily gazette days.
- Large books: list + detail HTTP per UID per window — raise `maxRunSeconds` / pace carefully; quiet books stay cheap.
- First-seen acts are delivered when they match; duplicates are deduped via `event_uid` / `publication_id`.
- We cite Amtsblattportal / SHAB / SOGC as the data origin. This Actor is not affiliated with or endorsed by SECO, EHRA, Moneyhouse, or CRIF.
- Signatory / natural-person fields are not harvested as structured outputs; gazette narrative may still contain statutory person text as published.

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

| Field | Default |
|-------|---------|
| `uidNumbers` | demo UIDs |
| `eventTypes` | new / modification / deletion / bankruptcy |
| `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 `shab-event-delivered`.

### Input (summary)

| Field | Notes |
|-------|--------|
| `uidNumbers` | CHE UID list (preferred) |
| `watchlistPairs` | Optional `UID\|Company name` for display |
| `eventTypes` | Typed filters |
| `publicationDate` / `lookbackDays` | Live scan window |
| `sourceMode` | `fixture` (default) or `live` |
| `emitFixtureDemoEvents` | Default **false** |
| `maxRunSeconds` / `maxEvents` | Budgets |
| `resumeFromCheckpoint` | Default true |
| `requestPaceMs` | Fair-use delay (default 300) |
| `useApifyProxy` | Default **true** on platform live runs — Amtsblattportal often times out from raw datacenter IPs |

#### Production example

```json
{
  "uidNumbers": ["CHE-101.400.176", "CHE-114.961.343"],
  "watchlistPairs": [
    "CHE-101.400.176|DEMO HELVETIA AG",
    "CHE-114.961.343|DEMO EDEL SYSTEMS GMBH"
  ],
  "eventTypes": [
    "SHAB_NEW",
    "SHAB_MODIFICATION",
    "SHAB_DELETION",
    "SHAB_BANKRUPTCY"
  ],
  "sourceMode": "live",
  "lookbackDays": 3,
  "maxRunSeconds": 120,
  "requestPaceMs": 300,
  "resumeFromCheckpoint": true
}
```

### Output

#### Portfolio events (billable under PPE)

Typed rows include: `uid`, `company_name`, `matched_name`, `event_type`, `event_subtype`, `publication_id`, `sub_rubric`, `publication_date`, `canton`, `act_excerpt`, `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: **`shab-event-delivered`** at **$0.02** per delivered unique portfolio act ($20 / 1,000). Single tier (see `docs/monetization.md` and ADR 0010). Health / duplicate / fixture rows are never charged.

### Local development

```bash
cd actors/switzerland-shab-uid-portfolio-monitor
npm install
npm test
npm run build
npm run start:dev
```

### Legal

SHAB / SOGC and Amtsblattportal are official public-sector gazette sources; commercial reuse of published commercial-register notices is established under Swiss practice (SHABV; OGD principles). Prefer official HTTP APIs. Do **not** use this Actor against Moneyhouse / CRIF HTML as the primary source.

# Actor input Schema

## `uidNumbers` (type: `array`):

Swiss company UIDs (CHE-XXX.XXX.XXX or digits). Matching is by UID after normalization. Invalid rows are skipped with no charge.

## `watchlistPairs` (type: `array`):

Optional display names as "UID|Company legal name". Matching remains by UID; names are copied onto output rows.

## `eventTypes` (type: `array`):

Which typed SHAB events to emit. Allowed: SHAB\_NEW, SHAB\_MODIFICATION, SHAB\_DELETION, SHAB\_BANKRUPTCY.

## `publicationDate` (type: `string`):

End of the live scan window. Default = today (UTC). Use with lookbackDays for catch-up.

## `lookbackDays` (type: `integer`):

How many calendar days (including publicationDate) to scan on live runs.

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

Wall-clock budget for this scheduled poll.

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

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

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

If true, resume lastPublicationDate 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 Amtsblattportal SHAB API (no Moneyhouse / CRIF key; fair-use).

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

When sourceMode=fixture, if true push fabricated portfolio events from local fixtures (unit/local demos only). Default false so Store daily auto-tests never emit fake events or charge shab-event-delivered. Production: leave false and use sourceMode=live. SAMPLE rows only: demo events use placeholder entities (never real companies/IDs), are flagged sample=true / isSample=true, and are NEVER charged. To see them, set Source mode = fixture and put the placeholder values CHE-999.999.996, CHE-999.999.967 in "UID watchlist".

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

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

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

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

## `useApifyProxy` (type: `boolean`):

Route live Amtsblattportal HTTP via Apify Proxy. Default true on the Apify platform (datacenter IPs often time out to SHAB). Leave on for production schedules.

## Actor input object example

```json
{
  "uidNumbers": [
    "CHE-101.400.176",
    "CHE-114.961.343"
  ],
  "watchlistPairs": [
    "CHE-101.400.176|DEMO HELVETIA AG",
    "CHE-114.961.343|DEMO EDEL SYSTEMS GMBH"
  ],
  "eventTypes": [
    "SHAB_NEW",
    "SHAB_MODIFICATION",
    "SHAB_DELETION",
    "SHAB_BANKRUPTCY"
  ],
  "lookbackDays": 1,
  "maxRunSeconds": 55,
  "maxEvents": 500,
  "resumeFromCheckpoint": true,
  "sourceMode": "fixture",
  "emitFixtureDemoEvents": false,
  "requestPaceMs": 300,
  "useApifyProxy": true
}
```

# Actor output Schema

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

JSON summary: delivered, charged, runStatus, checkpoint, stats, as\_of

# 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/switzerland-shab-uid-portfolio-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/switzerland-shab-uid-portfolio-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/switzerland-shab-uid-portfolio-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plym-actor-factory/switzerland-shab-uid-portfolio-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/ftIkcaA0SYO0jODaX/builds/AgfBDR2cXX6n9qyfu/openapi.json
