> 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

## 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 vendor webhooks target Younium’s KSeF webhook endpoint (environment-level registration, not per tenant). 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
