Invoice lines

The rows of an invoice. Lines can be added, changed, reordered and removed while the invoice is a draft; every change recalculates the invoice's totals and its ROT/RUT deduction line. On an issued invoice every write answers 409.

List an invoice's lines

GET/invoices/{invoice}/lines

Every line of the invoice in printed order, including the generated ROT/RUT line (is_generated: true), which always comes last. Not paginated: a page holding part of an invoice is a subtotal nobody can use.

curl 'https://api.closepact.com/v1/api/invoices/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40/lines' \
  -H "Authorization: Bearer $CLOSEPACT_API_KEY"
Response · 200
{
  "data": [
    {
      "id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "sort_order": 1,
      "description": "A short description.",
      "quantity": 1,
      "unit": "string",
      "unit_price_cents": 125000,
      "discount_percent": 25,
      "vat_rate": 25,
      "net_cents": 125000,
      "vat_cents": 125000,
      "total_cents": 125000,
      "line_type": "goods",
      "rot_rut_eligible": true,
      "rot_rut_work_type": "Bygg",
      "is_generated": true,
      "account_code": "string",
      "article_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "work_order_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "time_entry_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "metadata": {}
    }
  ]
}

Path parameters

  • invoicestring(uuid)required

    The invoice's or credit note's id.

Responses

  • Headers

    • X-RateLimit-Limit — Requests this key may make per minute.
    • X-RateLimit-Remaining — Requests left in the current minute.
    • dataarray of objectsrequired
      • idstring(uuid)required
      • sort_orderintegerrequired
      • descriptionstringrequired
      • quantitynumberrequired

        Negative on a credit note.

      • unitstringnullablerequired

        e.g. tim, st, kvm.

      • unit_price_centsintegerrequired

        Excluding VAT.

      • discount_percentnumberrequired
      • vat_ratenumberrequired

        Moms in percent: 25, 12, 6 or 0.

      • net_centsintegerrequired
      • vat_centsintegerrequired
      • total_centsintegerrequired
      • line_typestringrequired

        Only labour and service can carry a ROT/RUT deduction. rot_rut_deduction is the generated deduction line.

        One ofgoodsservicelabourtravelfeerot_rut_deduction

      • rot_rut_eligiblebooleanrequired
      • rot_rut_work_typestringnullablerequired

        Skatteverket's category for ROT or RUT work, as named in its claim file schema (version 6): Bygg to Vvs are ROT, Stadning to TvattVidTvattinrattning RUT. TransportTillForsaljning and TvattVidTvattinrattning are flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.

        One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

      • is_generatedbooleanrequired

        True for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.

      • account_codestringnullablerequired

        BAS sales account, e.g. 3001 (25 %), 3002 (12 %), 3003 (6 %).

      • article_idstring(uuid)nullablerequired

        The article it was copied from, for traceability.

      • work_order_idstring(uuid)nullablerequired
      • time_entry_idstring(uuid)nullablerequired
      • metadataobject | array of valuesrequired

        On the deduction line: eligible_gross_cents, rate_percent, customer_pays_cents. An empty list otherwise.

  • 401No key, or the key is invalid, revoked or expired, or its creator no longer has access.
    Errors
  • 402The organization has not bought the module this endpoint belongs to, or it has lapsed to read-only, or its tier does not include what the operation needs: feature names the capability (the operation's x-feature) and required_tier the cheapest tier that grants it. Every operation answers this with "feature": "core.api" when no module the organization holds is on a tier that includes the API.
    Errors
  • 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (module_seat_required — an administrator assigns seats under Settings → Users), or the organization is suspended.
    Errors
  • 404No such record in this organization.
    Errors
  • 429The key has made more requests this minute than its limit allows.
    Errors

Add a line

POST/invoices/{invoice}/lines
Scope write Module Invoicing Permission invoicing.invoices.manage

Adds a line at the end of a draft and recalculates the invoice.

From an article. Send article_id and the article's name, unit, price, VAT rate, BAS account and ROT/RUT eligibility are copied onto the line. Anything you send beside it wins — an agreed price for one job does not belong in the price list. The line keeps article_id for traceability; later changes to the article do not touch it.

By hand. description is required; quantity defaults to 1, unit_price_cents (öre, excluding VAT) to 0, vat_rate to 25 and line_type to goods.

Arithmetic. net = quantity × unit price × (1 − discount), rounded to the öre; VAT = net × rate. quantity may be fractional (2.5 hours, 13.75 m²). vat_rate must be 25, 12, 6 or 0 — anything else is a 422 naming the four rates.

ROT/RUT. A line counts towards the deduction only if it is labour or service and rot_rut_eligible — a material line never does, whatever the flag. The deduction line itself cannot be written (409); set rot_rut on the invoice instead.

curl -X POST 'https://api.closepact.com/v1/api/invoices/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40/lines' \
  -H "Authorization: Bearer $CLOSEPACT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "article_id": "01a159f8-2d6a-7b3e-9f1c-8e4a2d7b5c63",
  "quantity": 4
}'
Response · 201
{
  "data": {
    "id": "01a15b02-7c2e-7148-a9f3-6d2b8e5c1f40",
    "sort_order": 0,
    "description": "Hemstädning",
    "quantity": 4,
    "unit": "tim",
    "unit_price_cents": 45000,
    "discount_percent": 0,
    "vat_rate": 25,
    "net_cents": 180000,
    "vat_cents": 45000,
    "total_cents": 225000,
    "line_type": "labour",
    "rot_rut_eligible": true,
    "rot_rut_work_type": "Stadning",
    "is_generated": false,
    "account_code": "3001",
    "article_id": "01a159f8-2d6a-7b3e-9f1c-8e4a2d7b5c63",
    "work_order_id": null,
    "time_entry_id": null,
    "metadata": []
  }
}

