Expenses


Use this REST API to manage and administer expenses. With this resource, you can retrieve expenses lists, create, update, and delete expenses in your WebWork account.
Below we provide an example of the data which is required for each scenario.

GET All Expenses


You can get all the expenses in your workspace with the following URL request

Copy codeGEThttps://www.webwork-tracker.com/rest-api/expenses

Retrieves a list of expenses in your workspace. By default, results are paginated (50 rows per page). You can optionally filter expenses by including any combination of the following query parameters.

Copy codeGEThttps://www.webwork-tracker.com/rest-api/expenses?id={id}&date_from={date_from}&date_to={date_to}&page={page}

The response returns a json format. Below you can see an example of response structure.

                            Copy code
                            max_rows: "{max_rows}"
                            current_page: "{current_page}"
                            total_pages: "{total_pages}"
                            data: [
                                {
                                    "id": "{id}"
                                    "member": "{member}"
                                    "expense_date": "{expense_date}"
                                    "expense_name": "{expense_name}"
                                    "project": "{project}"
                                    "category": "{category}"
                                    "amount": {amount}
                                    "note": "{note}"
                                    "type": "{type}"
                                    "added_date": "{added_date}"
                                },
                                {...}
                            ]
                        

POST Create expense


You can create a new expense using POST method and adding all necessary parameters to request body.

Copy codePOSThttps://www.webwork-tracker.com/rest-api/expenses

Below you can see all parameters that you can pass to request body

Property name Type Is required
expense_name string Yes
date date Yes
amount numeric Yes
category_id string Yes
project_id integer No
note string No
is_billable boolean No

The returned response includes a success property which contains your request success value, and expense property which is an array of the created expense options.

                        Copy code
                        {
                            "success": "{success_of_the_request}"
                            "expense": "{expense_array}"
                        }
                    

PUT Update expense


You can update a expense by sending PUT request to the following URL and giving appropriate parameters.

Copy codePUThttps://www.webwork-tracker.com/rest-api/expenses/{expense_id}

You should put the following header in your request

Copy codeContent-Type: application/x-www-form-urlencoded

You can use PUT method to update a expense name, date, amount, category, project and note.

Property name Type Is required
expense_name string YES
project_id integer no
date date no
amount numeric no
category_id string no
project_id integer no
note string no
is_billable boolean no

The returned response contains a success property with your request success value.

                        Copy code
                        {
                            "success": "{success_of_the_request}"
                        }
                    

DELETE Delete expense


To delete a expense, you should send a request to the same URL using DELETE method and adding a {expense_id} at the end of it, as shown in the example.

Copy codeDELETEhttps://www.webwork-tracker.com/rest-api/expenses/{expense_id}

The returned response includes a success property which contains your request success value.

                        Copy code
                        {
                            "success": "{success_of_the_request}"
                        }
                    

GET Expense categories


You can get all the expenses categories in your workspace with the following URL request

Copy codeGEThttps://www.webwork-tracker.com/rest-api/expenses/categories

Retrieves a list of categories in your workspace. By default, results are paginated (50 rows per page), and you can optionally filter categories by including any combination of the following query parameters.

Copy codeGEThttps://www.webwork-tracker.com/rest-api/expenses/categories?id={id}&page={page}

The response returns a json format. Below you can see an example of response structure.

                            Copy code
                            max_rows: "{max_rows}"
                            current_page: "{current_page}"
                            total_pages: "{total_pages}"
                            data: [
                                {
                                    "id": "{id}"
                                    "name": "{name}"
                                },
                                {...}
                            ]