API Documentation

Overview
Time Tracking

Extended REST API
Clients
Client Contacts
Projects
Tasks
People
Expenses
Expense Tracking
User Assignment
Task Assignment
Reports
Invoices
Invoice Messages
Invoice Payments
Invoice Categories


Questions? Contact support

Expense Tracking API

The Expense tracking API allows you to access and manipulate expense entries in similar fashion to using the weekly expensesheet view. This allows developers to create lightweight clients or widgets to track expenses beyond directly interacting with Harvest through the web browser.


Create new expense

POST /expenses

HTTP Response: 201 Created
Location: /expenses

Post the following for a standard expense with a total cost:

<expense>
  <notes>Buy Valentine's Day chocolates for Harvest</notes>
  <total-cost type="decimal">11.00</total-cost>
  <project_id type="integer">2</project_id>
  <expense_category_id type="integer">1</expense_category_id>
  <spent_at type="date">Sun, 10 Feb 2008</spent_at>
</expense>

Post the following for an expense whose total cost is calculated via an expense categories unit price (e.g. mileage):

<expense>
  <notes>Drive to buy Valentine's chocolates</notes>
  <units type="integer">5</units>
  <project_id type="integer">2</project_id>
  <expense_category_id type="integer">3</expense_category_id>
  <spent_at type="date">Sun, 10 Feb 2008</spent_at>
</expense>

Update an existing expense

PUT /expenses/#{expense_id}

HTTP Response: 200 OK
Location: /expenses/#{expense_id}

Put the following for a standard expense with a total cost:

<expense>
  <notes>Buy Valentine's Day _dark_ chocolates for Harvest</notes>
  <total_cost type="decimal">20.00</total_cost>
</expense>

Put the following for an expense whose total cost is calculated via an expense categories unit price (e.g. mileage):

<expense>
  <notes>Drive _a long way_ to buy Valentine's chocolates</notes>
  <units type="integer">25</units>
</expense>

Show expense

GET /expenses/#{expense_id}

HTTP Response: 200 Success
<expense>
  <notes>Buy Valentine's Day _dark_ chocolates for Harvest</notes>
  <total-cost type="decimal">20.00</total-cost>
  <project_id type="integer">2</project_id>
  <expense_category_id type="integer">1</expense_category_id>
  <spent_at type="date">Sun, 10 Feb 2008</spent_at>
  <has-receipt type="boolean">true</has-receipt>
  <receipt-url>http://sub.harvestapp.com/expenses/234997/receipt</receipt-url>
</expense>

Note that the has-receipt field will indicate whether a receipt image has been attached. If it is true, you can use the URL in receipt-url to fetch the image.


Delete existing expense

DELETE /expenses/#{expense_id}

HTTP Response: 200 OK

Attach a receipt image to an expense

POST /expenses/#{expense_id}/receipt

HTTP Response: 200 OK
Location: /expenses/#{expense_id}/receipt

When adding or updating an image receipt, you don't need to post any XML. Just post the image data like you would any multipart form data. Be sure to set the name of the post data to expense[receipt] and set the filename= parameter:

POST /expenses/#{expense_id}/receipt HTTP/1.1
User-Agent: #{Your app name here}
Host: #{yoursubdomain}.harvestapp.com
Accept: application/xml
Authorization: Basic (insert your authentication string here)
Content-Length: 47899
Content-Type: multipart/form-data; boundary=------------------------------b7edea381b46
------------------------------b7edea381b46
Content-Disposition: form-data; name="expense[receipt]"; filename="hotel.jpg"
Content-Type: image/jpeg

#{ BINARY IMAGE DATA }

------------------------------b7edea381b46

Get a receipt image associated with an expense

GET /expenses/#{expense_id}/receipt

HTTP Response: 200 OK

Perform a simple GET on the receipt URL to receive the image data.