Developing on Invoiced
File Attachments
5 min
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 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 "https //api invoiced com/files" \\ u {api key} \\ d url="https //www invoiced com/img/logo invoice png" \\ d name="logo invoice png" \ # filename d size=6936 \ # size in bytes d type="image/png" # mime typeimport 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();\<?php $invoiced = new invoiced\client("{your api key}"); $file = $invoiced >file >create(\[ 'url' => "https //www invoiced com/img/logo invoice png", 'name' => "logo invoice png", // filename 'size' => 6936, // size in bytes 'type' => "image/png" // mime type ]);import invoiced client = invoiced client("{your api key}") file = client file create( url="https //www invoiced com/img/logo invoice png", name="logo invoice png", # filename size=6936, # size in bytes type="image/png" # mime type )require "invoiced" invoiced = invoiced client new("{your api key}") file = invoiced file create( \ url => "https //www invoiced com/img/logo invoice png", \ name => "logo invoice png", # filename \ size => 6936, # size in bytes \ type => "image/png" # mime type ) 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 "https //api invoiced com/invoices" \\ u {api key} \\ \# invoice parameters d attachments\[]={file id}import com invoiced entity attachment; import com invoiced entity invoice; invoice invoice = invoiced newinvoice(); // invoice parameters attachment\[] attachments = new attachment\[1]; attachments\[0] = new attachment(); attachments\[0] file = file id; invoice attachments = attachments; invoice create();\<?php $invoiced >invoice >create(\[ // invoice parameters 'attachments' => \[$file >id] ]);invoice = client invoice create( \# invoice parameters attachments=\[file id] )invoice = invoiced invoice create( \# invoice parameters \ 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 tab examples url https api invoiced com invoices id attachments name list invoice attachments method get request pathparameters kind required name id type integer description invoice id queryparameters headerparameters bodydataparameters formdataparameters results languages id dsyiav7j7wy9nhe6my078 code n n id 13 n file n id 13 n object file n name logo invoice png n size 6936 n type image png n url https www invoiced com img logo invoice png n created at 1464625855 n n created at 1464625855 n n language 200 selectedlanguageid dsyiav7j7wy9nhe6my078 examples languages id h4bek1jgxcy h wlsaddu code curl https api invoiced com invoices invoice id attachments n u api key language curl id s19ujtxg2d5lhqo7cause code import com invoiced entity attachment; n nattachment attachments invoice listattachments ; language java id v y9ammp5dwoemyu2lgeu code ?php nlist attachments metadata invoice attachments ; language php id xstg8mvobsn4kbwcj0cpy code attachments metadata invoice attachments language python id l2kw4iia0acqcdsv0jj 0 code attachments metadata invoice attachments language ruby selectedlanguageid h4bek1jgxcy h wlsaddu description get a list of attachments for an invoice currentnewparameter label path parameter value pathparameters