> For the complete documentation index, see [llms.txt](https://docs.younium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.younium.com/e-invoicing-integrations/maventa.md).

# Maventa

## Synchronisation scope

| Synchronisation                | Direction         | When it runs                                                                                          |
| ------------------------------ | ----------------- | ----------------------------------------------------------------------------------------------------- |
| Invoices and credit notes      | Younium → Maventa | When an invoice is posted through AutoInvoice or KSeF, or resent from the invoice                     |
| E-invoice status               | Maventa → Younium | When Maventa reports that an invoice was delivered or failed                                          |
| KSeF submission status and UPO | Maventa → Younium | When Maventa reports a status change, and scheduled every 30 minutes for invoices still awaiting KSeF |

Not in scope: received (supplier) invoices, payments.

***

## Overview

Maventa is the external e-invoicing platform behind Younium’s **AutoInvoice** and **KSeF** integrations. Younium does not expose a separate “Maventa” product toggle; instead, shared API constants, OAuth, and REST endpoints in `MaventaConstants` define how Younium talks to Maventa’s AX API. AutoInvoice posts Peppol XML and manages routing; KSeF reuses the same Maventa company, OAuth token, and invoice APIs for Polish National e-Invoice System submission and status.

## Authentication

AutoInvoice and KSeF both reach Maventa on the same connection, made with the client id and secret Maventa issued for your company. You enter them once on the AutoInvoice settings; KSeF reuses that connection rather than needing its own.

Younium manages the access itself and reuses it across the legal entity for as long as it is valid, renewing it shortly before it lapses. Maventa rejects an account that asks for new access too often, so Younium deliberately shares one rather than requesting a fresh one per invoice — which is why a burst of invoices does not multiply into a burst of sign-ins.

## Sandbox vs. Production

Younium uses Maventa's production service from a production environment and Maventa's test service everywhere else. It follows the Younium environment rather than a setting, so a test tenant cannot send a real invoice.

## API endpoints used by Younium

| Purpose                               | HTTP   | Path                               |
| ------------------------------------- | ------ | ---------------------------------- |
| OAuth token                           | POST   | `/oauth2/token`                    |
| Current company / connection          | GET    | `/oauth2/current`                  |
| Post invoice (XML)                    | POST   | `/v1/invoices`                     |
| Invoice details                       | GET    | `/v1/invoices/{id}`                |
| Invoice file (e.g. UPO)               | GET    | `/v1/invoices/{id}/files/{fileId}` |
| Link tenant company to Younium vendor | POST   | `/v1/company/vendors`              |
| Unlink on disconnect                  | DELETE | `/v1/company/vendors`              |
| Company notifications                 | GET    | `/v1/company/notifications`        |
| KSeF token submit                     | POST   | `/v1/services/ksef/tokens`         |

## Company vendor linking

On AutoInvoice **Save settings**, Younium POSTs to `/v1/company/vendors` with the bearer token so the Maventa company is linked to Younium’s vendor. On **Disconnect**, DELETE removes the link.

KSeF activation performs the same link when KSeF becomes active for the first time (`EnsureCompanyLinkedToVendor`), with race-safe re-check if POST fails but the company is already linked.

## Post invoice multipart mapping

AutoInvoice sends the Peppol XML Younium generates for the invoice, as multipart form data:

| Younium / form field                                                    | Maventa parameter                                   |
| ----------------------------------------------------------------------- | --------------------------------------------------- |
| UBL XML bytes                                                           | `file` (filename `{InvoiceNumber}.xml`, `text/xml`) |
| Fixed                                                                   | `format` = `PEPPOLBIS30`                            |
| `Invoice.Id` (first post only)                                          | `uuid`                                              |
| `Account.InvoiceEmailAddress`                                           | `recipient_email`                                   |
| `Account.ElectronicInvoiceOperator` (if `UseElectronicInvoiceOperator`) | `recipient_operator`                                |
| Derived from post flags                                                 | `disabled_routes`                                   |

`disabled_routes` values:

| Younium post behaviour           | `disabled_routes` |
| -------------------------------- | ----------------- |
| Default electronic post          | `print,email`     |
| `postElectronicInvoiceAsPrint`   | `einvoice,email`  |
| `postAutomaticElectronicRouting` | `print`           |

Authorization header: `Bearer {AccessToken}`.

## Invoice status (KSeF sync)

The KSeF status sync polls Maventa for invoice details and interprets the returned `status`:

| Maventa status | Younium outcome                                        |
| -------------- | ------------------------------------------------------ |
| `pending`      | Entry remains submitted                                |
| `error`        | `KSeFInvoiceEntry` failed with extracted error message |
| `delivered`    | UPO download, KSeF ID extraction, processed entry      |

## Webhooks and tenant resolution

Maventa’s vendor webhook notifies Younium of invoice status changes (environment-level registration, not per tenant). The same notification updates the e-invoice status of AutoInvoice invoices and, for KSeF invoices, triggers the KSeF status sync. When an invoice is submitted for KSeF, Younium registers `ElectronicInvoiceId` so callbacks resolve tenant and legal entity. `Invoice.ElectronicInvoiceId` is set to the invoice GUID for the lookup chain.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.younium.com/e-invoicing-integrations/maventa.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
