> ## 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.

# Sync invoices to your accounting software

> Connect Borga to your accounting provider to automatically sync invoices, credit notes, VAT codes, and payments — no manual exports needed.

Borga's AccountingLink feature connects your merchant account to an external accounting provider, automatically pushing invoices, VAT data, and payment records on every transaction. Once connected, every new invoice Borga generates is synced to your accounting software without any manual intervention.

## Supported providers

Retrieve the list of providers available on your platform:

```bash theme={null}
curl https://api.borga.is/v1/accounting_link/providers \
  -H "Authorization: Bearer sk_live_…" \
  -H "X-Merchant-Id: mer_xxx"
```

This returns a list of provider objects. Some providers use OAuth (you are redirected to authorize), and others (such as DK+) use a form-based credential flow.

## Connect a provider

<Steps>
  <Step title="Start the connection">
    Call `POST /v1/accounting_link/connect` to initiate. For OAuth providers, the response contains a `redirect_url` — send the merchant there to authorize access.

    ```bash theme={null}
    curl -X POST https://api.borga.is/v1/accounting_link/connect \
      -H "Authorization: Bearer sk_live_…" \
      -H "X-Merchant-Id: mer_xxx" \
      -H "Content-Type: application/json" \
      -d '{"provider": "my_provider"}'
    ```

    ```json theme={null}
    {
      "redirect_url": "https://oauth.provider.is/authorize?..."
    }
    ```
  </Step>

  <Step title="Complete the authorization">
    **OAuth providers:** After the merchant authorizes, the provider redirects to Borga's callback endpoint at `/v1/accounting_link/callback/{provider}`. Borga exchanges the code and saves credentials automatically.

    **Form-based providers (e.g. DK+):** Skip the redirect. Post credentials directly:

    ```bash theme={null}
    curl -X POST https://api.borga.is/v1/accounting_link/complete \
      -H "Authorization: Bearer sk_live_…" \
      -H "X-Merchant-Id: mer_xxx" \
      -H "Content-Type: application/json" \
      -d '{"provider": "dk_plus", "username": "...", "password": "..."}'
    ```
  </Step>

  <Step title="Configure VAT and GL account mapping">
    Fetch your chart of accounts and VAT codes from the connected provider:

    ```bash theme={null}
    curl https://api.borga.is/v1/accounting_link/chart_of_accounts \
      -H "Authorization: Bearer sk_live_…" \
      -H "X-Merchant-Id: mer_xxx"

    curl https://api.borga.is/v1/accounting_link/vat_codes \
      -H "Authorization: Bearer sk_live_…" \
      -H "X-Merchant-Id: mer_xxx"
    ```

    Then update your settings to map Borga's VAT categories to the correct codes and set the default GL account:

    ```bash theme={null}
    curl -X POST https://api.borga.is/v1/accounting_link/settings \
      -H "Authorization: Bearer sk_live_…" \
      -H "X-Merchant-Id: mer_xxx" \
      -H "Content-Type: application/json" \
      -d '{
        "default_gl_account": "5000",
        "vat_code_mapping": {
          "standard": "VSK24"
        }
      }'
    ```
  </Step>

  <Step title="Invoices sync automatically">
    From this point, every new invoice Borga generates is pushed to your accounting provider. Existing invoices are not retroactively synced.

    If an invoice fails to sync, you can trigger a retry from the **Invoices** section of the Borga dashboard by selecting the invoice and clicking **Retry sync**.
  </Step>
</Steps>

## Check or disconnect

Retrieve your current accounting link status:

```bash theme={null}
curl https://api.borga.is/v1/accounting_link \
  -H "Authorization: Bearer sk_live_…" \
  -H "X-Merchant-Id: mer_xxx"
```

To disconnect:

```bash theme={null}
curl -X DELETE https://api.borga.is/v1/accounting_link \
  -H "Authorization: Bearer sk_live_…" \
  -H "X-Merchant-Id: mer_xxx"
```

<Note>
  AccountingLink is scoped per mode. Your test mode and live mode each have separate accounting connections. Configure them independently in the dashboard.
</Note>
