# Invoices

> Invoices booked in your accounting provider for payments and subscription periods. Read-only.

Source: https://docs.borga.is/api/invoices

Invoices are created by Borga when a payment succeeds, a bank invoice is issued or a subscription period ends, and mirrored to PayDay or DK+. See [Invoicing](/billing/invoicing). You cannot create or edit them through the API; add one-off charges to a subscription with [invoice items](/api/invoice-items).

**The invoice object**

- `id` (string): Prefixed `inv_`.
- `customer` (string | null): <Param name="payment" type="string | null">The payment that paid it, for one-off sales and card-collected subscription invoices.
- `status` (enum): `draft`, `open`, `paid`, `void` or `sync_failed`.
- `subtotal` (integer): - `tax` (integer) - `total` (integer) - `amount_paid` (integer) - `currency` (string) <Param name="accounting_provider" type="enum | null">`payday` or `dk`.
- `external_invoice_id` (string | null): The provider's id.
- `external_invoice_number` (string | null): The legal invoice number issued by the provider.
- `pdf_url` (string | null): Provider-hosted PDF, when available.
- `sync_error_message` (string | null): Set when `status` is `sync_failed`.
- `external_reference` (string | null): Copied from the payment.
- `billing` (object): `name`, `email`, `kennitala`, `vat_number`, `address` used on the invoice.
- `lines` (array): Present when retrieving: `id`, `description`, `quantity`, `unit_amount`, `tax_rate`, `tax_amount`, `accounting_code`.
- `finalized_at` (timestamp | null)
- `paid_at` (timestamp | null)
- `created_at` (timestamp)

## Retrieve an invoice

`GET /v1/invoices/:id`

```bash
curl https://api.borga.is/v1/invoices/inv_3Ef5Gh7Ij9Kl1Mn3Op5Qr7St \
  -H "Authorization: Bearer sk_test_…"
```

## List invoices

`GET /v1/invoices`

**Query parameters**

- `status` (enum)
- `limit` (integer)
- `starting_after` (string)

```ts Node.js
const { data, has_more } = await borga.invoices.list({ status: "paid", limit: 50 });

for (const invoice of data) {
  console.log(invoice.external_invoice_number, invoice.total, invoice.pdf_url);
}

if (has_more) {
  const next = await borga.invoices.list({
    status: "paid",
    starting_after: data[data.length - 1].id,
  });
  console.log(next.data.length);
}
```
