Skip to main content

Invoice

An Invoice is a cumulative billing statement that aggregates charges for a payer over a defined billing period. Unlike one-time payments (which are settled per-request) or subscriptions (which are pre-paid recurring plans), invoices are post-paid — the payer consumes the service throughout the period and settles all charges at the end.

Invoices are the core of the ItPay Protocol's cumulative payment capability, enabling pay-as-you-go billing for AI services where usage is metered by tokens, requests, processing time, or any other unit.


Fields

FieldTypeDescription
idstring (UUIDv7)Globally unique invoice identifier
service_idstringThe ServiceManifest id for the billed service
payerPartyIdentity of the party responsible for payment
periodBillingPeriodThe time range this invoice covers
line_itemsLineItem[]Individual charge entries comprising the invoice
totalMoneyTotal amount due
statusStatusCurrent state of the invoice
due_datestring (ISO 8601)Deadline for payment before the invoice becomes overdue
paid_atstring (ISO 8601)Timestamp when the invoice was paid
created_atstring (ISO 8601)Timestamp of invoice generation
updated_atstring (ISO 8601)Timestamp of last status change

Party

FieldTypeDescription
agent_idstringUnique ID of the paying agent
human_idstringOptional — ID of the human user responsible

BillingPeriod

FieldTypeDescription
startstring (ISO 8601)Start of the billing period
endstring (ISO 8601)End of the billing period

LineItem

FieldTypeDescription
datestring (ISO 8601)Date/time of the chargeable event
descriptionstringWhat the charge is for
quantitynumberNumber of units consumed
unitstringUnit of measurement (e.g. "token", "request", "second")
ratenumberPrice per unit in the invoice currency
amountnumberTotal line amount (quantity × rate) in minor currency units

Money

FieldTypeDescription
currencystring (ISO 4217)Currency code
amountnumberTotal amount due in minor currency units (e.g. cents)

Status

StatusDescription
openInvoice has been generated and is awaiting payment
paidInvoice has been settled in full
overduedue_date has passed without payment
voidInvoice has been invalidated (e.g. due to dispute or adjustment)

JSON Example

{
"id": "inv_01J7YB5C6D7E8F9G0H1I2J3K4",
"service_id": "01J7XYKZ1A2B3C4D5E6F7G8H9I",
"payer": {
"agent_id": "agent_cli_a1b2c3d4",
"human_id": "user_abc_789"
},
"period": {
"start": "2026-05-01T00:00:00Z",
"end": "2026-05-31T23:59:59Z"
},
"line_items": [
{
"date": "2026-05-01T08:12:33Z",
"description": "Document summary — annual_report_2025.pdf (89 pages)",
"quantity": 12460,
"unit": "token",
"rate": 0.003,
"amount": 37
},
{
"date": "2026-05-07T14:30:01Z",
"description": "Document summary — meeting_notes_may6.txt (12 pages)",
"quantity": 1800,
"unit": "token",
"rate": 0.003,
"amount": 5
},
{
"date": "2026-05-14T09:05:47Z",
"description": "Document summary — research_paper_quantum.pdf (234 pages)",
"quantity": 32760,
"unit": "token",
"rate": 0.003,
"amount": 98
},
{
"date": "2026-05-22T16:44:12Z",
"description": "Document summary — contract_draft_v3.docx (56 pages)",
"quantity": 7840,
"unit": "token",
"rate": 0.003,
"amount": 24
},
{
"date": "2026-05-29T11:20:08Z",
"description": "Document summary — technical_spec.pdf (178 pages)",
"quantity": 24920,
"unit": "token",
"rate": 0.003,
"amount": 75
}
],
"total": {
"currency": "USD",
"amount": 239
},
"status": "open",
"due_date": "2026-06-07T23:59:59Z",
"paid_at": null,
"created_at": "2026-06-01T00:00:00Z",
"updated_at": "2026-06-01T00:00:00Z"
}

State Machine

┌──────────┐
│ open │
└──┬───┬───┘
pays │ │ due_date │ void
│ │ passes │
▼ ▼ │
┌───────────┐ │
│ overdue │ │
└─────┬─────┘ │
│ pays │
▼ ▼
┌──────────┐ ┌──────────┐
│ paid │ │ void │
└──────────┘ └──────────┘

Transitions

FromToTrigger
openpaidFull payment is received before the due date
openoverduedue_date passes without full payment
openvoidProvider voids the invoice (e.g. adjustment, dispute)
overduepaidFull payment is received after the due date
overduevoidProvider voids the overdue invoice
paidTerminal state — no further transitions
voidTerminal state — no further transitions

Key Behaviors

  • Post-paid by design: Invoices are generated at the end of a billing period based on recorded usage. This contrasts with subscriptions (pre-paid) and one-time payments (per-request).
  • Line items are immutable: Once an invoice is generated, its line items cannot be changed. Corrections require voiding the invoice and generating a new one with adjusted line items.
  • Partial payments: By default, the protocol requires full payment of the total.amount to transition the invoice to paid. Partial payments are supported at the channel level but are reflected in the invoice only after the full amount is settled.
  • Overdue handling: When an invoice becomes overdue, the provider may block further service access until payment is received. The provider determines the grace period and service degradation policy.
  • Reconciliation: Each line item's amount is the product of quantity × rate rounded to the nearest minor currency unit. The total.amount is the sum of all line item amounts. Discrepancies (e.g. due to rounding) are resolved in the provider's favour.
  • Invoice vs PaymentIntent: An invoice generates a PaymentIntent of type "cumulative" when the payer initiates settlement. The PaymentIntent tracks the real-time payment status, while the Invoice is the authoritative billing record.