website logo
SupportSign In
User Documentation
Developers
Navigate through spaces
⌘K
Developing on Invoiced
Custom PDF Templates
File Attachments
Magic Links
Metered Billing
Payment Information
Subscription Billing
Template Language
Webhooks
API Release Notes
API Reference
Docs powered by archbee 

File Attachments

7min

Invoiced supports attaching files to invoices to give customers more context about a bill.

Usage

Files can be attached to invoices through the dashboard or programmatically through the API. In this guide, we will walk you through the complete steps to attach a file to an invoice through the API.

1. Create a file

You can upload a file using our API or host your file somewhere publicly accessible.

To upload a local file, make the following request.

Curl
|
curl https://api.invoiced.com/files \
-u {API_KEY}: \
-H "Content-Type:multipart/form-data" \
-F "file=@/path/to/your/file/yourfilename.pdf" \
-F "name=file"


If your file is publicly hosted, make this request instead.

Curl
Java
PHP
Python
Ruby
|
import com.invoiced.entity.Connection;
import com.invoiced.entity.File;

Connection invoiced = new Connection("{YOUR_API_KEY}", false);

File file = invoiced.newFile();
file.url = "https://www.invoiced.com/img/logo-invoice.png";
file.size = 6936;
file.name = "logo-invoice.png";
file.type = "image/png";
file.create();


2. Attach to an invoice

Once you have created your file, you can attach it to an invoice. This is done by passing in an array of file IDs through the attachments parameter when creating or editing an invoice.

In this example, we are going to show how to attach a single file when creating a new invoice:

Curl
Java
PHP
Python
Ruby
|
curl "https://api.invoiced.com/invoices" \
  -u {API_KEY}: \
  # invoice parameters...
  -d attachments[]={FILE_ID}


And the file is now attached! It will be available in the client view and dashboard as a downloadable attachment.

Retrieving attachments for an invoice

You can also retrieve the existing file attachments for an invoice with a simple API query. This might be useful to synchronize the attachments for an invoice with your internal systems.

Get a list of attachments for an invoice
GET
Params
Path Params
id
required
Integer
Invoice Id




Did this page help you?
Yes
No
PREVIOUS
Custom PDF Templates
NEXT
Magic Links
Docs powered by archbee 
List Invoice Attachments