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
/invoices/{invoice}/linesEvery 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"{
"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)requiredThe 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 objectsrequiredidstring(uuid)requiredsort_orderintegerrequireddescriptionstringrequiredquantitynumberrequiredNegative on a credit note.
unitstringnullablerequirede.g.
tim,st,kvm.unit_price_centsintegerrequiredExcluding VAT.
discount_percentnumberrequiredvat_ratenumberrequiredMoms in percent: 25, 12, 6 or 0.
net_centsintegerrequiredvat_centsintegerrequiredtotal_centsintegerrequiredline_typestringrequiredOnly
labourandservicecan carry a ROT/RUT deduction.rot_rut_deductionis the generated deduction line.One of
goodsservicelabourtravelfeerot_rut_deductionrot_rut_eligiblebooleanrequiredrot_rut_work_typestringnullablerequiredSkatteverket's category for ROT or RUT work, as named in its claim file schema (version 6):
ByggtoVvsare ROT,StadningtoTvattVidTvattinrattningRUT.TransportTillForsaljningandTvattVidTvattinrattningare flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.One of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningis_generatedbooleanrequiredTrue for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.
account_codestringnullablerequiredBAS sales account, e.g.
3001(25 %),3002(12 %),3003(6 %).article_idstring(uuid)nullablerequiredThe article it was copied from, for traceability.
work_order_idstring(uuid)nullablerequiredtime_entry_idstring(uuid)nullablerequiredmetadataobject | array of valuesrequiredOn 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:Errors
featurenames the capability (the operation'sx-feature) andrequired_tierthe 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. - 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (Errors
module_seat_required— an administrator assigns seats under Settings → Users), or the organization is suspended. - 404No such record in this organization.Errors
- 429The key has made more requests this minute than its limit allows.Errors
Add a line
/invoices/{invoice}/linesAdds 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
}'{
"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)requiredThe 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)nullableCopy name, unit, price, VAT rate, account and eligibility from this article.
work_order_idstring(uuid)nullabletime_entry_idstring(uuid)nullabledescriptionstringat most 500 characters
quantitynumberDefault
1unitstringnullableat most 32 characters
unit_price_centsintegerÖre, excluding VAT.
Default
0discount_percentnumberDefault
00–100vat_ratenumberOne of
251260Default
25line_typestringOne of
goodsservicelabourtravelfeeDefault
"goods"rot_rut_eligiblebooleanDefault
falserot_rut_work_typestringnullableSkatteverket'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 of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningaccount_codestringnullableat 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.
dataobjectrequiredA row of an invoice. Amounts in öre.
idstring(uuid)requiredsort_orderintegerrequireddescriptionstringrequiredquantitynumberrequiredNegative on a credit note.
unitstringnullablerequirede.g.
tim,st,kvm.unit_price_centsintegerrequiredExcluding VAT.
discount_percentnumberrequiredvat_ratenumberrequiredMoms in percent: 25, 12, 6 or 0.
net_centsintegerrequiredvat_centsintegerrequiredtotal_centsintegerrequiredline_typestringrequiredOnly
labourandservicecan carry a ROT/RUT deduction.rot_rut_deductionis the generated deduction line.One of
goodsservicelabourtravelfeerot_rut_deductionrot_rut_eligiblebooleanrequiredrot_rut_work_typestringnullablerequiredSkatteverket's category for ROT or RUT work, as named in its claim file schema (version 6):
ByggtoVvsare ROT,StadningtoTvattVidTvattinrattningRUT.TransportTillForsaljningandTvattVidTvattinrattningare flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.One of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningis_generatedbooleanrequiredTrue for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.
account_codestringnullablerequiredBAS sales account, e.g.
3001(25 %),3002(12 %),3003(6 %).article_idstring(uuid)nullablerequiredThe article it was copied from, for traceability.
work_order_idstring(uuid)nullablerequiredtime_entry_idstring(uuid)nullablerequiredmetadataobject | array of valuesrequiredOn 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:Errors
featurenames the capability (the operation'sx-feature) andrequired_tierthe 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. - 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (Errors
module_seat_required— an administrator assigns seats under Settings → Users), or the organization is suspended. - 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.Errors
erroris alwaysconflict; the message says what to do instead. - 422The request body or query failed validation.Errors
- 429The key has made more requests this minute than its limit allows.Errors
Reorder the lines
/invoices/{invoice}/lines/reorderSets 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"
]
}'{
"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)requiredThe invoice's or credit note's id.
Request body
application/json · required
idsarray of strings(uuid)requiredLine 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 objectsrequiredidstring(uuid)requiredsort_orderintegerrequireddescriptionstringrequiredquantitynumberrequiredNegative on a credit note.
unitstringnullablerequirede.g.
tim,st,kvm.unit_price_centsintegerrequiredExcluding VAT.
discount_percentnumberrequiredvat_ratenumberrequiredMoms in percent: 25, 12, 6 or 0.
net_centsintegerrequiredvat_centsintegerrequiredtotal_centsintegerrequiredline_typestringrequiredOnly
labourandservicecan carry a ROT/RUT deduction.rot_rut_deductionis the generated deduction line.One of
goodsservicelabourtravelfeerot_rut_deductionrot_rut_eligiblebooleanrequiredrot_rut_work_typestringnullablerequiredSkatteverket's category for ROT or RUT work, as named in its claim file schema (version 6):
ByggtoVvsare ROT,StadningtoTvattVidTvattinrattningRUT.TransportTillForsaljningandTvattVidTvattinrattningare flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.One of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningis_generatedbooleanrequiredTrue for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.
account_codestringnullablerequiredBAS sales account, e.g.
3001(25 %),3002(12 %),3003(6 %).article_idstring(uuid)nullablerequiredThe article it was copied from, for traceability.
work_order_idstring(uuid)nullablerequiredtime_entry_idstring(uuid)nullablerequiredmetadataobject | array of valuesrequiredOn 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:Errors
featurenames the capability (the operation'sx-feature) andrequired_tierthe 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. - 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (Errors
module_seat_required— an administrator assigns seats under Settings → Users), or the organization is suspended. - 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.Errors
erroris alwaysconflict; the message says what to do instead. - 422The request body or query failed validation.Errors
- 429The key has made more requests this minute than its limit allows.Errors
Update a line
/invoices/{invoice}/lines/{line}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
}'{
"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)requiredThe invoice's or credit note's id.
linestring(uuid)requiredThe 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)nullableCopy name, unit, price, VAT rate, account and eligibility from this article.
work_order_idstring(uuid)nullabletime_entry_idstring(uuid)nullabledescriptionstringat most 500 characters
quantitynumberDefault
1unitstringnullableat most 32 characters
unit_price_centsintegerÖre, excluding VAT.
Default
0discount_percentnumberDefault
00–100vat_ratenumberOne of
251260Default
25line_typestringOne of
goodsservicelabourtravelfeeDefault
"goods"rot_rut_eligiblebooleanDefault
falserot_rut_work_typestringnullableSkatteverket'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 of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningaccount_codestringnullableat 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.
dataobjectrequiredA row of an invoice. Amounts in öre.
idstring(uuid)requiredsort_orderintegerrequireddescriptionstringrequiredquantitynumberrequiredNegative on a credit note.
unitstringnullablerequirede.g.
tim,st,kvm.unit_price_centsintegerrequiredExcluding VAT.
discount_percentnumberrequiredvat_ratenumberrequiredMoms in percent: 25, 12, 6 or 0.
net_centsintegerrequiredvat_centsintegerrequiredtotal_centsintegerrequiredline_typestringrequiredOnly
labourandservicecan carry a ROT/RUT deduction.rot_rut_deductionis the generated deduction line.One of
goodsservicelabourtravelfeerot_rut_deductionrot_rut_eligiblebooleanrequiredrot_rut_work_typestringnullablerequiredSkatteverket's category for ROT or RUT work, as named in its claim file schema (version 6):
ByggtoVvsare ROT,StadningtoTvattVidTvattinrattningRUT.TransportTillForsaljningandTvattVidTvattinrattningare flat-rate services that are claimed without hours or material. Read when the claim to Skatteverket is filed; null when none is chosen.One of
ByggElGlasPlatarbeteMarkDraneringarbeteMurningMalningTapetseringVvsStadningKladOchTextilvardSnoskottningTradgardsarbeteBarnpassningPersonligomsorgFlyttjansterItTjansterReparationAvVitvarorMobleringTillsynAvBostadTransportTillForsaljningTvattVidTvattinrattningis_generatedbooleanrequiredTrue for the ROT/RUT deduction line, which Closepact maintains and nobody can edit.
account_codestringnullablerequiredBAS sales account, e.g.
3001(25 %),3002(12 %),3003(6 %).article_idstring(uuid)nullablerequiredThe article it was copied from, for traceability.
work_order_idstring(uuid)nullablerequiredtime_entry_idstring(uuid)nullablerequiredmetadataobject | array of valuesrequiredOn 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:Errors
featurenames the capability (the operation'sx-feature) andrequired_tierthe 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. - 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (Errors
module_seat_required— an administrator assigns seats under Settings → Users), or the organization is suspended. - 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.Errors
erroris alwaysconflict; the message says what to do instead. - 422The request body or query failed validation.Errors
- 429The key has made more requests this minute than its limit allows.Errors
Delete a line
/invoices/{invoice}/lines/{line}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"{
"deleted": true
}Path parameters
invoicestring(uuid)requiredThe invoice's or credit note's id.
linestring(uuid)requiredThe 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.
deletedbooleanrequiredOne of
true
- 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:Errors
featurenames the capability (the operation'sx-feature) andrequired_tierthe 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. - 403The key lacks the scope, or the member it acts as lacks the permission or holds no seat in the module (Errors
module_seat_required— an administrator assigns seats under Settings → Users), or the organization is suspended. - 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.Errors
erroris alwaysconflict; the message says what to do instead. - 429The key has made more requests this minute than its limit allows.Errors