Upload documents to Bill.com

You can upload a document to your Bill.com Inbox with /UploadAttachmet.json. You can also attach the document to different Bill.com objects - bill, invoice, vendor, customer, vendor credits, bill payments, invoice payments, or chart of accounts.

cURL API request

In your request, file and fileName is required.

  • Set file as the file to be uploaded. Include the entire file path and file extension.
  • Set fileName as the file name including the file extension.
  • You can set id as the Bill.com ID of the object to attach the document.
curl --request POST \
     --url 'https://api-sandbox.bill.com/api/v2/UploadAttachment.json' \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/x-www-form-urlencoded' \
     --form 'devKey={developer_key}' \
     --form 'sessionId={session_id}' \
         --form '[email protected]"{filepath}"' \
         --form 'data="{\"id\":\"{object_id}\", \"fileName\":\"{file_name}\"}"'

HTTP API request

In your request, file, fileName, and Content-Type is required.

  • Set file as the file to be uploaded. Include the entire file path and file extension.
  • Set fileName as the file name including the file extension.
  • Set Content-Type as the document type. For example, for a PNG image, set Content-Type as image/png. For a PDF, set Content-Type as application/pdf.
  • You can set id as the Bill.com ID of the object to attach the document.
POST /api/v2/UploadAttachment.json HTTP/1.1
Host: api-sandbox.bill.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="devKey"

{developer_key}
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="sessionId"

{session_id}
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="{file_name}"
Content-Type: image/png

{file_binary_information}
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"

{"id":"{object_id}", "fileName":"{file_name}"}
----WebKitFormBoundary7MA4YWxkTrZu0gW

Response

In the response, a Bill.com-generated documentUploadId is generated. The value begins with 0du. You can use this value to download the document with /GetDocumentPages.json.

{
   "response_status" : 0,
   "response_message" : "Success",
   "response_data" : {
       "documentUploadedId" : "{object_id}" 
   }
}

If you do not set an id in your request, the document is uploaded to your Bill.com Inbox and is automatically processed and relevant information is pre-populated in a bill. See Bills detected by Intelligent Virtual Assistant (IVA) in the Bill.com Help for more information.

Uploading documents with /UploadAttachment.json has a set of requirements.

  • The user that is uploading the document must have at least one of the following permissions: Use Inbox, View and Manage Company Info, or Approve Bills/Vendor Credits.
  • Bill.com supports popular file formats, such as Microsoft Word, Excel, PowerPoint, Adobe PDF, TXT, PNG, JPG, and GIF.
  • The maximum file size is 20 MB.
  • The file extension must match the extension in your API request.
  • A document can be associated with only one Bill.com object.
  • If the Bill.com object ID is invalid, an error message is returned and the document is not uploaded.

Did this page help you?