# KSeF FA(3) Invoice Generator (`kamerozkan/ksef-fa-invoice-generator`) Actor

Turn structured JSON into KSeF FA(3) XML, then run the pinned official FA(3) Schema and deterministic offline technical checks.

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

## Pricing

from $10.00 / 1,000 invoice generateds

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

Strict JSON in. A generated and technically validated KSeF FA(3) v1-0E artifact out.

The Actor calculates totals with decimal arithmetic, generates the target invoice,
runs an independent pinned validation stack, stores only accepted artifacts, and
returns a SHA-256 evidence record. A rejected artifact is not delivered or charged
under pay-per-event pricing.

### Input

Use `invoice` for one document or `invoices` for a batch of up to 100. Amounts and
quantities must be JSON strings such as `"19.00"`, not floating-point numbers.
The input schema exposes the complete production v1 canonical model and the strict
product extension. Unknown fields are rejected instead of being silently ignored.

### Production v1 capabilities

- Generate production FA(3) invoice and correction scenarios with strict country-specific options.
- Support VAT groups, foreign-currency VAT reporting, annotations, advances, payment state, order rows, and structured attachments where applicable.
- Validate the official FA(3) XSD plus deterministic offline cross-field rules.

### Required product context

KSeF network submission, authentication, certificate handling, and authority acceptance are outside this offline generator.

### Output

Each dataset row contains the technical assessment, artifact key, evidence key,
hash, byte count, generator version, standard version, pinned ruleset, and bounded
findings. The artifact and evidence JSON are private key-value store records.

For pay-per-event deployment, configure `invoice-generated` at exactly USD 0.01
and keep the synthetic `apify-default-dataset-item` event at USD 0. The
synthetic `apify-actor-start` event may have any nonnegative configured price;
every other event must remain free. The runtime refuses hosted non-PPE runs and
unsafe event maps before reading input. Local non-PPE execution remains
available for offline tests. A paid run charges only an artifact that was
validated, stored, and delivered.

### Operational boundary

This Actor generates and validates the document. It does not submit to Peppol,
KSeF, SdI, or a French platform. It does not authenticate to an authority, create
a qualified signature, perform legal archival, assign an official network
identifier, or guarantee recipient or tax-authority acceptance. `ACCEPTED` means
the generated artifact passed the documented pinned offline technical gate.

# Actor input Schema

## `invoice` (type: `object`):

One invoice for KSeF FA(3) v1-0E.

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

Optional batch of up to 100 invoices. Do not use with invoice.

## Actor input object example

```json
{
  "invoice": {
    "invoice_number": "INV-2026-0001",
    "issue_date": "2026-07-29",
    "due_date": "2026-08-28",
    "delivery_date": "2026-07-29",
    "currency": "PLN",
    "invoice_type_code": "380",
    "buyer_reference": "BUYER-REF-1001",
    "purchase_order_reference": "PO-2026-1001",
    "seller": {
      "name": "Przykladowy Sprzedawca Sp. z o.o.",
      "address": {
        "line1": "ul. Prosta 1",
        "city": "Warszawa",
        "postal_code": "00-001",
        "country_code": "PL"
      },
      "vat_id": "PL5265877635",
      "tax_id": "5265877635"
    },
    "buyer": {
      "name": "Przykladowy Nabywca Sp. z o.o.",
      "address": {
        "line1": "ul. Dluga 2",
        "city": "Krakow",
        "postal_code": "30-001",
        "country_code": "PL"
      },
      "vat_id": "PL1234563218",
      "tax_id": "1234563218"
    },
    "lines": [
      {
        "id": "1",
        "description": "Usluga doradcza",
        "quantity": "2",
        "unit_code": "HUR",
        "unit_price": "500.00",
        "tax_rate": "23",
        "tax_category": "S"
      }
    ],
    "payment": {
      "means_code": "30",
      "reference": "INV-2026-0001",
      "iban": "PL61109010140000071219812874"
    },
    "notes": [],
    "extensions": {
      "ksef": {
        "jst": false,
        "gv": false
      }
    }
  }
}
```

# Actor output Schema

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

One result row per requested invoice, including delivery status and bounded validation findings.

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

Run-level counts, standard and ruleset identity, billing mode, and explicit operational boundaries.

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

Private XML or PDF records delivered only after every pinned technical gate accepted them.

## `evidence` (type: `string`):

SHA-256 identity, ruleset versions, validation outcome, and network-operation boundary for each delivered artifact.

