# Invoices

Invoices with line items, installments, late fees, early-payment discounts and automatic reminders.

```bash
curl -X POST https://paylynks.io/api/v1/invoices -H "Authorization: Bearer $PAYLYNKS_SECRET_KEY" \
  -H "Content-Type: application/json" -d '{
    "customer": "cus_...",
    "items": [{"description": "Water heater install", "unit_amount": 180000}],
    "installment_plan": {"count": 3, "interval_days": 30, "deposit": 45000},
    "late_fee": {"type": "percent", "rate_bps": 150, "grace_days": 5}
  }'
```

Creates a draft. Then:

- `POST /api/v1/invoices/:id/send` `{"channels": ["email", "sms"]}` — finalize (assigns a number like INV-1001 and a hosted page) and send.
- `POST /api/v1/invoices/:id/finalize` — finalize without sending.
- `POST /api/v1/invoices/:id/void`
- `GET /api/v1/invoices?status=open`, `GET /api/v1/invoices/:id`

Options: `due_date` or `days_until_due`, explicit `installments: [{amount, due_date}]`, `early_payment_discount: {rate_bps, within_days}` (single-payment invoices), `late_fee` fixed or percent with `grace_days`, `reminders: {offsets_days: [-3, 0, 3, 7]}`, `memo`, `footer`.

The customer pays on the hosted invoice page (installment due now, or the full balance). A daily job sends reminders and applies late fees once per installment.
