# Expenses

Expenses are defined as costs incurred as part of a project, but not related to time. Once created, expenses can
be included in generated invoices.

## Fetching a list of Expenses

 - [GET /expenses](https://developer.kantata.com/kantata/specification/expenses/get-expenses.md): The expenses endpoint provides a list of every expense that the user making the request is allowed to see—
across all projects to which the user belongs.

The response will contain an array of expense objects, sorted by the date attribute in descending order,
available under the expenses key.


This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the expenses top-level JSON key.
Please see our Response Format section for more information.

## Creating a new Expense

 - [POST /expenses](https://developer.kantata.com/kantata/specification/expenses/create-expense.md): Creates an expense.

Bulk Create

This endpoint supports bulk creating up to 100 objects. In the request body, set the top-level key to its plural form and place the objects in an array. Example:


{
  "expenses": [
    {
      "workspace_id": 123,
      "date": "2025-01-01",
      "expense_category_id": 456,
      "category": "Travel",
      "amount_in_cents": 20000
    },
    {
      "workspace_id": 123,
      "date": "2025-01-01",
      "expense_category_id": 456,
      "category": "Travel",
      "amount_in_cents": 20000
    }
  ]
}



This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the expenses top-level JSON key.
Please see our Response Format section for more information.

## Delete multiple expenses

 - [DELETE /expenses](https://developer.kantata.com/kantata/specification/expenses/delete-expenses.md): The IDs of the expenses to delete can be provided in the ids query parameter or via the request body.

Request body example:
{
  "ids": "1,2,3"
}

If any specified expenses cannot be deleted, the entire request will fail and an error message
will be returned that specifies which ones could not be deleted and why.


This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the expenses top-level JSON key.
Please see our Response Format section for more information.

## Fetching a single Expense

 - [GET /expenses/{id}](https://developer.kantata.com/kantata/specification/expenses/get-expense.md): You can request either GET /api/v1/expenses.json?only=5 or
GET /api/v1/expenses/5.json.  In both cases, default filters will be applied. Unless you
provide the from_archived_workspaces:true filter you won't receive expenses from archived projects,
and will get a 404 status on the "show" route.


This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the expenses top-level JSON key.
Please see our Response Format section for more information.

## Updating an existing Expense

 - [PUT /expenses/{id}](https://developer.kantata.com/kantata/specification/expenses/update-expense.md): An expense that has already been created can be updated with an HTTP PUT request. Any required or optional
attribute, with the exception of workspace_id, can be changed in an update.


This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the expenses top-level JSON key.
Please see our Response Format section for more information.

## Deleting an existing Expense

 - [DELETE /expenses/{id}](https://developer.kantata.com/kantata/specification/expenses/delete-expense.md): The response will contain no content and an HTTP 204 status code if the request was
successful, or a standard Kantata OX error message explaining why the object could not be deleted.

