> ## Documentation Index
> Fetch the complete documentation index at: https://docs.borga.is/llms.txt
> Use this file to discover all available pages before exploring further.

# Legal invoicing through PayDay.is

> Borga automatically generates legally compliant Icelandic invoices in PayDay.is for every payment — no manual bookkeeping required. Learn about invoice structure and credit notes.

Every successful payment made through Borga produces a legally compliant Icelandic invoice in [PayDay.is](https://payday.is) automatically. You do not need to generate invoices manually, integrate with a separate invoicing system, or handle Icelandic accounting regulations yourself — Borga takes care of it. Invoices are immediately available via the API and downloadable as PDFs.

## Invoice generation

Borga creates an invoice the moment a payment succeeds. The invoice is associated with the payment and, if provided, the customer record. You can retrieve all invoices with `GET /v1/invoices`, or fetch a specific invoice with `GET /v1/invoices/{id}`.

Invoices generated from subscriptions are created at the start of each billing cycle and finalized once payment is collected.

<Note>
  Invoice generation happens asynchronously after payment succeeds. If you query `GET /v1/invoices` immediately after a payment, allow a brief moment for the invoice to appear. Use webhooks to receive a notification when an invoice is finalized.
</Note>

## Invoice statuses

An invoice moves through the following statuses during its lifecycle:

| Status          | Meaning                                                                                          |
| --------------- | ------------------------------------------------------------------------------------------------ |
| `draft`         | The invoice is being assembled. Line items can still be added. Not yet sent to the customer.     |
| `open`          | The invoice has been finalized and sent. Payment is outstanding.                                 |
| `paid`          | Payment has been collected.                                                                      |
| `void`          | The invoice has been canceled. A voided invoice is replaced by a new one if rebilling is needed. |
| `uncollectible` | Payment attempts have been exhausted and the invoice is marked as a bad debt.                    |

## Invoice items

For subscription invoices in `draft` status, you can add ad-hoc line items before the invoice is finalized using `POST /v1/invoice_items`. This is useful for one-off charges — setup fees, overages, or adjustments — that should appear on the customer's next invoice.

```bash curl theme={null}
curl --request POST \
  --url https://api.borga.is/v1/invoice_items \
  --header "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  --header "X-Merchant-Id: mer_YOUR_MERCHANT_ID" \
  --header "Content-Type: application/json" \
  --data '{
    "customer": "cus_01HXYZ",
    "subscription": "sub_01HXYZ",
    "amount": 5000,
    "currency": "ISK",
    "description": "Setup fee",
    "quantity": 1
  }'
```

### Invoice item fields

| Field          | Required | Description                                                        |
| -------------- | -------- | ------------------------------------------------------------------ |
| `customer`     | Yes      | The customer the item is billed to.                                |
| `amount`       | Yes      | Amount in ISK (integer).                                           |
| `description`  | Yes      | Line item description that appears on the invoice.                 |
| `subscription` | No       | Attach this item to a specific subscription's upcoming invoice.    |
| `currency`     | No       | Defaults to `ISK`.                                                 |
| `quantity`     | No       | Multiplied by `amount` to produce the line total. Defaults to `1`. |
| `metadata`     | No       | Key-value pairs for your own data.                                 |

<Warning>
  Invoice items can only be added to invoices in `draft` status. Once an invoice is finalized (`open`, `paid`, or `void`), its line items are locked.
</Warning>

## Credit notes

When you issue a refund against a paid invoice, Borga automatically generates a credit note. A credit note is the legally required document that offsets the original invoice amount — it does not modify or void the invoice itself.

Retrieve credit notes with `GET /v1/credit_notes`. To filter by invoice, pass the invoice ID as a query parameter:

```bash curl theme={null}
curl --request GET \
  --url "https://api.borga.is/v1/credit_notes?invoice=inv_01HXYZ" \
  --header "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  --header "X-Merchant-Id: mer_YOUR_MERCHANT_ID"
```

Fetch a specific credit note with `GET /v1/credit_notes/{id}`.

<Note>
  Credit notes are generated automatically when a refund is processed. You do not need to create them manually.
</Note>

## PDF access

Every finalized invoice has a PDF available for download. Invoice PDFs are accessible directly from the Borga dashboard under **Invoices**. From the API, the invoice object includes a `pdf_url` field you can use to open or serve the PDF directly to your customers.

## Accounting sync

To sync invoices and credit notes to external accounting software such as Uniconta or DK, see the [accounting link guide](/guides/accounting-link).

<Tip>
  If you use PayDay.is directly, your Borga invoices are already present in your PayDay.is account under the same merchant registration. No additional sync is required.
</Tip>
