Uploading documents
Upload received invoices and receipts through the API and follow their extraction.
Documents uploaded through the API go through the same AI extraction as documents uploaded in the app. In Uploaded files their source is API. Uploading needs a key with Read and write access.
Supported files: PDF, images (JPG, PNG, WEBP, HEIC), Word, Excel, OpenDocument and RTF. Up to 20 files at once, each up to 20 MB.
Small files: one request
For up to about 4 MB per request, send the files as multipart/form-data in file fields:
curl https://moniary.com/api/v1/uploads \
-H "Authorization: Bearer $MONIARY_API_KEY" \
-F file=@invoice.pdf \
-F file=@receipt.jpg
{
"uploadSessionId": "On3iHRaS2JhErPH2Ai",
"documents": [
{
"fileName": "invoice.pdf",
"path": "…/uploads/invoices/srprbuxP_mon_invoice.pdf"
}
]
}
Large files: signed upload URLs
- Ask for upload URLs:
curl https://moniary.com/api/v1/uploads \
-H "Authorization: Bearer $MONIARY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"files": [{"fileName": "invoice.pdf", "contentType": "application/pdf", "size": 8123456}]}'
PUTeach file to itsuploadUrl(without the Authorization header):
curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/pdf" --data-binary @invoice.pdf
- Complete the upload with the
fileNameandpathfrom step 1:
curl https://moniary.com/api/v1/uploads/$SESSION/complete \
-H "Authorization: Bearer $MONIARY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"documents": [{"fileName": "invoice.pdf", "path": "…"}]}'
Extraction starts only after this step. The CLI (moniary upload) does all three steps for you.
Extraction progress
curl https://moniary.com/api/v1/uploads/$SESSION \
-H "Authorization: Bearer $MONIARY_API_KEY"
While the files wait in the queue, data is null. Then it returns totals (totalFiles, activeFiles, completedFiles, failedFiles) and, for each file, its parts (parts) with the result: status, the invoiceId and invoiceNumber of the created document, or a rejectionReason or reviewIssues. A file with several documents is split into several parts.
Extraction usually takes tens of seconds. Don't check more often than every few seconds. Then load the document with the invoices.getInvoiceById action.
Extraction is billed the same way as for documents uploaded in the app.