Invoice Documents
Instead of creating Invoices through the API, you can upload the Invoice a Business sent to its customer, such as a PDF or an image. Asset reads it and creates the Invoice for you.
Call Upload Documents for a Business with document_type set to invoice:
curl --request POST \
--url https://api.sandbox.getasset.com/v0/business/biz_GA6EG2qFxA97NZHtxeLPUy/document \
--header 'Authorization: Bearer <token>' \
--form 'files=@invoice-1042.pdf' \
--form 'document_type=invoice'Always send document_type. Without it, Asset works out the type from the
file, and an invoice is treated as a vendor bill (money the Business
owes), not as an Invoice the Business sent.
What Asset does with it
- Reads the document. Asset extracts the customer, the Invoice number, the dates, the line items and the total.
- Finds or creates the Customer. Asset looks for an existing Customer with the same name, allowing for small differences such as "ACME Corp" and "Acme Corporation". If there is none, it creates one.
- Creates the Invoice. It uses the number on the document, the issue date as
sent_at, and the due date asdue_at. If the document has no due date, Asset uses 30 days after the issue date. Each line item becomes an Invoice line. If a document holds several Invoices, each one is created separately. - Picks Ledgers for the lines. Asset proposes ledger assignments from the business's Chart of Accounts. Lines it cannot confidently place, and tax lines, are initially left without a ledger and pass through the usual categorization workflow.
- Books it like any other Invoice. Asset creates the usual Journal Entry, links the document to the Invoice, and then categorizes the lines that still have no Ledger.
From there the Invoice works like one created through the API, including matching payments.
Result
Follow the outcome on the Document's status. When an Invoice was created, the Document's invoice_id holds its ID.
| Status | Meaning |
|---|---|
| processing | Asset is reading the document. |
| processed | An Invoice was created from the document. |
| partially_processed | Asset read the document but didn't create an Invoice, for example because the number is already used by an Invoice. |
| failed | Asset couldn't read the document. The status_reason says why. |
A DOCUMENT_PROCESSED webhook is sent when processing finishes, whatever the outcome.
- Duplicates: a file that matches one already uploaded for the Business is rejected, and the error names the existing document.
- Unsupported files: a file type that isn't supported, or a file that is too large, is rejected at upload.
- Check the result: review the Customer, Ledgers and amounts on the new Invoice, and correct them with Update an Invoice.
Questions? Reach out via our Contact form.