Invoice Data Model

This page documents all fields available in the Invoice object, their types, requirements, and usage.

Invoice Object

An invoice is represented as a JSON object with the following structure:

FieldTypeRequiredDescriptionExample
idstring
Required
Unique invoice identifier, prefixed with 'inv_'inv_01HXYZ...
organization_idstring
Required
ID of the organization that owns this invoiceorg_01HABC...
external_idstring | nullOptionalExternal reference ID from your CRM or accounting systemcrm-12345
numberstring
Required
Human-readable invoice number, auto-generated if not providedINV-2025-0001
customer_namestring
Required
Legal name of the customerAcme Ltd
customer_emailstring | nullOptionalBilling email address for the customer[email protected]
customer_walletstring | nullOptionalWallet address or payment identifier (e.g., Lightning invoice)lnbc1... or 0x...
amountnumber (Decimal)
Required
Invoice amount, must be positive120.00
currencystring
Required
ISO currency code (USD, EUR, SAT, BTC, etc.)USD
statusenum
Required
Current status of the invoicesent
issued_atdatetime
Required
When the invoice was issued (ISO 8601 UTC)2025-11-24T10:00:00Z
due_atdatetime | nullOptionalWhen the invoice is due (ISO 8601 UTC)2025-12-01T10:00:00Z
paid_atdatetime | nullOptionalWhen payment was recorded (ISO 8601 UTC)2025-11-25T10:00:00Z
sourcestring
Required
How the invoice was created (api, agent, dashboard, etc.)api
created_atdatetime
Required
Creation timestamp (ISO 8601 UTC)2025-11-24T10:00:00Z
updated_atdatetime
Required
Last update timestamp (ISO 8601 UTC)2025-11-24T10:00:00Z

Status Enum Values

The status field accepts one of the following values:

  • draft - Invoice is created but not sent
  • sent - Invoice has been sent to the customer
  • paid - Payment has been received
  • overdue - Invoice has passed its due date
  • canceled - Invoice has been canceled

Datetime Format

All datetime fields use ISO 8601 format in UTC. Examples:

  • 2025-11-24T10:00:00Z
  • 2025-11-24T10:00:00+00:00

When creating invoices, you can omit the timezone (it will default to UTC) or explicitly specify UTC with Z suffix.

Organization Scoping

All invoices are scoped to an organization via organization_id. This is automatically set based on:

  • API Key Context: When using API keys, the organization is derived from the key
  • User Session: When using the dashboard, the organization is from the user's active organization

Row-level security (RLS) policies ensure users can only access invoices from their organization.

Example Invoice Object

{
  "id": "inv_01HXYZ123ABC",
  "organization_id": "org_01HABC456DEF",
  "external_id": "crm-12345",
  "number": "INV-2025-0001",
  "customer_name": "Acme Ltd",
  "customer_email": "[email protected]",
  "customer_wallet": "lnbc1u1p3xyz...",
  "amount": 120.00,
  "currency": "EUR",
  "status": "sent",
  "issued_at": "2025-11-24T10:00:00Z",
  "due_at": "2025-12-01T10:00:00Z",
  "paid_at": null,
  "source": "api",
  "created_at": "2025-11-24T10:00:00Z",
  "updated_at": "2025-11-24T10:00:00Z"
}

Related Documentation