> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spirii.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Billing automation

> How Spirii turns charging sessions into invoices and payouts — without manual work.

Spirii's billing engine processes every CDR as it arrives and automatically determines who owes money, who is owed money, and what documents to produce. The result is a complete, reconciled set of sales documents each month — invoices, self-billing invoices, and expense reports — without you building any billing infrastructure.

## How it works

The billing engine runs continuously. As sessions complete and CDRs are finalised, the engine evaluates each one using the billing rules configured for your account and adds it to the appropriate document for the billing period.

```
CDR created → Billing Engine evaluates → Sales document updated → ERP synced → Invoice sent
```

The engine determines:

* **Who to invoice** — the fleet company, the eMSP, the roaming partner, or the driver directly, based on the session's payment method and your billing service configuration
* **Who to pay** — the CPO, the CSO, a subsidiary, or a mix, based on the payout configuration for the location
* **What document type to create** — a standard invoice, a self-billing invoice (issued to Spirii on your behalf).

## Token billing vs. roaming billing

The billing logic differs by session type:

* **Token sessions** are aggregated per billing customer (the fleet company or eMSP) across the billing period. One invoice covers all sessions, with line item aggregation configurable and specification attachments detailing individual charging sessions.
* **Roaming sessions** are billed based on the CDR data exchanged with the roaming partner over Hubject or OCPI. Spirii invoices the roaming partner for inbound sessions and receives invoices from the roaming partner for outbound sessions.

## What you see as a CPO

Each month you receive a self-billing invoice from Spirii for the charging revenue Spirii collected on your behalf. Attached to the invoice is a CSV listing every CDR included in the payout. You can cross-reference this with session data in Spirii Connect.

<Note>
  Sessions that arrive late — because a charger was offline and synced later — are included in the earliest available open billing period. If the period for that session has already closed, they appear in the current period.
</Note>

## Related

<CardGroup cols={3}>
  <Card title="Token billing" icon="key-round" href="/capabilities/billing-payouts/token-billing">
    How token billing sessions are aggregated and invoiced to fleet companies.
  </Card>

  <Card title="Roaming settlement" icon="globe" href="/capabilities/billing-payouts/roaming-settlement">
    How cross-network sessions are invoiced and settled.
  </Card>

  <Card title="Understanding your payout" icon="file-text" href="/capabilities/billing-payouts/payouts">
    How to reconcile the self-billing invoice with your session data.
  </Card>
</CardGroup>
