# UBL Invoice Pre-Check for Peppol (`al31si/peppol-bis-invoice-validator-staging`) Actor

Fast deterministic pre-checks for UBL invoices before Peppol submission. Validates core invoice structure and consistency rules. Not a full EN 16931 or official Peppol conformance validator.

- **URL**: https://apify.com/al31si/peppol-bis-invoice-validator-staging.md
- **Developed by:** [Alessandro Isidori](https://apify.com/al31si) (community)
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / invoice validated

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

## Deterministic restricted Peppol BIS Billing 3.0 subset validator

Private Atlas Actor for bounded, offline validation of inline UBL `Invoice` and `CreditNote` documents.

### Contract

- Input is one inline `invoice_xml`, a bounded `invoices` array (maximum 8 documents), or the provenance-only smoke contract.
- Each XML document is limited to 131,072 UTF-8 bytes; the combined XML in a single or batch input is limited to 1,048,576 UTF-8 bytes. Schema and runtime also cap each XML string at 131,072 characters.
- The Actor performs no network fetches and accepts no URL, file, credential, or remote-document input.
- Runtime egress remains disabled by the Actor policy (`external_hosts: []`).
- `Actor.push_data` emits one per-document validation record; `Actor.set_value("OUTPUT", ...)` emits the aggregate result.
- Smoke input containing only `atlas_provenance` emits a smoke dataset record and a separate zero-count aggregate output.

### Validation scope

This implementation is a deterministic restricted subset, not a complete Peppol conformance engine. It checks the declared Peppol BIS Billing 3.0 identifiers, selected UBL structure, mandatory parties and electronic addresses, country and VAT scheme fields, line arithmetic, line- and document-level allowances and charges, tax totals, currencies, monetary-total reconciliation, and XML declaration safety.

- `Invoice` documents use `InvoiceTypeCode`, `InvoiceLine`, and `InvoicedQuantity`.
- `CreditNote` documents use `CreditNoteTypeCode`, `CreditNoteLine`, and `CreditedQuantity`.
- `ChargeIndicator=true` or `1` increases the applicable total; `ChargeIndicator=false` or `0` decreases it. Other values are invalid at both line and document level.
- DTD and entity declarations are rejected before XML parsing, while ordinary text containing words such as `Public Systems Srl` remains valid.

No official OpenPeppol ruleset is vendored or executed offline. This Actor therefore makes no full-conformance, national-CIUS, legal, or accounting claim. Documents requiring national extensions or rules outside this subset need separate validation.

### Offline schemas

`.actor/actor.json` links Apify to `output_schema.json`, whose `results` output exposes the default Dataset items. `input_schema.json` defines inline inputs and smoke contracts; `dataset_schema.json` defines each pushed record; and `provenance_schema.json` defines the bounded provenance object. `.actor/actor_schema.json` validates the private bounded `atlas-apify.json` configuration. The remaining offline schemas use `schemaVersion: 1`.

### Local checks

```bash
python -m pip install --require-hashes --requirement requirements.txt
python -m unittest discover -s tests -p 'test_*.py'
docker build --tag peppol-bis-invoice-validator:local .
```

These are source-only checks. They do not run the Actor, call Apify services, publish, deploy, or change provider lifecycle state.

# Actor input Schema

## `invoice_xml` (type: `string`):

One complete inline UBL Invoice or CreditNote document.

## `reference` (type: `string`):

Optional non-sensitive caller reference returned with the result.

## `invoices` (type: `array`):

At most 8 inline documents; runtime enforces a 1 MiB aggregate UTF-8 limit.

## `atlas_provenance` (type: `object`):

Optional offline provenance metadata; it does not authorize network or provider operations.

## Actor input object example

```json
{}
```

# Actor output Schema

## `results` (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("al31si/peppol-bis-invoice-validator-staging").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("al31si/peppol-bis-invoice-validator-staging").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 al31si/peppol-bis-invoice-validator-staging --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,al31si/peppol-bis-invoice-validator-staging"
        }
    }
}
```

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/N4nrUGZcOLwafdl72/builds/fvbq1mwfZkRGpgh7z/openapi.json
