Invoices#

Invoices are statements of amounts owed by a tenant. They track the status of payments from creation through collection.

The Invoice object#

AttributeTypeDescription
idstringUnique identifier with inv_ prefix
objectstringAlways "invoice"
customerstringCustomer ID
statusenumdraft, open, paid, void, uncollectible
amount_dueintegerAmount owed in smallest currency unit
amount_paidintegerAmount already paid
amount_remainingintegerAmount still owed
currencystringThree-letter ISO 4217 currency code
due_datetimestampPayment due date
line_itemsarrayArray of invoice line items
subtotalintegerSubtotal before tax
taxintegerTotal tax amount
totalintegerTotal after tax
descriptionstringDescription of the invoice
pdf_urlstringURL of the generated PDF
hosted_invoice_urlstringURL for hosted payment page
payment_intentstringAssociated PaymentIntent ID
metadatahashKey-value pairs
finalized_attimestampWhen the invoice was finalized
paid_attimestampWhen the invoice was paid
createdtimestampTime at which the object was created
livemodebooleanWhether this is a live mode object
{
  "id": "inv_abc123",
  "object": "invoice",
  "customer": "cus_123456789",
  "status": "open",
  "amount_due": 125000,
  "amount_paid": 0,
  "amount_remaining": 125000,
  "currency": "eur",
  "due_date": 1708732800,
  "line_items": [
    {
      "id": "ii_item1",
      "description": "Monthly rent — Unit 4B",
      "amount": 120000,
      "currency": "eur",
      "quantity": 1
    },
    {
      "id": "ii_item2",
      "description": "Parking space",
      "amount": 5000,
      "currency": "eur",
      "quantity": 1
    }
  ],
  "subtotal": 125000,
  "tax": 0,
  "total": 125000,
  "pdf_url": "https://files.casapay.com/invoices/inv_abc123.pdf",
  "hosted_invoice_url": "https://pay.casapay.com/inv/inv_abc123",
  "metadata": {
    "lease_id": "lease_789",
    "period": "2025-02"
  },
  "finalized_at": 1706227200,
  "created": 1706140800,
  "livemode": false
}

Create an Invoice#

POST /v1/invoices

ParameterTypeRequiredDescription
customerstringYesCustomer ID
due_datetimestampNoPayment due date
line_itemsarrayNoInvoice line items
line_items[].descriptionstringYesLine item description
line_items[].amountintegerYesAmount in smallest currency unit
line_items[].currencystringYesISO 4217 currency code
line_items[].quantityintegerNoQuantity (default: 1)
descriptionstringNoInvoice description
tax_ratesarrayNoTax rate IDs to apply
metadatahashNoKey-value pairs
curl https://api.casapay.com/v1/invoices \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_123456789",
    "due_date": 1708732800,
    "line_items": [
      {
        "description": "Monthly rent — Unit 4B",
        "amount": 120000,
        "currency": "eur"
      },
      {
        "description": "Parking space",
        "amount": 5000,
        "currency": "eur"
      }
    ]
  }'
{
  "id": "inv_abc123",
  "object": "invoice",
  "status": "draft",
  "amount_due": 125000,
  "currency": "eur",
  "created": 1706140800
}

Retrieve an Invoice#

GET /v1/invoices/:id

curl https://api.casapay.com/v1/invoices/inv_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Update an Invoice#

Updates a draft invoice. Only invoices in draft status can be updated.

POST /v1/invoices/:id

ParameterTypeDescription
due_datetimestampUpdated due date
descriptionstringUpdated description
metadatahashUpdated metadata
curl https://api.casapay.com/v1/invoices/inv_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc" \
  -H "Content-Type: application/json" \
  -d '{"due_date": 1709337600}'

Delete an Invoice#

Permanently deletes a draft invoice. Finalized invoices cannot be deleted — use void instead.

DELETE /v1/invoices/:id

curl -X DELETE https://api.casapay.com/v1/invoices/inv_abc123 \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

List Invoices#

GET /v1/invoices

ParameterTypeDescription
customerstringFilter by customer
statusstringFilter by status
due_date[gte]timestampDue date on or after
due_date[lte]timestampDue date on or before
limitintegerNumber of objects to return (1–100)
starting_afterstringCursor for pagination
curl "https://api.casapay.com/v1/invoices?customer=cus_123456789&status=open" \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Finalize an Invoice#

Finalizes a draft invoice, locking it for payment. The invoice status changes from draft to open.

POST /v1/invoices/:id/finalize

curl -X POST https://api.casapay.com/v1/invoices/inv_abc123/finalize \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Send an Invoice#

Sends a finalized invoice to the customer via email.

POST /v1/invoices/:id/send

curl -X POST https://api.casapay.com/v1/invoices/inv_abc123/send \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Void an Invoice#

Voids a finalized invoice that hasn't been paid. Voided invoices cannot be unvoided.

POST /v1/invoices/:id/void

curl -X POST https://api.casapay.com/v1/invoices/inv_abc123/void \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"

Mark Invoice Uncollectible#

Marks an open invoice as uncollectible. This is typically done after exhausting payment attempts.

POST /v1/invoices/:id/mark_uncollectible

curl -X POST https://api.casapay.com/v1/invoices/inv_abc123/mark_uncollectible \
  -H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"