Menu

Set-offs

Kvittning: a counterparty that is both customer and supplier as one relation (open customer and supplier invoices, the net per currency, its set-offs), and setting an open customer invoice off against an open supplier invoice of the same counterparty. Served while the company has set-offs switched on.

Endpoints


GET /api/v1/companies/:companyId/setoffs/counterparty

invoices.counterparty-balance.get · scope reports:read

A counterparty that is both customer and supplier, as one relation: its open customer and supplier invoices, the net per currency and its set-offs.

Name the counterparty by exactly one of party_id, customer_id or supplier_id. Every customer and supplier card of the same legal person (one party, linked by organisation number) is included. Each open invoice says whether it can be set off now and why not (ineligible_reason). The net is receivable minus payable: above zero they pay us, below zero we pay them. Credit notes are not included.

Use when: Deciding what to set off between a customer that is also a supplier, or checking what is left to pay or receive after a set-off.

Don't use for: The full kund- or leverantörsreskontra (use the ledger reports).

Pitfalls

  • A card without an organisation number has no party until it is merged in Motparter (404 SETOFF_PARTY_NOT_FOUND).
  • Totals are per currency; only SEK invoices can be set off.

Risk: low · Idempotent: yes · Reversible: no · Dry-run supported: no

Query parameters

NameTypeRequiredDescription
party_idstringnoThe counterparty (Motparter).
customer_idstringnoA customer card of the counterparty.
supplier_idstringnoA supplier card of the counterparty.

Response fields

NameType
partyobject
customersobject[]
suppliersobject[]
receivablesobject[]
payablesobject[]
totalsobject[]
setoffsobject[]

Example request

{
  "customer_id": "6b0e…"
}

Example response

{
  "data": {
    "party": {
      "party_id": "7fc2…",
      "name": "Exempel Energi AB",
      "org_number": "5599887766"
    },
    "totals": [
      {
        "currency": "SEK",
        "receivable": 1388,
        "payable": 4504,
        "net": -3116,
        "direction": "we_pay"
      }
    ]
  },
  "meta": {
    "request_id": "req_…",
    "api_version": "2026-05-12"
  }
}

POST /api/v1/companies/:companyId/setoffs

invoices.setoff.book · scope invoices:write

Set off (kvitta) an open customer invoice against an open supplier invoice of the same counterparty: one verifikat, both invoices lowered, the net left to pay or receive.

Books Dr accounts payable / Cr accounts receivable (the accounts the invoices' own vouchers booked) for amount, at most the smaller remaining amount (the default). VAT is untouched. Both invoices get a payment row dated setoff_date and their remaining amounts go down; the net is then matched to the bank line like any part payment. A kvittningsavräkning is archived on the verifikat as underlag. SEK only; refused for credit notes, ROT/RUT invoices, invoices not booked as receivable or payable (kontantmetoden), an open collection case, or a supplier invoice with a payment on its way.

Use when: A company sells to and buys from the same legal person and settles the two against each other instead of paying both in full.

Don't use for: Settling a credit note against its invoice (credit the invoice), or recording a payment received or made (mark the invoice paid or match the bank line).

Pitfalls

  • Both cards must belong to the same counterparty (same organisation number, or merged in Motparter): 422 SETOFF_PARTY_MISMATCH / SETOFF_NO_PARTY.
  • A supplier invoice entered at the bank, in a payment file or in an open payment order is refused (409 SETOFF_PAYMENT_IN_FLIGHT): the bank would pay the full amount.
  • A mistake is undone by reversing (storno) the set-off verifikat; it is never corrected in place.

Risk: high · Idempotent: yes · Reversible: yes · Dry-run supported: yes · Stage for approval: yes (?stage=true)

Query parameters

NameTypeRequiredDescription
dry_runstringnotrue (any case) previews the write without committing it, like the X-Dry-Run: true header. Any other value commits.
stagestringnotrue stages the write for approval instead of committing it: 202 with the pending operation to approve via POST /pending-operations/{id}/approve. Absent or false commits; other values are 400. A reason in the body (why you propose it, at most 500 characters) is shown to the approver as agent_reason and kept with the decision.

Request body

NameTypeRequiredDescription
invoice_idstringyesThe open customer invoice.
supplier_invoice_idstringyesThe open supplier invoice of the same counterparty.
amountnumbernoIn SEK; the smaller of the two remaining amounts when omitted.
setoff_datestringnoThe verifikat date; today when omitted.
notestringnoThe agreement or notice the set-off rests on.
party_idstringnoThe counterparty the approver saw; refused if the invoices belong to another.

Response fields

NameType
setoff_idstring
journal_entry_idstring
voucher_seriesstring | null
voucher_numbernumber | null
party_idstring
amountnumber
setoff_datestring
invoiceobject
supplier_invoiceobject
netobject
underlag_document_idstring | null

Example request

{
  "invoice_id": "2a9c…",
  "supplier_invoice_id": "79f1…",
  "setoff_date": "2026-09-30",
  "note": "Kvittning enligt flexavtal"
}

Example response

{
  "data": {
    "setoff_id": "5d1e…",
    "journal_entry_id": "c41d…",
    "amount": 1388,
    "invoice": {
      "invoice_id": "2a9c…",
      "status": "paid",
      "remaining_amount": 0
    },
    "supplier_invoice": {
      "supplier_invoice_id": "79f1…",
      "status": "partially_paid",
      "remaining_amount": 3116
    },
    "net": {
      "direction": "we_pay",
      "amount": 3116
    }
  },
  "meta": {
    "request_id": "req_…",
    "api_version": "2026-05-12"
  }
}