Skip to content

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 wantCallFile
To send your own rendered invoice instead of the PDF Quiddly rendersPOST /documents/invoicePDF, at most 10 MB
To add pages after the invoice PDFPOST /documents/attachments/invoicePDF, at most 10 MB
To store a file on the invoice and not send it to the debtorPOST /documents/connected-filescsv, pdf, xls, jpg, jpeg, png, mp3 or wav, at most 24 MB

Each call takes these form fields:

FieldMeaning
fileThe file. Required.
invoiceIdThe invoice. Required for the invoice document and the attachment. Optional for a connected file.
clientIdThe 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.

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 with PUT /settings/client/flag/<client id> and the body { "key": "DISABLE_INTERNAL_INVOICE_PDF", "enabled": true } (right ManageClientSettings). It applies to invoices and credit invoices.
  • The client has an invoice document template with enableUpload set to true. The template is a document template of type INVOICE for the client (POST /document-templates, right CreateDocumentTemplate).

Quiddly accepts one invoice document for each invoice. A second upload answers 400 Only one invoice document can be added to invoice.

Terminal window
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:

SetupAt activation
Internal PDF generation switched offQuiddly 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 enableUploadQuiddly 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.

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.

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.

Terminal window
curl -X POST "https://$HOST/documents/connected-files" \
-H "Authorization: Bearer $JWT" \
-F "file=@agreement.pdf" -F "clientId=C.100100" -F "invoiceId=$INVOICE_ID"