DocHeart Vault
Overview
This reference page contains an overview of the DocHeart Vault API. DocHeart Vault API contains endpoints that enable the user to store, list and retrieve documents inside and from DocHeart Vault.
What is DocHeart Vault? DocHeart Vault is a feature of DocHeart that enables the user to store documents. Extractions can later be triggered on documents that are inside the DocHeart vault, by providing their DocHeart Vault ID to the extraction endpoint. In other words, the DocHeart Vault enables you to separate the document upload step from the extraction step.
The DocHeart Vault API supports all basic operations you would expect from a document storage system:
- uploading a document
- listing uploaded documents
- fetching information about a document
- downloading a document
The following sections will provide brief descriptions of the various endpoints that make up DocHeart Vault API.
Upload endpoint
As the name suggests, the upload endpoint allows you to upload a document to the DocHeart vault. Below, you can find an example of how to use this endpoint:
-
const formData = new FormData() // the type of document (it can be any string) formData.append('doctype', 'Invoice') // the file object containing the document you want to upload // for more details see: // https://developer.mozilla.org/en-US/docs/Web/API/File?retiredLocale=nl formData.append('uploadFile', new File(...)) const response = await fetch('https://api.docheart.ai/docheart/api/vault/upload', { method: "POST", headers: { "X-Api": "<api_token>" }, body: formData })
-
curl -X POST https://api.docheart.ai/docheart/api/vault/upload \ -H "X-api: <api_token>" \ -F "uploadFile=@<filepath>" -F "doctype=Invoice"
If the request is successful, the endpoint will return a JSON object containing information about the newly uploaded document, as in the example below:
{
"document_id":"4d82b7cd-7ddb-4154-8519-ca8baa84528e",
"document_name":"rules_screen.png",
"document_type":"Invoice",
"content_type":"image/png",
"owner_id":"7ZawPyIwfZYt3LTlmdRCJhV0vlG3",
"upload_unix_timestamp":1707304007.8676543,
"num_pages":1
}
A very important field is the document_id (also referred as the document_storage_id) which is a unique id generated by DocHeart for every document in the vault. You will use this id as a handle for the newly uploaded document in all endpoints of DocHeart API.
List endpoint
This endpoint is used to list all the documents that are part of DocHeart Vault, which belong to the user making the request. Here is an example of how to use this endpoint:
-
const response = await fetch('https://api.docheart.ai/docheart/api/vault/upload', { method: "GET", headers: { "X-Api": "<api_token>" }, })
-
curl -X GET https://api.docheart.ai/docheart/api/vault/list \ -H "X-api: <api_token>"
The response will follow this format:
{
"documents": [
{
"content_type": "application/pdf",
"document_id": "0353cf23-f1ba-4a9e-98ef-e1a69f74198a",
"document_name": "eu_invoice_document.pdf",
"document_type": "cfa6cae9-74b0-4a4d-8ef2-cfed5ab901b4",
"owner_id": "64bfb8a144177f5c2945da9c",
"upload_unix_timestamp": 1690288361.026583
},
{
"content_type": "application/pdf",
"document_id": "668182a9-7b1f-4775-9edd-7e4ed2b3be7e",
"document_name": "demo_invoice.pdf",
"document_type": "c4d4cbf8-eb76-429b-8509-55f5d66e64d3",
"owner_id": "64bfb8a144177f5c2945da9c",
"upload_unix_timestamp": 1690800182.7536302
},
{
"content_type": "application/pdf",
"document_id": "4ecb5464-0bcb-4a0d-9985-6ec0e1717cf4",
"document_name": "blueberry_certificate.pdf",
"document_type": "c4d4cbf8-eb76-429b-8509-55f5d66e64d3",
"owner_id": "64bfb8a144177f5c2945da9c",
"upload_unix_timestamp": 1690883135.0778074
}
]
}
Info endpoint
This endpoint is used to retrieve information about a specific document within the vault, which is referenced by its id. Here is an example of how to use this endpoint:
-
const response = await fetch('https://api.docheart.ai/docheart/api/vault/info/<document_id>', { method: "GET", headers: { "X-Api": "<api_token>" }, })
-
curl -X GET https://api.docheart.ai/docheart/api/vault/info/<document_id> \ -H "X-api: <api_token>"
If the request is successful, the endpoint will return a JSON object containing information about the document, as in the example below:
{
"document_id":"4d82b7cd-7ddb-4154-8519-ca8baa84528e",
"document_name":"rules_screen.png",
"document_type":"Invoice",
"content_type":"image/png",
"owner_id":"7ZawPyIwfZYt3LTlmdRCJhV0vlG3",
"upload_unix_timestamp":1707304007.8676543,
"num_pages":1
}
Get endpoint
This endpoint enables you to download a document. As in the case of the previous endpoints, the document is referenced by its id:
-
const response = await fetch('https://api.docheart.ai/docheart/api/vault/get/<document_id>', { method: "GET", headers: { "X-Api": "<api_token>" }, })
-
curl -X GET https://api.docheart.ai/docheart/api/vault/get/<document_id> \ -H "X-api: <api_token>"