Skip to content

Invoice routes: create, get, list

The Invoice Verbs create, get, list as api.sb routes, with inputs, result, refusals and an example.

Reference for Invoice, one group of Invoice routes.

Invoice.create

Creates an Invoice. Verb page.

Text
POST /{namespace}/invoices

Body, as JSON: the inputs. Emits Invoice.created.

Inputs

InputTypeRequiredDescription
totalmoneyrequiredThe amount due.
duedaterequiredWhen payment is due.
paidAtdatetimeWhen it was paid.
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.
subscriptionSubscriptionThe Invoices the Subscription issues, one for each period it renews.
customerCustomerEach Invoice is owed by one Customer.

Returns

OutputTypeRequiredDescription
invoiceInvoicerequiredThe Invoice.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/invoices \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"total":{"amount":29,"currency":"USD"},"due":"2026-10-22"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "invoice": {
    "$id": "https://api.sb/leaseline.app/invoices/inv_Ez0sMX4WOW",
    "$type": "Invoice",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "due": "2026-10-22"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Invoice.create",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Invoice.get

Returns one Invoice by id. Verb page.

Text
GET /{namespace}/invoices/{id}

Path: id. Query: the other inputs. Reads only: it emits no Event.

Inputs

InputTypeRequiredDescription
idstringrequiredThe id of the Invoice.
atstringA time or Version name: the record as it stood then. Unset: as it stands now.

Returns

OutputTypeRequiredDescription
invoiceInvoicerequiredThe Invoice.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "$type": "Invoice",
  "$id": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L",
  "invoice": {
    "$id": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L",
    "$type": "Invoice",
    "total": {
      "amount": 99,
      "currency": "USD"
    },
    "due": "2026-10-01"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L",
    "up": "https://api.sb/leaseline.app/invoices"
  },
  "actions": {
    "bill": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L/bill",
    "collect": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L/collect",
    "refund": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L/refund"
  }
}

Invoice.list

Returns Invoices, newest first, one page at a time. Verb page.

Text
GET /{namespace}/invoices

Query: the inputs. Reads only: it emits no Event.

Inputs

InputTypeRequiredDescription
limitintegerAt most this many records, up to 100. The default is 20.
afterstringThe cursor from the previous page.
wherestringA filter over the properties, such as paidAt = null and total.amount > 500.
sortstringProperties to sort by, comma-separated; a leading minus sorts descending.
totalbooleanTrue adds the match count as meta.total, exact up to 10,000 matches and estimated above.
facetsstringProperties to count by value, comma-separated, returned as meta.facets.
fieldsstringProperties to return on each record, comma-separated; $id and $type always return.
includestringRelated records to embed in place of their URLs, comma-separated.
depthintegerHow many levels of related records to embed. The default is 1.
qstringWords to match across the text properties, ranked by relevance.
matchstringRanks the search by words, or meaning; words is the default.

Returns

OutputTypeRequiredDescription
invoiceslist of InvoicerequiredOne page of Invoices.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl "https://api.sb/leaseline.app/invoices?limit=20" \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "$type": "Invoice",
  "invoices": [
    {
      "$id": "https://api.sb/leaseline.app/invoices/inv_9sfvgeRT7L",
      "$type": "Invoice",
      "total": {
        "amount": 99,
        "currency": "USD"
      },
      "due": "2026-10-01"
    }
  ],
  "meta": {
    "limit": 20,
    "after": "inv_9sfvgeRT7L"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/invoices?limit=20",
    "next": "https://api.sb/leaseline.app/invoices?after=inv_9sfvgeRT7L"
  }
}