Product Workaround > TW automations HTTP request - Add a budget expense

Aim: Create a budget expense is not an option with the automations feature. This guide will provide a work around to automate the creation a budget expense.

Feature: Teamwork.com Automations - HTTP Request

API endpoint:

  • Create a budget expense - undocumented

  • https://{siteName}.teamwork.com/projects/api/v3/projects/budgets/{budgetId}/expenses.json

Step one:

Click on automations on the top right of Teamwork.com > Create automation. This will open the new automations modal.

Step two:

Note: The options selected for this step are selected for this scenario. you can change these to match your own process

  • On the with section set trigger to Task completed

  • Select your desired project where you want to add the budget expense to

  • Click on add condition

  • Select Tag from the drop down > set to is any of and add your desired tag. for this scenario I selected Expense

Step three:

For this part we will set up the request.

  • Action: Send HTTP request

  • URL: Use the url above and make sure that you add your site name and budget id where applicable

  • HTTP method: POST

  • Headers: For this scenario we only require authorization

    • On the left add Authorization

    • On the right add the word Basic followed by a space and then add your base64 encoded credentials.

      • Use the BASE64Decode site to convert your credentials in the following format emailAddress:password and click on encode.

Step four:

Here we will add the request body required to create the expense. The format of the request body is specific so please use the code below as an example .

{"budgetExpense":{"cost":50000,"description":"Add expense > New Printer"}}

Note: Depending on how you want to process this action you can also use task variables if applicable.

For this scenario I will use:

  • A task custom field value for the cost

  • Task name as the description text. You can add additional text if required inside quotes. ""

Click on save to enable the automation.

Step five:

The steps above require a task to be completed. The task must include the Expense tag for the automation to fire.

  • Create a task with Add expense > New Printer as the name in the project linked to the budget id you added above

  • Create a numeric whole number type custom field for the task and add 50000 as the value. this will represent 500 denomination.

Replace the task name and custom field value to suit your process.

Step six:

Review expense that was created