Skip to content

Invoice

An Invoice is what a Customer owes for one or more Offers over one billing period.

Properties

PropertyTypeRequiredDescription
totalmoneyrequiredThe amount due.
duedaterequiredWhen payment is due.
paidAtdatetimeWhen it was paid.
statusstringOne of draft, open, paid, void, or uncollectible.
collectionstringcharge charges the saved payment method; send sends the Invoice and waits for a transfer. charge by default.
termsintegerDays from issue until a send Invoice is due, such as 30; sets due.
purchaseOrderstringThe Customer’s purchase order number, printed on the Invoice.
refundedmoneyThe total returned to the Customer, from zero up to the amount paid.
numberstringThe Invoice number, sequential per Startup and never reused, voided Invoices included.
linesjsonEach Offer billed: its quantity, Period and amount, with any Coupon or Credit Grant applied.
pdfurlThe Invoice, or its receipt once paid, as a PDF on the Startup’s Domain that names the seller of record.
payUrlurlThe page on the Startup’s Domain where the Customer pays it by card or bank transfer.

Object

JSON
{
  "$id": "https://api.sb/patentpad.com/invoices/invoice_1",
  "$type": "Invoice",
  "total": {
    "amount": 499,
    "currency": "USD"
  },
  "due": "2026-10-22",
  "paidAt": "2026-10-22T12:00:00Z",
  "status": "draft",
  "collection": "charge",
  "terms": 1,
  "purchaseOrder": "PO-48213",
  "refunded": {
    "amount": 499,
    "currency": "USD"
  },
  "number": "LEDG-0042",
  "lines": {},
  "pdf": "https://patentpad.com",
  "payUrl": "https://patentpad.com"
}

Relationships

Lifecycle

Invoice lifecycle: draft, open, paid (ends), void (ends), uncollectible (ends)draft → open: Invoice.billdraft → void: Invoice.voidopen → paid: Invoice.collectopen → void: Invoice.voidopen → uncollectible: on Invoice.overduedraftopenpaidvoiduncollectible
StateMeaningMoves to
draft (first)Its lines can still change, and the Customer has not seen it.open by Invoice.bill; void by Invoice.void
openFinalized and presented to the Customer, its lines frozen.paid by Invoice.collect; void by Invoice.void; uncollectible on Invoice.overdue when every retry on the Startup’s retry schedule has failed
paidPaid in full; a refund adds to its refunded total and never reopens it.None: it ends here.
voidCanceled unpaid and kept on record, with its reversing Entries posted.None: it ends here.
uncollectibleKept on record as unpaid once every retry has failed.None: it ends here.

Verbs

  1. createCreates an Invoice.
    POST /{namespace}/invoicesdoInvoice.created
  2. getReturns one Invoice by id.
    GET /{namespace}/invoices/{id}readNo Event
  3. listReturns Invoices, newest first, one page at a time.
    GET /{namespace}/invoicesreadNo Event
  4. updateChanges the given properties of an Invoice.
    PATCH /{namespace}/invoices/{id}doInvoice.updated
  5. billBill finalizes an Invoice and presents it to the Customer for payment.
    POST /{namespace}/invoices/{invoice}/billdoInvoice.billed
  6. collectCollect charges a Customer’s saved payment method for an open Invoice and retries on failure.
    POST /{namespace}/invoices/{invoice}/collectdoInvoice.collected
  7. refundRefund returns all or part of a paid Invoice to the Customer’s original payment method and posts the reversing Entries.
    POST /{namespace}/invoices/{invoice}/refunddoInvoice.refunded
  8. voidVoid cancels an unpaid Invoice, keeps it on record, and posts the reversing Entries.
    POST /{namespace}/invoices/{invoice}/voiddoInvoice.voided

An Invoice is never deleted: it ends by Invoice.void, and its records stay.

Events

Events no Verb emits. Each Verb’s Event is in the Verbs table above; every Event is delivered in the same shape.

Invoice.overdue

An open Invoice passed its due date unpaid, or a retry on the Startup’s retry schedule failed. Raised by a clock.

FieldTypeRequiredDescription
namestringrequiredInvoice.overdue.
atdatetimerequiredWhen it happened.
seqintegerIts position in the namespace, one more than the Event before; any seq is a cursor into the history.
datajsonrequiredThe Thing as the Action left it.
data.invoiceInvoicerequiredThe Invoice as the change left it.
data.invoice.totalmoneyrequiredThe amount due.
data.invoice.duedaterequiredWhen payment is due.
data.invoice.paidAtdatetimeWhen it was paid.
data.invoice.statusstringOne of draft, open, paid, void, or uncollectible.
data.invoice.collectionstringcharge charges the saved payment method; send sends the Invoice and waits for a transfer. charge by default.
data.invoice.termsintegerDays from issue until a send Invoice is due, such as 30; sets due.
data.invoice.purchaseOrderstringThe Customer’s purchase order number, printed on the Invoice.
data.invoice.refundedmoneyThe total returned to the Customer, from zero up to the amount paid.
data.invoice.numberstringThe Invoice number, sequential per Startup and never reused, voided Invoices included.
data.invoice.linesjsonEach Offer billed: its quantity, Period and amount, with any Coupon or Credit Grant applied.
data.invoice.pdfurlThe Invoice, or its receipt once paid, as a PDF on the Startup’s Domain that names the seller of record.
data.invoice.payUrlurlThe page on the Startup’s Domain where the Customer pays it by card or bank transfer.
data.attemptintegerrequiredWhich retry failed; 0 when the due date passed.
data.nextRetryAtdatetimeWhen the next retry runs; empty after the last one.
JSON
{
  "$id": "https://api.sb/patentpad.com/events/event_1",
  "$type": "Event",
  "name": "Invoice.overdue",
  "at": "2026-10-22T12:00:00Z",
  "data": {
    "invoice": {
      "$id": "https://api.sb/patentpad.com/invoices/invoice_1",
      "$type": "Invoice",
      "total": {
        "amount": 499,
        "currency": "USD"
      },
      "due": "2026-10-22",
      "paidAt": "2026-10-22T12:00:00Z",
      "status": "open",
      "collection": "charge",
      "terms": 1,
      "purchaseOrder": "PO-48213",
      "refunded": {
        "amount": 499,
        "currency": "USD"
      },
      "number": "LEDG-0042",
      "lines": {},
      "pdf": "https://patentpad.com",
      "payUrl": "https://patentpad.com"
    },
    "attempt": 1,
    "nextRetryAt": "2026-10-22T12:00:00Z"
  },
  "seq": 1
}

Permissions

Which Access level may call each Verb. One-way Verbs wait their delay window.

Operationowneradminmemberviewer
Invoice.createYesYesYesNo
Invoice.getYesYesYesYes
Invoice.listYesYesYesYes
Invoice.updateYesYesYesNo
Invoice.billYesNoNoNo
Invoice.collectYesNoNoNo
Invoice.refundYesNoNoNo
Invoice.voidYesNoNoNo

Stripe

Invoice (invoice). The source of truth is db.sb, and Stripe holds a copy written from it.

PropertyStripe fieldSource of truth
totaltotaldb.sb
duedue_datedb.sb
statusstatusStripe
paidAtstatus_transitions.paid_atStripe
collectioncollection_methoddb.sb
termsdays_until_duedb.sb
numbernumberdb.sb
lineslines.datadb.sb
StateStripe status
draftdraft
openopen
paidpaid
voidvoid
uncollectibleuncollectible

Call it

Text
Bill the latest invoice.

Example

The monthly Invoice to a dental group bills $99 for the base plan and $36 for 1,200 reminders over its Limit. It is due in 15 days.