curl --request POST \
--url https://api.watchdog.no/v1/purchase-orders/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_ids": [],
"text": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({document_ids: [], text: '<string>'})
};
fetch('https://api.watchdog.no/v1/purchase-orders/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/purchase-orders/imports"
payload = {
"document_ids": [],
"text": "<string>"
}
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",
"outcome": "created",
"purchase_order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"intent": "new",
"missing": [
{
"field": "supplier",
"line_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>"
}
],
"not_order_reason": "<string>",
"text": true,
"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"
},
"position": 123,
"attached_to_document_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"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"outcome": "created",
"purchase_order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"intent": "new",
"missing": [
{
"field": "supplier",
"line_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>"
}
],
"not_order_reason": "<string>",
"text": true,
"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"
},
"position": 123,
"attached_to_document_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"
}{
"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. 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": "conflict: the Idempotency-Key was used with a different request. 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": "Temporarily unavailable. Retry after the Retry-After delay, when provided.",
"request_id": "req_example"
}
}Create a purchase order from documents
Reads a quote, an order confirmation, a receipt or an email thread and drafts a purchase order from it. Documents are read together as one order: PDFs, images (PNG, JPEG, WEBP), emails (.eml, .msg; their attachments are read too and attached to the order) and plain text, with optional pasted text. An import ends with one of three outcomes. created: a new order with the files attached and the gaps listed in missing; the order is a draft, or is submitted (opened, or left a draft waiting for approval under the approval rules) when the documents show it already placed, nothing is missing and the submit succeeds. duplicate: the order the same file or the same supplier and sales order reference already made gets the files attached. not_order: the sources hold no order. Poll the returned import, or follow its workflow run, until status is completed, failed or cancelled. Idempotency-Key is optional; a replay returns the same import in its current state.
curl --request POST \
--url https://api.watchdog.no/v1/purchase-orders/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_ids": [],
"text": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({document_ids: [], text: '<string>'})
};
fetch('https://api.watchdog.no/v1/purchase-orders/imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.watchdog.no/v1/purchase-orders/imports"
payload = {
"document_ids": [],
"text": "<string>"
}
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",
"outcome": "created",
"purchase_order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"intent": "new",
"missing": [
{
"field": "supplier",
"line_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>"
}
],
"not_order_reason": "<string>",
"text": true,
"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"
},
"position": 123,
"attached_to_document_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"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"origin": "upload",
"outcome": "created",
"purchase_order_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"intent": "new",
"missing": [
{
"field": "supplier",
"line_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"note": "<string>"
}
],
"not_order_reason": "<string>",
"text": true,
"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"
},
"position": 123,
"attached_to_document_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"
}{
"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. 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": "conflict: the Idempotency-Key was used with a different request. 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": "Temporarily unavailable. Retry after the Retry-After delay, when provided.",
"request_id": "req_example"
}
}Authorizations
Headers
Body
Pasted text, such as an email thread, read together with the documents.
1 - 100000Response
Idempotent replay: the same import in its current state.
created: a new order, a draft unless submitted. duplicate: the order already exists (same file, or the same supplier and sales order reference); the sources were attached to it. not_order: the sources hold no order. Null until completed.
created, duplicate, not_order, null