curl --request PATCH \
--url https://api.watchdog.no/v1/invoices/{id}/coding \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({line_item_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.watchdog.no/v1/invoices/{id}/coding', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/invoices/{id}/coding"
payload = { "line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text){
"state": "ready",
"open_field_count": 123,
"nothing_to_post": true,
"suggesting": true,
"dimensions": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "department",
"name": "<string>",
"is_active": true
}
],
"lines": [
{
"line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"line_number": 123,
"total_excluding_vat": "<string>",
"account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"number": "<string>",
"name": "<string>",
"is_active": true,
"default_vat_code_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_locked": true,
"allowed_vat_code_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"required_dimension_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"vat_code": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"rate": "<string>",
"is_active": true
},
"dimension_values": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"is_active": true
}
],
"state": "ready",
"open_fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"not_booked": true,
"expected_fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"dimension_needs": [
{
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"need": "required",
"alternatives": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"invoice_count": 123
}
]
}
],
"problems": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reason": "inactive"
}
],
"source": "manual",
"fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "suggested",
"reason": {
"proposer": "precedent",
"rule": "same_line",
"invoice_count": 123,
"certainty": "sure"
}
}
],
"updated_at": "2023-11-07T05:31:56Z",
"updated_by_user_id": "<string>"
}
],
"groups": [
{
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_code_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_value_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"line_item_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"total_excluding_vat": "<string>"
}
],
"voucher": {
"status": "draft",
"source_system": "<string>",
"system_name": "<string>",
"number": "<string>",
"url": "<string>",
"company_currency": "<string>",
"postings": [
{
"kind": "cost",
"account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"vat_code": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"dimensions": [
{
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension": "<string>",
"value_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
}
],
"amount": "<string>",
"amount_gross": "<string>",
"currency": "<string>",
"company_amount": "<string>",
"company_amount_gross": "<string>",
"line_item_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
],
"differences": [
{
"posting": 123,
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension": "<string>",
"booked": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"watchdog": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
}
}
]
}
}{
"error": {
"code": "validation_error",
"message": "A code is not an active one of the connection, the line does not fit, or the invoice is sent for approval and the line would not be complete and valid.",
"request_id": "req_example"
}
}{
"error": {
"code": "invalid_token",
"message": "The bearer token is missing or invalid.",
"request_id": "req_example"
}
}{
"error": {
"code": "forbidden",
"message": "Access denied. The error code says why: forbidden, token_disabled, organization_required, insufficient_role or mfa_required.",
"request_id": "req_example"
}
}{
"error": {
"code": "not_found",
"message": "The resource does not exist in the current organization.",
"request_id": "req_example"
}
}{
"error": {
"code": "conflict",
"message": "The invoice is deleted or in its accounting system, the organization has no connection to code with, or other work is changing the invoice (retry).",
"request_id": "req_example"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Wait for the Retry-After delay before retrying.",
"request_id": "req_example"
}
}{
"error": {
"code": "internal_error",
"message": "Unexpected server failure. Include the request ID when contacting support.",
"request_id": "req_example"
}
}{
"error": {
"code": "service_unavailable",
"message": "Temporarily unavailable. Retry after the Retry-After delay, when provided.",
"request_id": "req_example"
}
}Code invoice lines
Coding is how the invoice posts in the accounting system: an account, a VAT code and dimension values per line, from the organization’s vocabulary, which its accounting connections sync (list it with listLedgerAccounts, listVatCodes and listDimensionValues). Sets the account, VAT code or dimension values of one line, all existing lines with line_item_id: all, or selected lines with an array of line IDs. All-line and selected-line edits are atomic and preserve every field left out, including VAT and dimensions when changing the account; incompatible VAT codes are refused rather than replaced. Single-line account edits retain their existing automatic VAT and dimension defaults. Only active codes of the organization’s connection can be set. Once the invoice is sent for approval (locked), only its approvers, the AP team and admins change its coding, approvals given stay, and the line must stay complete and valid: change a value, remove an optional dimension, or switch account with the dimensions it requires in the same request; removing the account, the VAT code or a required dimension returns 400. Once it is in its accounting system its coding no longer changes (409). The change is recorded in the invoice’s activity.
curl --request PATCH \
--url https://api.watchdog.no/v1/invoices/{id}/coding \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({line_item_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.watchdog.no/v1/invoices/{id}/coding', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/invoices/{id}/coding"
payload = { "line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text){
"state": "ready",
"open_field_count": 123,
"nothing_to_post": true,
"suggesting": true,
"dimensions": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "department",
"name": "<string>",
"is_active": true
}
],
"lines": [
{
"line_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"line_number": 123,
"total_excluding_vat": "<string>",
"account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"number": "<string>",
"name": "<string>",
"is_active": true,
"default_vat_code_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_locked": true,
"allowed_vat_code_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"required_dimension_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
},
"vat_code": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"rate": "<string>",
"is_active": true
},
"dimension_values": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"is_active": true
}
],
"state": "ready",
"open_fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"not_booked": true,
"expected_fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"dimension_needs": [
{
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"need": "required",
"alternatives": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>",
"invoice_count": 123
}
]
}
],
"problems": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reason": "inactive"
}
],
"source": "manual",
"fields": [
{
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "suggested",
"reason": {
"proposer": "precedent",
"rule": "same_line",
"invoice_count": 123,
"certainty": "sure"
}
}
],
"updated_at": "2023-11-07T05:31:56Z",
"updated_by_user_id": "<string>"
}
],
"groups": [
{
"ledger_account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_code_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_value_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"line_item_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"total_excluding_vat": "<string>"
}
],
"voucher": {
"status": "draft",
"source_system": "<string>",
"system_name": "<string>",
"number": "<string>",
"url": "<string>",
"company_currency": "<string>",
"postings": [
{
"kind": "cost",
"account": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"vat_code": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"dimensions": [
{
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension": "<string>",
"value_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
}
],
"amount": "<string>",
"amount_gross": "<string>",
"currency": "<string>",
"company_amount": "<string>",
"company_amount_gross": "<string>",
"line_item_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
],
"differences": [
{
"posting": 123,
"field": "account",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension": "<string>",
"booked": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
},
"watchdog": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"name": "<string>"
}
}
]
}
}{
"error": {
"code": "validation_error",
"message": "A code is not an active one of the connection, the line does not fit, or the invoice is sent for approval and the line would not be complete and valid.",
"request_id": "req_example"
}
}{
"error": {
"code": "invalid_token",
"message": "The bearer token is missing or invalid.",
"request_id": "req_example"
}
}{
"error": {
"code": "forbidden",
"message": "Access denied. The error code says why: forbidden, token_disabled, organization_required, insufficient_role or mfa_required.",
"request_id": "req_example"
}
}{
"error": {
"code": "not_found",
"message": "The resource does not exist in the current organization.",
"request_id": "req_example"
}
}{
"error": {
"code": "conflict",
"message": "The invoice is deleted or in its accounting system, the organization has no connection to code with, or other work is changing the invoice (retry).",
"request_id": "req_example"
}
}{
"error": {
"code": "rate_limit_exceeded",
"message": "Too many requests. Wait for the Retry-After delay before retrying.",
"request_id": "req_example"
}
}{
"error": {
"code": "internal_error",
"message": "Unexpected server failure. Include the request ID when contacting support.",
"request_id": "req_example"
}
}{
"error": {
"code": "service_unavailable",
"message": "Temporarily unavailable. Retry after the Retry-After delay, when provided.",
"request_id": "req_example"
}
}Authorizations
Headers
Body
Response
The invoice’s coding.
The worst state of its lines; unavailable without accounts payable or synced accounts; booked once the accounting system has posted its booking (see voucher), which is its coding: no lines, nothing to fill and nothing suggested.
ready, needs_input, invalid, unavailable, booked