Skip to main content
Version: v2alpha1

Attached documents using the API

Steps

1. Upload invoice attached document

Upload your file to getpaid to be attached to the invoice by calling POST /invoices/documents with the file content, the type of file and the file name to be used. Check the documents formats supported to attach to your invoices.

The response of the invoice upload contains the id of the document uploaded that must be used in the invoice creation to attach it.

In this scenario, the file uploaded is a CSV file named details.csv.

Request

POST /invoices/documents
POST /v2alpha1/invoices/documents HTTP/1.1
Host: api.getpaid.io
Content-Length: 296
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="details.csv"
Content-Type: text/csv

Response

201 Created
{
"id": "doc_4ggsy83a7bhe78428t371ecqds"
}

2. Issue invoice

Issue an invoice addding the document unique identifier to the documents list indicating that it is an attachment by setting the type to invoice_attachment.

See how to issue invoices for further details about invoice creation.

In this scenario, apart from the attached document, the request includes the generation of the invoice document in PDF format.

Request

POST /invoices
{
"documents": [
{
"type": "invoice",
"format": "pdf"
},
{
"type": "invoice_attachment",
"id": "doc_4ggsy83a7bhe78428t371ecqds"
}
],
[...]
}

Response

201 Created
{
"id": "inv_4ehg1mkv3mvt3256vcn8dspb4h",
[...]
}

3. Generate invoice document

getpaid generates the invoice document asynchronously once the invoice is issued.

It can be generated in various formats and provides an URL to download it.

4. Notify about document creation

Once the invoice document creation is completed in each of the formats needed, an invoice_document_created webhook notification per document generated is sent to the configured webhook URL.

5. Send invoice buyer notification

If the buyer notifications are configured, getpaid sends a newly issued invoice notification to the buyer with the invoice documents attached.

6. Notify about buyer notification sent

If the buyer notifications are configured, once the notification is sent, a invoice_buyer_notification_sent webhook notification is sent to the configured webhook URL.