curl --request POST \
--url https://api.watchdog.no/v1/invoices/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"primary_document_id": "11111111-1111-4111-8111-111111111111"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({primary_document_id: '11111111-1111-4111-8111-111111111111'})
};
fetch('https://api.watchdog.no/v1/invoices/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/invoices/imports"
payload = { "primary_document_id": "11111111-1111-4111-8111-111111111111" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"supersedes_invoice": true,
"deleted_at": "2023-11-07T05:31:56Z",
"primary_document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source_count": 1,
"attachment_count": 1,
"retryable": true,
"provenance": {
"uploader": {
"user_id": "<string>",
"name": "<string>",
"deleted": true
},
"api_key": {
"name": "<string>"
},
"email": {
"sender": "<string>",
"name": "<string>"
},
"integration": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"deleted": true
}
},
"classification_reason": "<string>",
"outcome": "imported",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"failure": {
"code": "<string>",
"message": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sources": [
{
"document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"role": "primary",
"position": 123
}
],
"sources_next_cursor": "<string>",
"evidence": [
{
"stage": "inspection",
"succeeded": true,
"created_at": "2023-11-07T05:31:56Z",
"confidence_level": "high",
"confidence_reason": "<string>"
}
]
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"supersedes_invoice": true,
"deleted_at": "2023-11-07T05:31:56Z",
"primary_document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source_count": 1,
"attachment_count": 1,
"retryable": true,
"provenance": {
"uploader": {
"user_id": "<string>",
"name": "<string>",
"deleted": true
},
"api_key": {
"name": "<string>"
},
"email": {
"sender": "<string>",
"name": "<string>"
},
"integration": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"deleted": true
}
},
"classification_reason": "<string>",
"outcome": "imported",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"failure": {
"code": "<string>",
"message": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sources": [
{
"document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"role": "primary",
"position": 123
}
],
"sources_next_cursor": "<string>",
"evidence": [
{
"stage": "inspection",
"succeeded": true,
"created_at": "2023-11-07T05:31:56Z",
"confidence_level": "high",
"confidence_reason": "<string>"
}
]
}{
"error": {
"code": "validation_error",
"message": "The request is invalid. details lists up to 20 field errors. Request bodies are limited to 2 MiB.",
"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, or invoice_processing_capacity_exhausted: the organization has no invoice processing capacity left. Nothing was imported.",
"request_id": "req_example"
}
}{
"error": {
"code": "conflict",
"message": "conflict: the Idempotency-Key was used with a different request, the import cannot be changed in its current state, or a document already belongs to another invoice. source_unavailable: an uploaded file is missing or has changed.",
"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": "The service is temporarily unavailable. If error.import_id is present, the import exists: read its status before retrying.",
"request_id": "req_example"
}
}Import an invoice from documents
Imports an invoice from one uploaded primary document and up to 50 attachments (each file at least 100 bytes; the primary up to 50 MiB, attachments up to 25 MiB). Poll GET /v1/invoices/imports/ until status is completed, failed or cancelled. A completed import has outcome imported, duplicate or not_invoice; when it has an invoice_id, poll the invoice until workflows.settled.
The primary document must be a PDF or an XML invoice or credit note (Peppol BIS Billing 3.0 or EHF 2.0); any other file fails the import with validation_error. If the XML cannot be used, an attached PDF or HTML version of the same invoice is used instead. Attachments can be any file type, such as spreadsheets, Word documents or emails; they are read when the invoice is checked.
If the primary document is already an invoice’s primary document, the import completes at once as a duplicate of that invoice, without using capacity. Each new import uses invoice processing capacity. Idempotency-Key is optional; a replay returns the same import in its current state.
curl --request POST \
--url https://api.watchdog.no/v1/invoices/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"primary_document_id": "11111111-1111-4111-8111-111111111111"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({primary_document_id: '11111111-1111-4111-8111-111111111111'})
};
fetch('https://api.watchdog.no/v1/invoices/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/invoices/imports"
payload = { "primary_document_id": "11111111-1111-4111-8111-111111111111" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"supersedes_invoice": true,
"deleted_at": "2023-11-07T05:31:56Z",
"primary_document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source_count": 1,
"attachment_count": 1,
"retryable": true,
"provenance": {
"uploader": {
"user_id": "<string>",
"name": "<string>",
"deleted": true
},
"api_key": {
"name": "<string>"
},
"email": {
"sender": "<string>",
"name": "<string>"
},
"integration": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"deleted": true
}
},
"classification_reason": "<string>",
"outcome": "imported",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"failure": {
"code": "<string>",
"message": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sources": [
{
"document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"role": "primary",
"position": 123
}
],
"sources_next_cursor": "<string>",
"evidence": [
{
"stage": "inspection",
"succeeded": true,
"created_at": "2023-11-07T05:31:56Z",
"confidence_level": "high",
"confidence_reason": "<string>"
}
]
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"supersedes_invoice": true,
"deleted_at": "2023-11-07T05:31:56Z",
"primary_document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source_count": 1,
"attachment_count": 1,
"retryable": true,
"provenance": {
"uploader": {
"user_id": "<string>",
"name": "<string>",
"deleted": true
},
"api_key": {
"name": "<string>"
},
"email": {
"sender": "<string>",
"name": "<string>"
},
"integration": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"type": "<string>",
"deleted": true
}
},
"classification_reason": "<string>",
"outcome": "imported",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workflow_run_item_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"failure": {
"code": "<string>",
"message": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"sources": [
{
"document": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"file_name": "<string>",
"mime_type": "<string>",
"file_size": 123,
"page_count": 123,
"md5_checksum": "<string>",
"properties": {
"kind": "workbook",
"sheets": [
{
"name": "<string>",
"hidden": true,
"row_count": 1
}
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"version": 123,
"previous_version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"role": "primary",
"position": 123
}
],
"sources_next_cursor": "<string>",
"evidence": [
{
"stage": "inspection",
"succeeded": true,
"created_at": "2023-11-07T05:31:56Z",
"confidence_level": "high",
"confidence_reason": "<string>"
}
]
}{
"error": {
"code": "validation_error",
"message": "The request is invalid. details lists up to 20 field errors. Request bodies are limited to 2 MiB.",
"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, or invoice_processing_capacity_exhausted: the organization has no invoice processing capacity left. Nothing was imported.",
"request_id": "req_example"
}
}{
"error": {
"code": "conflict",
"message": "conflict: the Idempotency-Key was used with a different request, the import cannot be changed in its current state, or a document already belongs to another invoice. source_unavailable: an uploaded file is missing or has changed.",
"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": "The service is temporarily unavailable. If error.import_id is present, the import exists: read its status before retrying.",
"request_id": "req_example"
}
}Authorizations
Personal API key sent as a bearer token, together with X-Organization-Id. The key must have at least the access level the endpoint requires (read, write or admin).
Headers
The organization to act in. Required for personal API keys; list the organizations you can access with GET /v1/organizations.
Optional protection for safely retrying a request after a timeout or lost response. Choose a unique value (for example, a UUID) for each action and reuse it with the same input when retrying. Omit it for a normal request.
1 - 200^[\x21-\x7e]+$Body
Response
Idempotent replay: the same import in its current state.
queued, running, completed, failed, cancelled How the invoice was submitted.
upload, api, email, integration True when this import replaces an existing invoice from the same source.
Show child attributes
Show child attributes
x >= 0x >= 0Whether the import can be retried.
Show child attributes
Show child attributes
imported, duplicate, not_invoice, null Show child attributes
Show child attributes
Show child attributes
Show child attributes
The latest result of each extraction step, for diagnostics. More steps may be added.
4Show child attributes
Show child attributes