Path parameters

  • invoicestring(uuid)required

    The invoice's or credit note's id.

Request body

application/json · required

The writable fields of a line. description is required when adding a line without article_id; on update every field is optional.

  • article_idstring(uuid)nullable

    Copy name, unit, price, VAT rate, account and eligibility from this article.

  • work_order_idstring(uuid)nullable
  • time_entry_idstring(uuid)nullable
  • descriptionstring

    at most 500 characters

  • quantitynumber

    Default 1

  • unitstringnullable

    at most 32 characters

  • unit_price_centsinteger

    Öre, excluding VAT.

    Default 0

  • discount_percentnumber

    Default 00–100

  • vat_ratenumber

    One of251260

    Default 25

  • line_typestring

    One ofgoodsservicelabourtravelfee

    Default "goods"

  • rot_rut_eligibleboolean

    Default false

  • rot_rut_work_typestringnullable

    Skatteverket's category for this line's work — or, on a goods line, for the work the material was for. Null falls back to the invoice's rot_rut_work_type.

    One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

  • account_codestringnullable

    at most 8 characters

  • sort_orderinteger

    ≥ 0

Responses

  • Headers

    • X-RateLimit-Limit — Requests this key may make per minute.
    • X-RateLimit-Remaining — Requests left in the current minute.
    • dataobjectrequired

      A row of an invoice. Amounts in öre.

      • idstring(uuid)required
      • sort_orderintegerrequired
      • descriptionstringrequired
      • quantitynumberrequired

        Negative on a credit note.

      • unitstringnullablerequired

        e.g. tim, st, kvm.

      • unit_price_centsintegerrequired

        Excluding VAT.

      • discount_percentnumberrequired
      • vat_ratenumberrequired

        Moms in percent: 25, 12, 6 or 0.

      • net_centsintegerrequired
      • vat_centsintegerrequired
      • total_centsintegerrequired
      • line_typestringrequired

        Only labour and service can carry a ROT/RUT deduction. rot_rut_deduction is the generated deduction line.

        One ofgoodsservicelabourtravelfeerot_rut_deduction

      • rot_rut_eligiblebooleanrequired
      • rot_rut_work_typestringnullablerequired

        Skatteverket's category for ROT or RUT work, as named in its claim file schema (version 6): Bygg to Vvs are ROT, Stadning to TvattVidTvattinrattning RUT. TransportTillForsaljning and TvattVidTvattinrattning are flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.

        One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

      • is_generatedbooleanrequired

        True for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.

      • account_codestringnullablerequired

        BAS sales account, e.g. 3001 (25 %), 3002 (12 %), 3003 (6 %).

      • article_idstring(uuid)nullablerequired

        The article it was copied from, for traceability.

      • work_order_idstring(uuid)nullablerequired
      • time_entry_idstring(uuid)nullablerequired
      • metadataobject | array of valuesrequired

        On the deduction line: eligible_gross_cents, rate_percent, customer_pays_cents. An empty list otherwise.

  • 401No key, or the key is invalid, revoked or expired, or its creator no longer has access.
    Errors
  • 402The organization has not bought the module this endpoint belongs to, or it has lapsed to read-only, or its tier does not include what the operation needs: feature names the capability (the operation's x-feature) and required_tier the cheapest tier that grants it. Every operation answers this with "feature": "core.api" when no module the organization holds is on a tier that includes the API.
    Errors
  • 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (module_seat_required — an administrator assigns seats under Settings → Users), or the organization is suspended.
    Errors
  • 404No such record in this organization.
    Errors
  • 409The request is well-formed but the invoice's state does not allow it — for example it has already been issued, has no lines, or has been credited in full. error is always conflict; the message says what to do instead.
    Errors
  • 422The request body or query failed validation.
    Errors
  • 429The key has made more requests this minute than its limit allows.
    Errors

Reorder the lines

POST/invoices/{invoice}/lines/reorder
Scope write Module Invoicing Permission invoicing.invoices.manage

Sets the printed order of a draft's lines. ids must name every line exactly once — except the generated ROT/RUT line, which always stays last and is not named — or the answer is 409 saying how many were expected. Answers with all lines in their new order.

curl -X POST 'https://api.closepact.com/v1/api/invoices/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40/lines/reorder' \
  -H "Authorization: Bearer $CLOSEPACT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": [
    "01a15b02-7c41-72d6-b5e8-1a7f3c9d2e85",
    "01a15b02-7c2e-7148-a9f3-6d2b8e5c1f40"
  ]
}'
Response · 200
{
  "data": [
    {
      "id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "sort_order": 1,
      "description": "A short description.",
      "quantity": 1,
      "unit": "string",
      "unit_price_cents": 125000,
      "discount_percent": 25,
      "vat_rate": 25,
      "net_cents": 125000,
      "vat_cents": 125000,
      "total_cents": 125000,
      "line_type": "goods",
      "rot_rut_eligible": true,
      "rot_rut_work_type": "Bygg",
      "is_generated": true,
      "account_code": "string",
      "article_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "work_order_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "time_entry_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
      "metadata": {}
    }
  ]
}

