# Kundfakturor: Kvickd API-referens

Kundfakturor i Kvickds REST-API: 15 anrop, till exempel lista kundfakturor, hämta kundfaktura och utestående kundfordringar. Med parametrar, curl-exempel och MCP-verktyget som varje anrop kör.

Nyckel, gränser och felkoder: https://www.kvickd.com/api. Alla grupper: https://www.kvickd.com/api/referens. Alla adresser börjar med `https://api.kvickd.com/api/v1`. Parametrarna i sökvägen står inom klamrar, övriga skickas i query-strängen (GET och DELETE) eller som JSON i kroppen. Den fullständiga beskrivningen med scheman finns i OpenAPI-filen: https://api.kvickd.com/api/v1/openapi.json

## Lista kundfakturor

`GET /api/v1/companies/{orgnr}/customer-invoices`

Listar bolagets kundfakturor, nyast först, valfritt filtrerade på status.

MCP-verktyg: `list_customer_invoices`. Läser, ändrar inget.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `status` | query | text | nej | Valfritt filter: ej_bokford (utkast), obetald (allt med saldo kvar, även förfallna och delbetalda), forfallen, under_betalning (delbetald), slutbetald eller makulerad. |

```bash
curl "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Hämta kundfaktura

`GET /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}`

Hämtar en kundfaktura med alla uppgifter.

MCP-verktyg: `get_customer_invoice`. Läser, ändrar inget.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja | Kundfakturans id (heltal), t.ex. 42. |

```bash
curl "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Utestående kundfordringar

`GET /api/v1/companies/{orgnr}/customer-invoices/outstanding`

Visar utestående kundfordringar per kund: hur mycket som är obetalt och hur mycket som har förfallit.

MCP-verktyg: `customer_outstanding`. Läser, ändrar inget.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |

```bash
curl "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/outstanding" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Skapa kundfaktura

`POST /api/v1/companies/{orgnr}/customer-invoices`

Skapa en kundfaktura (utkast; bokförs inte förrän du bokför den).

MCP-verktyg: `create_customer_invoice`. Skriver.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `customer_name` | kropp | text | ja |  |
| `invoice_date` | kropp | text | ja |  |
| `invoice_number` | kropp | text | nej |  |
| `customer_id` | kropp | heltal | nej |  |
| `lines` | kropp | lista | nej |  |
| `due_date` | kropp | text | nej |  |
| `ocr` | kropp | text | nej |  |
| `income_account` | kropp | heltal | nej |  |
| `total_ore` | kropp | heltal | nej |  |
| `vat_ore` | kropp | heltal | nej |  |
| `currency` | kropp | text | nej |  |
| `rounding_ore` | kropp | heltal | nej |  |
| `customer_orgnr` | kropp | text | nej |  |
| `customer_address` | kropp | text | nej |  |
| `customer_email` | kropp | text | nej |  |
| `customer_reference` | kropp | text | nej |  |
| `payment_terms` | kropp | text | nej |  |
| `service_description` | kropp | text | nej |  |
| `seller_address` | kropp | text | nej |  |
| `seller_bank` | kropp | text | nej |  |
| `seller_iban` | kropp | text | nej |  |
| `seller_bic` | kropp | text | nej |  |
| `seller_bankgiro` | kropp | text | nej |  |
| `seller_contact` | kropp | text | nej |  |
| `husarbete` | kropp | objekt | nej |  |
| `customer_vat_number` | kropp | text | nej |  |
| `customer_country` | kropp | text | nej |  |
| `vat_mode` | kropp | text | nej |  |
| `show_late_interest` | kropp | sant/falskt | nej |  |
| `delivery_date` | kropp | text | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customer_name":"<customer_name>","invoice_date":"<invoice_date>"}'
```

## Ändra kundfaktura

`PATCH /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}`

Ändra en EJ bokförd kundfaktura (utkast).

MCP-verktyg: `update_customer_invoice`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `customer_name` | kropp | text | nej |  |
| `invoice_number` | kropp | text | nej |  |
| `ocr` | kropp | text | nej |  |
| `invoice_date` | kropp | text | nej |  |
| `due_date` | kropp | text | nej |  |
| `total_ore` | kropp | heltal | nej |  |
| `vat_ore` | kropp | heltal | nej |  |
| `currency` | kropp | text | nej |  |
| `income_account` | kropp | heltal | nej |  |
| `rounding_ore` | kropp | heltal | nej |  |
| `lines` | kropp | lista | nej |  |
| `customer_orgnr` | kropp | text | nej |  |
| `customer_address` | kropp | text | nej |  |
| `customer_email` | kropp | text | nej |  |
| `customer_reference` | kropp | text | nej |  |
| `payment_terms` | kropp | text | nej |  |
| `service_description` | kropp | text | nej |  |
| `seller_address` | kropp | text | nej |  |
| `seller_bank` | kropp | text | nej |  |
| `seller_iban` | kropp | text | nej |  |
| `seller_bic` | kropp | text | nej |  |
| `seller_bankgiro` | kropp | text | nej |  |
| `seller_contact` | kropp | text | nej |  |
| `husarbete` | kropp | objekt | nej |  |
| `customer_vat_number` | kropp | text | nej |  |
| `customer_country` | kropp | text | nej |  |
| `vat_mode` | kropp | text | nej |  |
| `show_late_interest` | kropp | sant/falskt | nej |  |

```bash
curl -X PATCH "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Bokför kundfaktura

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/book`