# 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 = {
    "invoice": {
        "invoice_number": "INV-2026-0001",
        "issue_date": "2026-07-29",
        "due_date": "2026-08-28",
        "delivery_date": "2026-07-29",
        "currency": "PLN",
        "invoice_type_code": "380",
        "buyer_reference": "BUYER-REF-1001",
        "purchase_order_reference": "PO-2026-1001",
        "seller": {
            "name": "Przykladowy Sprzedawca Sp. z o.o.",
            "address": {
                "line1": "ul. Prosta 1",
                "city": "Warszawa",
                "postal_code": "00-001",
                "country_code": "PL"
            },
            "vat_id": "PL5265877635",
            "tax_id": "5265877635"
        },
        "buyer": {
            "name": "Przykladowy Nabywca Sp. z o.o.",
            "address": {
                "line1": "ul. Dluga 2",
                "city": "Krakow",
                "postal_code": "30-001",
                "country_code": "PL"
            },
            "vat_id": "PL1234563218",
            "tax_id": "1234563218"
        },
        "lines": [
            {
                "id": "1",
                "description": "Usluga doradcza",
                "quantity": "2",
                "unit_code": "HUR",
                "unit_price": "500.00",
                "tax_rate": "23",
                "tax_category": "S"
            }
        ],
        "payment": {
            "means_code": "30",
            "reference": "INV-2026-0001",
            "iban": "PL61109010140000071219812874"
        },
        "notes": [],
        "extensions": {
            "ksef": {
                "jst": false,
                "gv": false
            }
        }
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("kamerozkan/ksef-fa-invoice-generator").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 = { "invoice": {
        "invoice_number": "INV-2026-0001",
        "issue_date": "2026-07-29",
        "due_date": "2026-08-28",
        "delivery_date": "2026-07-29",
        "currency": "PLN",
        "invoice_type_code": "380",
        "buyer_reference": "BUYER-REF-1001",
        "purchase_order_reference": "PO-2026-1001",
        "seller": {
            "name": "Przykladowy Sprzedawca Sp. z o.o.",
            "address": {
                "line1": "ul. Prosta 1",
                "city": "Warszawa",
                "postal_code": "00-001",
                "country_code": "PL",
            },
            "vat_id": "PL5265877635",
            "tax_id": "5265877635",
        },
        "buyer": {
            "name": "Przykladowy Nabywca Sp. z o.o.",
            "address": {
                "line1": "ul. Dluga 2",
                "city": "Krakow",
                "postal_code": "30-001",
                "country_code": "PL",
            },
            "vat_id": "PL1234563218",
            "tax_id": "1234563218",
        },
        "lines": [{
                "id": "1",
                "description": "Usluga doradcza",
                "quantity": "2",
                "unit_code": "HUR",
                "unit_price": "500.00",
                "tax_rate": "23",
                "tax_category": "S",
            }],
        "payment": {
            "means_code": "30",
            "reference": "INV-2026-0001",
            "iban": "PL61109010140000071219812874",
        },
        "notes": [],
        "extensions": { "ksef": {
                "jst": False,
                "gv": False,
            } },
    } }

# Run the Actor and wait for it to finish
run = client.actor("kamerozkan/ksef-fa-invoice-generator").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 '{
  "invoice": {
    "invoice_number": "INV-2026-0001",
    "issue_date": "2026-07-29",
    "due_date": "2026-08-28",
    "delivery_date": "2026-07-29",
    "currency": "PLN",
    "invoice_type_code": "380",
    "buyer_reference": "BUYER-REF-1001",
    "purchase_order_reference": "PO-2026-1001",
    "seller": {
      "name": "Przykladowy Sprzedawca Sp. z o.o.",
      "address": {
        "line1": "ul. Prosta 1",
        "city": "Warszawa",
        "postal_code": "00-001",
        "country_code": "PL"
      },
      "vat_id": "PL5265877635",
      "tax_id": "5265877635"
    },
    "buyer": {
      "name": "Przykladowy Nabywca Sp. z o.o.",
      "address": {
        "line1": "ul. Dluga 2",
        "city": "Krakow",
        "postal_code": "30-001",
        "country_code": "PL"
      },
      "vat_id": "PL1234563218",
      "tax_id": "1234563218"
    },
    "lines": [
      {
        "id": "1",
        "description": "Usluga doradcza",
        "quantity": "2",
        "unit_code": "HUR",
        "unit_price": "500.00",
        "tax_rate": "23",
        "tax_category": "S"
      }
    ],
    "payment": {
      "means_code": "30",
      "reference": "INV-2026-0001",
      "iban": "PL61109010140000071219812874"
    },
    "notes": [],
    "extensions": {
      "ksef": {
        "jst": false,
        "gv": false
      }
    }
  }
}' |
apify call kamerozkan/ksef-fa-invoice-generator --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/0ACCf4vfwfp4vqXfJ/builds/cBYqvMDIPl6zbqPrH/openapi.json