Path parameters

  • invoicestring(uuid)required

    The invoice's or credit note's id.

Request body

application/json · required

  • idsarray of strings(uuid)required

    Line ids in the order they should be printed.

    at least 1 item

Responses

  • Headers

    • X-RateLimit-Limit — Requests this key may make per minute.
    • X-RateLimit-Remaining — Requests left in the current minute.
    • dataarray of objectsrequired
      • idstring(uuid)required
      • sort_orderintegerrequired
      • descriptionstringrequired
      • quantitynumberrequired

        Negative on a credit note.

      • unitstringnullablerequired

        e.g. tim, st, kvm.

      • unit_price_centsintegerrequired

        Excluding VAT.

      • discount_percentnumberrequired
      • vat_ratenumberrequired

        Moms in percent: 25, 12, 6 or 0.

      • net_centsintegerrequired
      • vat_centsintegerrequired
      • total_centsintegerrequired
      • line_typestringrequired

        Only labour and service can carry a ROT/RUT deduction. rot_rut_deduction is the generated deduction line.

        One ofgoodsservicelabourtravelfeerot_rut_deduction

      • rot_rut_eligiblebooleanrequired
      • rot_rut_work_typestringnullablerequired

        Skatteverket's category for ROT or RUT work, as named in its claim file schema (version 6): Bygg to Vvs are ROT, Stadning to TvattVidTvattinrattning RUT. TransportTillForsaljning and TvattVidTvattinrattning are flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.

        One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

      • is_generatedbooleanrequired

        True for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.

      • account_codestringnullablerequired

        BAS sales account, e.g. 3001 (25 %), 3002 (12 %), 3003 (6 %).

      • article_idstring(uuid)nullablerequired

        The article it was copied from, for traceability.

      • work_order_idstring(uuid)nullablerequired
      • time_entry_idstring(uuid)nullablerequired
      • metadataobject | array of valuesrequired

        On the deduction line: eligible_gross_cents, rate_percent, customer_pays_cents. An empty list otherwise.

  • 401No key, or the key is invalid, revoked or expired, or its creator no longer has access.
    Errors
  • 402The organization has not bought the module this endpoint belongs to, or it has lapsed to read-only, or its tier does not include what the operation needs: feature names the capability (the operation's x-feature) and required_tier the cheapest tier that grants it. Every operation answers this with "feature": "core.api" when no module the organization holds is on a tier that includes the API.
    Errors
  • 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (module_seat_required — an administrator assigns seats under Settings → Users), or the organization is suspended.
    Errors
  • 404No such record in this organization.
    Errors
  • 409The request is well-formed but the invoice's state does not allow it — for example it has already been issued, has no lines, or has been credited in full. error is always conflict; the message says what to do instead.
    Errors
  • 422The request body or query failed validation.
    Errors
  • 429The key has made more requests this minute than its limit allows.
    Errors

Update a line

PATCH/invoices/{invoice}/lines/{line}
Scope write Module Invoicing Permission invoicing.invoices.manage

Changes only the fields you send; the line's amounts and the invoice's totals and deduction are recalculated from the result. Sending article_id copies that article onto the line again, as when adding one. The generated ROT/RUT line cannot be changed (409), and neither can any line of an issued invoice.

curl -X PATCH 'https://api.closepact.com/v1/api/invoices/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40/lines/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40' \
  -H "Authorization: Bearer $CLOSEPACT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "quantity": 3.5,
  "discount_percent": 10
}'
Response · 200
{
  "data": {
    "id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
    "sort_order": 1,
    "description": "A short description.",
    "quantity": 1,
    "unit": "string",
    "unit_price_cents": 125000,
    "discount_percent": 25,
    "vat_rate": 25,
    "net_cents": 125000,
    "vat_cents": 125000,
    "total_cents": 125000,
    "line_type": "goods",
    "rot_rut_eligible": true,
    "rot_rut_work_type": "Bygg",
    "is_generated": true,
    "account_code": "string",
    "article_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
    "work_order_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
    "time_entry_id": "01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40",
    "metadata": {}
  }
}

