Upload and attach invoice documents
Three calls put a file on an invoice. They all take multipart/form-data, not
JSON, so a file sent as a base64 string in a JSON body is not accepted. The calls
on this page are for a user or service-account token with the right
CreateDocuments. An integration that authenticates with a machine token uses
the routes under Upload a PDF (machine-to-machine)
instead.
| You want | Call | File |
|---|---|---|
| To send your own rendered invoice instead of the PDF Quiddly renders | POST /documents/invoice | PDF, at most 10 MB |
| To add pages after the invoice PDF | POST /documents/attachments/invoice | PDF, at most 10 MB |
| To store a file on the invoice and not send it to the debtor | POST /documents/connected-files | csv, pdf, xls, jpg, jpeg, png, mp3 or wav, at most 24 MB |
Each call takes these form fields:
| Field | Meaning |
|---|---|
file | The file. Required. |
invoiceId | The invoice. Required for the invoice document and the attachment. Optional for a connected file. |
clientId | The client. Required when the token is not bound to a client, such as a system-level service account. A token that is bound to a client must leave it out, otherwise the call answers 400 clientId should not be specified. |
The invoice must belong to that client, otherwise the call answers
400 Invoice could not be found on client. Each call returns the stored
document.
Send your own invoice PDF
Section titled “Send your own invoice PDF”Use POST /documents/invoice when your system renders the invoice and Quiddly
must use that file as the invoice document. The call is accepted for a client
only in one of two setups, otherwise it answers
400 Upload own invoice document is not enabled on client:
- The client has internal invoice PDF generation switched off. In the
Operations Portal this is the Enable PDF Generation checkbox in the
Distribution Settings on the client’s Distribution tab: unticked
means switched off. Through the API it is the client flag
DISABLE_INTERNAL_INVOICE_PDF, set withPUT /settings/client/flag/<client id>and the body{ "key": "DISABLE_INTERNAL_INVOICE_PDF", "enabled": true }(rightManageClientSettings). It applies to invoices and credit invoices. - The client has an invoice document template with
enableUploadset totrue. The template is a document template of typeINVOICEfor the client (POST /document-templates, rightCreateDocumentTemplate).
Quiddly accepts one invoice document for each invoice. A second upload answers
400 Only one invoice document can be added to invoice.
curl -X POST "https://$HOST/documents/invoice" \ -H "Authorization: Bearer $JWT" \ -F "file=@invoice.pdf" -F "clientId=C.100100" -F "invoiceId=$INVOICE_ID"The two setups behave differently when the invoice is activated:
| Setup | At activation |
|---|---|
| Internal PDF generation switched off | Quiddly generates no invoice PDF and creates no distribution for the invoice, so Quiddly does not send it to the debtor. Sending your own PDF to the debtor is up to you. The uploaded file is stored on the invoice. |
Template with enableUpload | Quiddly distributes the invoice as usual, with your uploaded PDF as the invoice document. If no PDF is uploaded before activation, Quiddly renders its own invoice document, and a later upload is then refused as the second invoice document. Upload before you activate. |
Add an attachment to the invoice PDF
Section titled “Add an attachment to the invoice PDF”POST /documents/attachments/invoice adds a PDF after the invoice pages. An
invoice takes one attachment, a second answers
400 Only one attachment can be added to invoice. When the invoice document
has already been generated, Quiddly generates the combined invoice document
again so that it contains the attachment.
Store a file without sending it
Section titled “Store a file without sending it”POST /documents/connected-files stores a file on the invoice, or on the client
when you leave out invoiceId. The file is not part of the invoice document and
is not sent to the debtor. Other extensions than the ones in the table above are
refused with 400 and the list of accepted ones.
curl -X POST "https://$HOST/documents/connected-files" \ -H "Authorization: Bearer $JWT" \ -F "file=@agreement.pdf" -F "clientId=C.100100" -F "invoiceId=$INVOICE_ID"