# xmlvalid on Apify

Source: https://xmlvalid.com/docs/integrations/apify

> Validate a list of XML documents and e-invoices by URL and get one row per document, without an xmlvalid account.

The [XML &amp; E-invoice Validator](https://apify.com/xmlvalid/xml-einvoice-validator) Actor in the Apify Store checks each document against its XSD, DTD or RelaxNG schema and, for e-invoices, the Schematron business rules (EN 16931, Peppol BIS, XRechnung, Factur-X and national CIUS). It runs on the [xmlvalid API](https://xmlvalid.com/docs/api), so the results are the same as in the [validator](https://xmlvalid.com/validate). It suits a batch of documents already on the web: a supplier portal, an export, a set of feeds.

## Run it

1. Open the [Actor's page](https://apify.com/xmlvalid/xml-einvoice-validator) and choose **Try for free** (Apify asks you to sign in).
2. Under **Document URLs**, add the addresses one by one, paste a list, or upload a text file with one URL per line. The form starts with an example Peppol invoice.
3. Leave **Schema** at `auto` and choose **Start**.
4. When the run finishes, open the **Output** tab: the **Results** view has a row per document, **Findings** a row per error. Export either as CSV, Excel or JSON.

## Input

**Document URLs**

Public http(s) addresses of XML documents, e-invoices (UBL, CII), Factur-X or ZUGFeRD PDFs, or ZIP archives. xmlvalid downloads them; private addresses are refused.

**Or paste an XML document**

One document as text, checked as well as the URLs.

**Schema**

`auto` (the default) picks the profile each e-invoice names, so a mix of Peppol, XRechnung and Factur-X invoices goes in one run; other documents are checked for well-formedness and against their own DOCTYPE. Or a name from the [schema catalog](https://xmlvalid.com/schemas), such as `peppol-bis-3-invoice`, `xrechnung-3-cii`, `ubl-2.1-invoice` or `sitemap-0.9`.

**Your xmlvalid API key**

Optional; see [pricing](#pricing).

**Findings listed per document**

How many errors and warnings each row lists, 20 by default; all of them are counted.

**Make a shareable report link**

One public HTML report for all the documents, open for 30 days, in the run's `OUTPUT` record. It holds the verdicts and the findings, not the documents.

**Documents at a time**

How many are checked in parallel, 3 by default.

## Output

One dataset item per document:

```json
{
  "source": "https://example.com/invoices/INV-1042.xml",
  "valid": false,
  "outcome": "invalid",
  "schema": "peppol-bis-3-invoice",
  "schemaName": "Peppol BIS Billing 3.0 Invoice",
  "errorsTotal": 1,
  "warningsTotal": 0,
  "firstError": "Line 139: [BR-CO-16] Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) -Paid amount (BT-113) +Rounding amount (BT-114).",
  "errors": [
    {
      "line": 139,
      "level": "error",
      "type": "schematron",
      "rule": "BR-CO-16",
      "message": "Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) -Paid amount (BT-113) +Rounding amount (BT-114).",
      "help": "https://xmlvalid.com/rules/BR-CO-16"
    }
  ],
  "warnings": [],
  "sizeBytes": 9227,
  "durationMs": 35,
  "validationId": "val_01m55d4m0rtw2n0szg5f3ybmas",
  "error": null
}
```

`outcome` is `valid`, `warnings` (valid, with warnings), `invalid`, `schema` (the schema could not be used), `input` (the document could not be downloaded or read), `failed`, or `error` when the request was refused, with the reason in `error`. `help` links to the rule's page or to an explanation of the error.

## Pricing and your own key

By default the Actor runs on xmlvalid's own account and Apify charges you per document validated, at the price on the Actor's **Pricing** tab, plus Apify's small fee for each run. Documents refused before they are checked, such as an unknown schema, are not charged. Set a maximum cost per run in the run options and the Actor stops when it is reached.

If you already have an xmlvalid account, enter your [API key](https://xmlvalid.com/dashboard/api) instead. The documents then count towards your plan (100 a month on Free, 10,000 on [Pro](https://xmlvalid.com/pricing)), your saved schemas can be used by their name (`my-12`), and Apify charges only for the run. The key field is secret: Apify stores it encrypted and doesn't show it in the run's input.

## Schedules and alerts

- **Save as a task** to keep your list of URLs and settings, then add the task to a **Schedule** to check them every day or hour.
- Under the task's **Integrations**, send the results to Slack, email, Google Drive or a webhook when a run finishes, or hand them to Make, Zapier or n8n.

For a single address, [URL monitors](https://xmlvalid.com/dashboard/monitors) on xmlvalid do this on their own, with an email when the document starts failing.

## Call it from code

Apify's API runs the Actor and returns the dataset in one request, with your Apify token:

```bash
curl -X POST "https://api.apify.com/v2/acts/xmlvalid~xml-einvoice-validator/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": [{"url": "https://example.com/invoices/INV-1042.xml"}], "schema": "auto"}'
```

If your code talks to xmlvalid directly, the [xmlvalid API](https://xmlvalid.com/docs/api) is simpler and validates files you hold as well as URLs.

## Privacy

The Actor passes the URLs to xmlvalid, whose servers in the EU download each document, validate it and delete it as soon as the check finishes; results are kept for 24 hours. The rows are stored in your Apify account under Apify's terms. See [Security](https://xmlvalid.com/security) and the [DPA](https://xmlvalid.com/dpa).
