× FreshBooks App Logo
FreshBooks
Official App
Free - Google Play
Get it
You're currently on our US site. Select your regional site here:

Expense Attachments

Access Requirements

AccessRequires Authorization
Scopesuser:expenses:write
user:uploads:read
user:uploads:write

Overview

Expenses can have images of pdfs of the receipt attached to them. All receipts that you’d like to add to an expense first need to be uploaded to the system via the attachments upload endpoint first. The endpoint will then return a path to your image with a JWT. This path will can then be passed in the body of your expense request for your receipt to be included.

Upload Attachment

Request: POST

curl --location -g --request POST 'https://api.freshbooks.com/uploads/account/<accountId>/attachments' \
--header 'Authorization: Bearer ' \
--form 'content=@"/path/to/file"'

Response:

{
    "attachment": {
        "filename": "upload-9198160f94ca297e174a602f40899a3c9f76099d", 
        "public_id": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6InRvcm9udG8tc2t5bGluZS5qcGciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtOTE5ODE2MGY5NGNhMjk3ZTE3NGE2MDJmNDA4OTlhM2M5Zjc2MDk5ZCIsImxlbmd0aCI6MzA3MDY4LCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTkxOTgxNjBmOTRjYTI5N2UxNzRhNjAyZjQwODk5YTNjOWY3NjA5OWQifQ.yAfSd2cIAf2GONitgBmimMCHxvH9OYij7g0WMsiLsaE", 
        "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6InRvcm9udG8tc2t5bGluZS5qcGciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtOTE5ODE2MGY5NGNhMjk3ZTE3NGE2MDJmNDA4OTlhM2M5Zjc2MDk5ZCIsImxlbmd0aCI6MzA3MDY4LCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTkxOTgxNjBmOTRjYTI5N2UxNzRhNjAyZjQwODk5YTNjOWY3NjA5OWQifQ.yAfSd2cIAf2GONitgBmimMCHxvH9OYij7g0WMsiLsaE", 
        "media_type": "image/png", 
        "uuid": "47356675-5gh5-4a1e-9de6-761cg66fgf43"
    }
}

Create Expense With Attachment

Request: POST 'https://api.freshbooks.com/accounting/account/<accountId>/expenses/expenses?include[]=attachment'

{
  "expense": {
    "amount": {
      "amount": "39.991"
    },
    "attachment": {
      "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6InRvcm9udG8tc2t5bGluZS5qcGciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtOTE5ODE2MGY5NGNhMjk3ZTE3NGE2MDJmNDA4OTlhM2M5Zjc2MDk5ZCIsImxlbmd0aCI6MzA3MDY4LCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTkxOTgxNjBmOTRjYTI5N2UxNzRhNjAyZjQwODk5YTNjOWY3NjA5OWQifQ.yAfSd2cIAf2GONitgBmimMCHxvH9OYij7g0WMsiLsaE",
      "media_type": "image/png",
      "expenseid": null
    },
    "categoryid": 93993004,
    "staffid": 1,
    "date": "2009-11-24"
  }
}


Response:

{
  "response": {
    "result": {
      "expense": {
        "account_name": null,
        "accountid": null
        "accounting_systemid": "zDmNq",
        "amount": {
          "amount": "39.991",
          "code": "USD"
        },
        "attachment": {
          "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6InRvcm9udG8tc2t5bGluZS5qcGciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtOTE5ODE2MGY5NGNhMjk3ZTE3NGE2MDJmNDA4OTlhM2M5Zjc2MDk5ZCIsImxlbmd0aCI6MzA3MDY4LCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTkxOTgxNjBmOTRjYTI5N2UxNzRhNjAyZjQwODk5YTNjOWY3NjA5OWQifQ.yAfSd2cIAf2GONitgBmimMCHxvH9OYij7g0WMsiLsaE",
          "media_type": "image/png",
          "expenseid": null
        },
        "bank_name": null,
        "categoryid": 93993004,
        "clientid": 0,
        "compounded_tax": false,
        "date": "2009-11-24",
        "expenseid": 1574917,
        "ext_invoiceid": 0,
        "ext_systemid": 0,
        "has_receipt": false,
        "id": 1574917,
        "invoiceid": null,
        "isduplicate": true,
        "markup_percent": "0",
        "notes": "",
        "profileid": null,
        "projectid": 0,
        "staffid": 1,
        "status": 0,
        "taxAmount1": null,
        "taxAmount2": null,
        "taxName1": null,
        "taxName2": null,
        "taxPercent1": null,
        "taxPercent2": null,
        "transactionid": null,
        "updated": "2016-09-29 19:08:17",
        "vendor": null,
        "vis_state": 0,
      }
    }
  }
}