# Leverantörsfakturor: Kvickd API-referens

Leverantörsfakturor i Kvickds REST-API: 10 anrop, till exempel lista leverantörsfakturor, hämta leverantörsfaktura och underlag att registrera. 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 leverantörsfakturor

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

Listar bolagets leverantörsfakturor, nyast först, valfritt filtrerat på status.

MCP-verktyg: `list_supplier_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, obetald (allt med saldo kvar, även förfallna och delbetalda), forfallen, under_betalning, slutbetald eller makulerad. |

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

## Hämta leverantörsfaktura

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

Hämtar en leverantörsfaktura med alla uppgifter.

MCP-verktyg: `get_supplier_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 | Leverantörsfakturans id (heltal), t.ex. 42. |

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

## Underlag att registrera

`GET /api/v1/companies/{orgnr}/supplier-invoices/unregistered-documents`

Lista dokument klassade som Leverantörsfaktura (uppladdade eller triage:ade från inkorgen) som ännu inte registrerats som en faktura, att registrera i reskontran.

MCP-verktyg: `list_supplier_underlag`. 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/supplier-invoices/unregistered-documents" \
  -H "X-API-Key: $KVICKD_KEY"
```

## Registrera leverantörsfaktura

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

Registrera en leverantörsfaktura (bokförs inte förrän du bokför den med book_supplier_invoice).

MCP-verktyg: `create_supplier_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. |
| `supplier_name` | kropp | text | ja |  |
| `invoice_number` | kropp | text | ja |  |
| `invoice_date` | kropp | text | ja |  |
| `lines` | kropp | lista | nej |  |
| `rounding_ore` | kropp | heltal | nej |  |
| `total_ore` | kropp | heltal | nej |  |
| `vat_ore` | kropp | heltal | nej |  |
| `due_date` | kropp | text | nej |  |
| `ocr` | kropp | text | nej |  |
| `currency` | kropp | text | nej |  |
| `expense_account` | kropp | heltal | nej |  |
| `supplier_id` | kropp | heltal | nej |  |
| `document_id` | kropp | heltal | nej |  |
| `fx_rate` | kropp | tal eller text | nej |  |
| `total_sek_ore` | kropp | heltal | nej |  |
| `delivery_date` | kropp | text | nej |  |

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

## Ändra leverantörsfaktura

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

Ändra en ännu ej bokförd leverantörsfaktura (bara medskickade fält ändras).

MCP-verktyg: `update_supplier_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 |  |
| `supplier_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 |  |
| `expense_account` | kropp | heltal | nej |  |
| `document_id` | kropp | heltal | nej |  |
| `lines` | kropp | lista | nej |  |
| `rounding_ore` | kropp | heltal | nej |  |
| `fx_rate` | kropp | tal eller text | nej |  |
| `total_sek_ore` | kropp | heltal | nej |  |

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

## Bokför leverantörsfaktura

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

Bokför en leverantörsfaktura som redan har registrerats med create_supplier_invoice, så att kostnad, ingående moms och leverantörsskuld hamnar i huvudboken (D kostnadskonto + D 2640 / K 2440).

MCP-verktyg: `book_supplier_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 | Leverantörsfakturans id (heltal), t.ex. 42. |
| `fx_rate` | kropp | tal eller text | nej | Valfritt: växelkurs i SEK per 1 enhet som användaren har angett, t.ex. 11.42. |
| `total_sek_ore` | kropp | heltal | nej | Valfritt, i stället för fx_rate: fakturans totalbelopp i SEK, i öre, som användaren har angett. |

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

## Bokför leverantörsbetalning

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

Bokför en leverantörsbetalning på en faktura.

MCP-verktyg: `register_supplier_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 |  |
| `settle` | kropp | sant/falskt | nej |  |
| `foreign_amount_minor` | kropp | heltal | nej |  |

```bash
curl -X POST "https://api.kvickd.com/api/v1/companies/5599001004/supplier-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 leverantörsbetalning

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

Backar den senast registrerade betalningen på en leverantörsfaktura med ett motverifikat, så att fakturan blir obetald igen.

MCP-verktyg: `reverse_supplier_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 | Leverantörsfakturans id (heltal), t.ex. 42. |
| `returned` | kropp | sant/falskt | nej |  |

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

## Makulera leverantörsfaktura

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

Makulera en leverantörsfaktura (återför bokföringen om den redan bokförts).

MCP-verktyg: `cancel_supplier_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/supplier-invoices/<invoice_id>/cancel" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Faktura-PDF

`POST /api/v1/companies/{orgnr}/supplier-invoices/{invoice_id}/pdf`

Generera Kvickds sammanställning av en registrerad leverantörsfaktura som PDF och spara den i dokumentarkivet (kategori Leverantörsfaktura, syns sedan via list_documents/list_policies och kan läsas/laddas ner).

MCP-verktyg: `generate_supplier_invoice_pdf`. 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/supplier-invoices/<invoice_id>/pdf" \
  -H "X-API-Key: $KVICKD_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```
