# XRechnung to JSON Parser (`kamerozkan/xrechnung-to-json-parser`) Actor

Parse XRechnung UBL or CII XML into a stable EN 16931-oriented JSON contract with pinned technical conformance findings.

- **URL**: https://apify.com/kamerozkan/xrechnung-to-json-parser.md
- **Developed by:** [Kamer Ozkan](https://apify.com/kamerozkan) (community)
- **Categories:** Developer tools
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 document processeds

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/platform/actors/running/actors-in-store#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

Parse XRechnung UBL 2.1 Invoice, UBL 2.1 CreditNote, or CII D16B XML into one
stable EN 16931-oriented JSON contract.

### Quick start

The following input uses an official XRechnung testsuite invoice pinned to an
immutable source commit:

```json
{
  "documents": [
    {
      "documentId": "official-ubl-smoke",
      "fileName": "01.01a-INVOICE_ubl.xml",
      "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/b3791d47a2e1446b1751a27cb732aac294231293/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml"
    }
  ],
  "sourceSyntax": "UBL",
  "allowPartialNormalization": true,
  "storeTechnicalReports": false,
  "maxFindingsPerDocument": 100
}
```

Each submitted document produces one Dataset result with separate processing,
technical conformance, normalization, billing, source-provenance, and invoice
data fields.

### What it does

- Accepts up to 100 XML documents by upload, inline XML, inline base64,
  HTTPS URL, or explicit key-value store record.
- Enforces a 5 MiB per-document and 100 MiB per-run limit.
- Detects UBL Invoice, UBL CreditNote, or CII and can enforce a caller-declared
  syntax.
- Runs KoSIT Validator `1.6.0` with the pinned XRechnung `3.0.2`
  configuration release `2026-01-31`.
- Reports XML, XSD, Schematron, EN 16931, XRechnung, and mapping evidence
  separately.
- Maps the full declared EN 16931 syntax binding into the shared JSON model,
  with business-term trace entries and decimal strings.
- Can retain KoSIT XML and XHTML reports as opt-in KVS artifacts.

Invalid documents can still receive normalized data when XML parsing is safe.
`conformanceStatus` and `normalizationStatus` are separate so a technically
rejected document is never presented as conformant.

### Product boundary

The result is integration-ready JSON, not a preconfigured connector for every
ERP. Posting logic, chart-of-accounts rules, master-data resolution, duplicate
handling, approval policy, and the final ERP field mapping remain
system-specific.

The Actor does not make legal, tax, authenticity, signature, or recipient
acceptance decisions.

### Release state

The processing engine and Actor contract are feature-complete. The source
contains a fail-closed pay-per-event charge path for `document-processed` at
exactly `$0.005` per evaluated document. Local non-PPE results remain
`billable: false`; a hosted run stops before processing unless the event and
price contract are active. The synthetic `apify-actor-start` event is allowed,
while `apify-default-dataset-item` must not create an additional charge.

The live Apify pricing contract uses `document-processed` as the primary event
at `$0.005` and retains the standard `$0.00005` Actor Start event. A Store
release is approved only after the selected hosted build passes an eligible
document, a free source failure, and a free constrained-budget lifecycle smoke
with exact charge-count and artifact checks.

# Actor input Schema

## `invoiceFiles` (type: `array`):

Upload XRechnung UBL Invoice, UBL CreditNote, or CII XML files.

## `documents` (type: `array`):

Each item must contain exactly one source: url, xml, base64, or keyValueStoreKey.

## `sourceKeyValueStoreId` (type: `string`):

Key-value store ID containing records referenced by keyValueStoreKey.

## `sourceSyntax` (type: `string`):

Detect the XML syntax automatically or require UBL or CII.

## `allowPartialNormalization` (type: `boolean`):

Return safely parsed fields even when the XML is technically non-conformant.

## `storeTechnicalReports` (type: `boolean`):

Store the KoSIT XML report and its embedded HTML report in the run key-value store.

## `maxFindingsPerDocument` (type: `integer`):

Maximum number of validation findings returned for each invoice.

## Actor input object example

```json
{
  "documents": [
    {
      "documentId": "kosit-valid-sample",
      "fileName": "01.01a-INVOICE_ubl.xml",
      "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-01-31/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml"
    }
  ],
  "sourceSyntax": "AUTO",
  "allowPartialNormalization": true,
  "storeTechnicalReports": false,
  "maxFindingsPerDocument": 100
}
```

# Actor output Schema

## `results` (type: `string`):

Default Dataset rows validated against the versioned invoice, conversion, conformance, and semantic-difference contract.

## `summary` (type: `string`):

The OUTPUT key-value-store record with aggregate processing and billing counts.

## `artifacts` (type: `string`):

ARTIFACT-prefixed key-value-store records written only when artifact storage was requested.

# 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 = {
    "documents": [
        {
            "documentId": "kosit-valid-sample",
            "fileName": "01.01a-INVOICE_ubl.xml",
            "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-01-31/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kamerozkan/xrechnung-to-json-parser").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 = { "documents": [{
            "documentId": "kosit-valid-sample",
            "fileName": "01.01a-INVOICE_ubl.xml",
            "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-01-31/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("kamerozkan/xrechnung-to-json-parser").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "documents": [
    {
      "documentId": "kosit-valid-sample",
      "fileName": "01.01a-INVOICE_ubl.xml",
      "url": "https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/v2026-01-31/src/test/business-cases/standard/01.01a-INVOICE_ubl.xml"
    }
  ]
}' |
apify call kamerozkan/xrechnung-to-json-parser --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=kamerozkan/xrechnung-to-json-parser",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/QR4q0jicBJaU7yhI1/builds/2hiQhkbRezndX0cUz/openapi.json