Bokför en kundfaktura som redan har skapats med create_customer_invoice, så att fordran, intäkt och utgående moms hamnar i huvudboken (D 1510 / K intäkt / K moms på 2611, 2621 eller 2631 beroende på momssats).

MCP-verktyg: `book_customer_invoice`. Skriver.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja | Kundfakturans id (heltal), t.ex. 42. |
| `confirm` | kropp | sant/falskt | nej | ROT/RUT-faktura när F-skatt inte är angiven i företagsinformationen: true först när användaren har bekräftat att företaget har F-skatt. |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/book" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Bokför kundinbetalning

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/payments`

Bokför en INbetalning på en kundfaktura (D likvidkonto / K 1510).

MCP-verktyg: `register_customer_payment`. Skriver.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `pay_date` | kropp | text | ja |  |
| `amount_ore` | kropp | heltal | ja |  |
| `bank_account` | kropp | heltal | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/payments" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pay_date":"<pay_date>","amount_ore":"<amount_ore>"}'
```

## Backa kundinbetalning

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/payments/reverse`

Backa den senaste registrerade inbetalningen på en kundfaktura (postar ett omvänt verifikat, K likvidkonto / D 1510, så fakturan blir obetald igen).

MCP-verktyg: `reverse_customer_payment`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `returned` | kropp | sant/falskt | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/payments/reverse" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Skapa kreditfaktura

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/credit`

Skapa en kreditfaktura för en BOKFÖRD kundfaktura (utkast; negativa belopp, omvänd bokföring vid bokför).

MCP-verktyg: `credit_customer_invoice`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `invoice_number` | kropp | text | nej |  |
| `invoice_date` | kropp | text | nej |  |
| `lines` | kropp | lista | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/credit" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Makulera kundfaktura

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/cancel`

Makulera en kundfaktura (obetald → backar bokföringsverifikatet).

MCP-verktyg: `cancel_customer_invoice`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/cancel" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Fakturauppgifter och kundregister

`GET /api/v1/companies/{orgnr}/customer-invoices/setup`

Det som behövs för att skapa en kundfaktura: nästa fakturanummer i bolagets serie, betalningsvillkor, intäktskonto, senast fakturerade tjänster (recent_lines med pris och moms), företagsinformationen som står på fakturan (adress, momsreg.nr, F-skatt, bankgiro) och kundregistret (customers, senast fakturerade först; customer_query söker i namn, org.nr och e-post).

MCP-verktyg: `get_invoice_setup`. Läser, ändrar inget.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `customer_query` | query | text | nej |  |

```bash
curl "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/setup" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Ändra fakturainställningar

`PATCH /api/v1/companies/{orgnr}/customer-invoices/settings`

Ändrar bolagets fakturainställningar, som gäller nya fakturor och utkast: betalningsvillkor (payment_terms_days, 0-120 dagar), dröjsmålsränta (late_interest_percent = egen ränta i procent per år, eller statutory_interest=true för räntelagens nivå, referensräntan plus 8 procentenheter), show_late_interest (false: villkoret om dröjsmålsränta skrivs inte ut på fakturorna; rätten till ränta och påminnelsernas ränta påverkas inte) och påminnelseavgift (reminder_fee_ore, högst 6000 öre, 0 = ingen; får bara tas ut om den avtalats).

MCP-verktyg: `update_invoice_settings`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `payment_terms_days` | kropp | heltal | nej |  |
| `late_interest_percent` | kropp | tal | nej |  |
| `statutory_interest` | kropp | sant/falskt | nej |  |
| `show_late_interest` | kropp | sant/falskt | nej |  |
| `reminder_fee_ore` | kropp | heltal | nej |  |

```bash
curl -X PATCH "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/settings" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Skicka kundfaktura med e-post

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/send`

Skickar en BOKFÖRD kundfaktura (eller kreditfaktura) som PDF med e-post till kunden.

MCP-verktyg: `send_customer_invoice`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `to` | kropp | text | ja |  |
| `message` | kropp | text | nej |  |
| `save_customer_email` | kropp | sant/falskt | nej |  |
| `send_at` | kropp | text | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/send" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"<to>"}'
```

## Avbryt schemalagt utskick

`DELETE /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/send`

Avbryter ett schemalagt utskick av en kundfaktura (se send_customer_invoice med send_at).

MCP-verktyg: `cancel_scheduled_invoice_send`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |

```bash
curl -X DELETE "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/send" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Skicka betalningspåminnelse

`POST /api/v1/companies/{orgnr}/customer-invoices/{invoice_id}/reminders`

Skickar en betalningspåminnelse med e-post för en förfallen, obetald kundfaktura: kvarvarande belopp, nytt sista betalningsdatum och PDF.

MCP-verktyg: `send_payment_reminder`. Tar bort eller vänder något.

| Parameter | Var | Typ | Obligatorisk | Beskrivning |
| --- | --- | --- | --- | --- |
| `orgnr` | sökväg | text | ja | Bolagets organisationsnummer, 10 siffror med eller utan bindestreck, t.ex. 559900-1004. |
| `invoice_id` | sökväg | heltal | ja |  |
| `to` | kropp | text | ja |  |
| `include_fee` | kropp | sant/falskt | nej |  |
| `include_interest` | kropp | sant/falskt | nej |  |
| `message` | kropp | text | nej |  |
| `save_customer_email` | kropp | sant/falskt | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/customer-invoices/<invoice_id>/reminders" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"<to>"}'
```