Path parameters

  • invoicestring(uuid)required

    The invoice's or credit note's id.

  • linestring(uuid)required

    The line's id. It must belong to this invoice, or the answer is 404.

Request body

application/json · required

The writable fields of a line. description is required when adding a line without article_id; on update every field is optional.

  • article_idstring(uuid)nullable

    Copy name, unit, price, VAT rate, account and eligibility from this article.

  • work_order_idstring(uuid)nullable
  • time_entry_idstring(uuid)nullable
  • descriptionstring

    at most 500 characters

  • quantitynumber

    Default 1

  • unitstringnullable

    at most 32 characters

  • unit_price_centsinteger

    Öre, excluding VAT.

    Default 0

  • discount_percentnumber

    Default 00–100

  • vat_ratenumber

    One of251260

    Default 25

  • line_typestring

    One ofgoodsservicelabourtravelfee

    Default "goods"

  • rot_rut_eligibleboolean

    Default false

  • rot_rut_work_typestringnullable

    Skatteverket's category for this line's work — or, on a goods line, for the work the material was for. Null falls back to the invoice's rot_rut_work_type.

    One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

  • account_codestringnullable

    at most 8 characters

  • sort_orderinteger

    ≥ 0

Responses

  • Headers

    • X-RateLimit-Limit — Requests this key may make per minute.
    • X-RateLimit-Remaining — Requests left in the current minute.
    • dataobjectrequired

      A row of an invoice. Amounts in öre.

      • idstring(uuid)required
      • sort_orderintegerrequired
      • descriptionstringrequired
      • quantitynumberrequired

        Negative on a credit note.

      • unitstringnullablerequired

        e.g. tim, st, kvm.

      • unit_price_centsintegerrequired

        Excluding VAT.

      • discount_percentnumberrequired
      • vat_ratenumberrequired

        Moms in percent: 25, 12, 6 or 0.

      • net_centsintegerrequired
      • vat_centsintegerrequired
      • total_centsintegerrequired
      • line_typestringrequired

        Only labour and service can carry a ROT/RUT deduction. rot_rut_deduction is the generated deduction line.

        One ofgoodsservicelabourtravelfeerot_rut_deduction

      • rot_rut_eligiblebooleanrequired
      • rot_rut_work_typestringnullablerequired

        Skatteverket's category for ROT or RUT work, as named in its claim file schema (version 6): Bygg to Vvs are ROT, Stadning to TvattVidTvattinrattning RUT. TransportTillForsaljning and TvattVidTvattinrattning are flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.

        One ofByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattning

      • is_generatedbooleanrequired

        True for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.

      • account_codestringnullablerequired

        BAS sales account, e.g. 3001 (25 %), 3002 (12 %), 3003 (6 %).

      • article_idstring(uuid)nullablerequired

        The article it was copied from, for traceability.

      • work_order_idstring(uuid)nullablerequired
      • time_entry_idstring(uuid)nullablerequired
      • metadataobject | array of valuesrequired

        On the deduction line: eligible_gross_cents, rate_percent, customer_pays_cents. An empty list otherwise.

  • 401No key, or the key is invalid, revoked or expired, or its creator no longer has access.
    Errors
  • 402The organization has not bought the module this endpoint belongs to, or it has lapsed to read-only, or its tier does not include what the operation needs: feature names the capability (the operation's x-feature) and required_tier the cheapest tier that grants it. Every operation answers this with "feature": "core.api" when no module the organization holds is on a tier that includes the API.
    Errors
  • 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (module_seat_required — an administrator assigns seats under Settings → Users), or the organization is suspended.
    Errors
  • 404No such record in this organization.
    Errors
  • 409The request is well-formed but the invoice's state does not allow it — for example it has already been issued, has no lines, or has been credited in full. error is always conflict; the message says what to do instead.
    Errors
  • 422The request body or query failed validation.
    Errors
  • 429The key has made more requests this minute than its limit allows.
    Errors

Delete a line

DELETE/invoices/{invoice}/lines/{line}
Scope write Module Invoicing Permission invoicing.invoices.manage

Removes a line from a draft and recalculates the invoice. The generated ROT/RUT line cannot be removed on its own (409) — set rot_rut: "none" on the invoice to drop it.

curl -X DELETE 'https://api.closepact.com/v1/api/invoices/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40/lines/01a14f2c-7c1e-7d0b-9a3e-3f5b2c8d1e40' \
  -H "Authorization: Bearer $CLOSEPACT_API_KEY"
Response · 200
{
  "deleted": true
}

Path parameters

  • invoicestring(uuid)required

    The invoice's or credit note's id.

  • linestring(uuid)required

    The line's id. It must belong to this invoice, or the answer is 404.

Responses

  • Headers

    • X-RateLimit-Limit — Requests this key may make per minute.
    • X-RateLimit-Remaining — Requests left in the current minute.
    • deletedbooleanrequired

      One oftrue

  • 401No key, or the key is invalid, revoked or expired, or its creator no longer has access.
    Errors
  • 402The organization has not bought the module this endpoint belongs to, or it has lapsed to read-only, or its tier does not include what the operation needs: feature names the capability (the operation's x-feature) and required_tier the cheapest tier that grants it. Every operation answers this with "feature": "core.api" when no module the organization holds is on a tier that includes the API.
    Errors
  • 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (module_seat_required — an administrator assigns seats under Settings → Users), or the organization is suspended.
    Errors
  • 404No such record in this organization.
    Errors
  • 409The request is well-formed but the invoice's state does not allow it — for example it has already been issued, has no lines, or has been credited in full. error is always conflict; the message says what to do instead.
    Errors
  • 429The key has made more requests this minute than its limit allows.
    Errors