Skip to content

Invoices

Invoices are automatically created when payments are processed. They contain the payment amount, status, provider-specific details, and optional download URLs.

Invoice Structure

FieldTypeDescription
subscriptionIdstringAssociated subscription
billableEntityType"user" | "workspace"Billing target type
billableEntityIdstringUser or workspace ID
amountnumberTotal payment amount
currencystringISO 4217 currency code
statusstringPayment status
externalInvoiceIdstringProvider-side invoice/transaction ID
providerKindstringPayment provider
invoiceUrlstringURL to view/download the invoice
paidAtDateWhen the payment was completed
periodStartDateBilling period start
periodEndDateBilling period end
itemsarrayLine items with description, amount, quantity

Invoice Statuses

StatusDescription
paidPayment completed successfully
pendingPayment initiated but not yet confirmed
failedPayment attempt failed
refundedPayment was refunded

API Endpoints

List Invoices

GET /api/invoices?billableEntityType=user&billableEntityId=user-123

Query Parameters:

ParameterDescription
billableEntityTypeFilter by user or workspace
billableEntityIdFilter by specific entity
statusFilter by invoice status

Get Invoice

GET /api/invoices/:id

SDK Usage

Public SDK

typescript
// List my invoices
const invoices = await sdk.payments.getInvoices();

// Get specific invoice
const invoice = await sdk.payments.getInvoice('invoice-id');

// Access invoice download URL
if (invoice.invoiceUrl) {
  window.open(invoice.invoiceUrl);
}

Admin SDK

typescript
// List all invoices for a workspace
const invoices = await adminSdk.managePayments.getInvoices({
  billableEntityType: 'workspace',
  billableEntityId: 'workspace-id',
});

// List failed invoices
const failed = await adminSdk.managePayments.getInvoices({
  status: 'failed',
});

How Invoices Are Created

Invoices are created automatically by webhook handlers when a payment provider confirms a transaction:

  1. Provider sends a payment completion webhook
  2. The webhook handler locates the associated subscription
  3. An invoice is created with the payment details from the webhook payload
  4. If the provider includes an invoice URL (e.g. Paddle, Sumit), it's stored for user access

Build SaaS Products Without Limits.