Tilbake til hjelpesenteret

Integrasjoner

API: Closing invoices

Sist oppdatert: 06.10.2026

If you want to close a sales invoice, either against a credit note, or a payment you can use the EntryMatch endpoint to do that.

The EntryMatch endpoint accepts posting line ids, so to use it you will have to do the following

  1. Fetch the journal id from the sales invoice(s)
  2. Use the journal id to fetch the relevant posting lines and their ids. You use the customer’s account for closing, so make sure you select those posting lines.
  3. Provide the posting line ids and the customer’s account id to the EntryMatch. Include every posting line on the customer’s account from both sides: an invoice often has several, and the lines you match must balance to zero.

In the example where you want to match an invoice to a credit note, you will have to find journal and posting line ids for both the invoice and the credit note.

1. Fetch journal id

Query:

query($id: ID!) {
    saleInvoice(id: $id) {
        id
        bookkeepingJournal { id }
    }
}

Example response:

{
    "data": {
        "saleInvoice": {
            "id": "9DhWnW",
            "bookkeepingJournal": { "id": "4LCGvv" }
        }
    }
}

(you will have to do this twice for invoice/credit note matching)

2. Fetch posting line ids

Fetching journal: Query:

query($id: ID!){
    bookkeepingJournal(id: $id) {
        id
        postings {
            postingLines {
                id
                amountCents
                debitAccount {
                    id
                    code
                    subCode
                }
                creditAccount {
                    id
                    code
                    subCode
                }
            }
        }
    }
}

(you will have to do this twice for invoice/credit note matching)

Example response:

{
    "data": {
        "bookkeepingJournal": {
            "id": "4LCGvv",
            "postings": [ {
                "postingLines": [ {
                    "id": "JeCRVx",
                    "amountCents": "15000",
                    "debitAccount": {
                        "id": "24HJA4y",
                        "code": "1500",
                        "subCode": "10005"
                    },
                    "creditAccount": {
                        "id": "ggHNwdQ",
                        "code": "3100",
                        "subCode": null
                    }
                } ]
            } ]
        }
    }
}

3. Create an entry match

Mutation:

mutation ($postingLineId1: ID!, $postingLineId2: ID!, $accountId: ID!) {
    bookkeepingEntryMatchCreate(
        entryMatch: {postingLines: [{id: $postingLineId1}, {id: $postingLineId2}], accountId: $accountId}
    ) {
        id
        postingEntriesDebit {
            id
        }
        postingEntriesCredit {
            id
        }
    }
}

Example response:

{
    "data": {
        "bookkeepingEntryMatchCreate": {
            "id": "kQBSpD",
            "postingEntriesDebit": [ {
                "id": "JeCRVx"
            }],
            "postingEntriesCredit": [ {
                "id": "gYCr2n"
            }]
        }
    }
}

Optional, to reopen an invoice, you just delete the entry match

Mutation:

mutation ($id: ID!) {
    bookkeepingEntryMatchDestroy(id: $id) {
        id
    }
}

Response:

{
    "data": {
        "bookkeepingEntryMatchDestroy": {
            "id": "kQBSpD"
        }
    }
}

Gjør regnskapet ditt på et blunk.

Prøv gratis i dag.

Prøv gratis

Vi bruker informasjonskapsler (cookies) for å forbedre brukeropplevelsen. Les mer