# Fetching a list of Expenses

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/Response-Format) section for more information.

Endpoint: GET /expenses
Version: 1.0.0

## Query parameters:

  - `approved` (boolean)
    Filter for expenses that are on approved expense reports, or on a workspace that does not require approvals.

  - `created_after` (string)
    Filter for records created after a specified datetime. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `created_before` (string)
    Filter for records created before a specified datetime. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `created_by` (integer)

  - `date_expensed_between` (string)
    Filter for expenses between the start and end dates in a colon-separated YYYY-MM-DD format. For example, `2013-06-01:2013-08-01`. If a date is not specified, it is interpreted as no start/end date.

  - `external_reference_external_message` (string)
    Filter the objects based on the external message of their associated external references. This is an exact match.

  - `external_reference_external_status` (string)
    Filter by the status of the external object in the external system.

  - `external_reference_service_model` (string)
    Filter by the type of the external object this external reference belongs to.

  - `external_reference_service_model_ref` (integer)
    Filter by the id of the external object this external reference belongs to.

  - `external_reference_service_model_refs` (string)
    Filter for objects that correlate to the specified external object IDs. Provide a comma-separated list of up to 200 external IDs.

  - `external_reference_service_name` (string)
    Filter by the name of the provider for integration.

  - `external_reference_status` (string)
    Filter by the status of the integration, this can be successful or fail.

  - `from_archived_workspaces` (boolean)
    Filter for expenses from archived projects.

  - `has_external_references` (boolean)
    Filter by whether or not the object has external references.

  - `in_active_invoice_id` (integer)
    Limit results to time entries current in the specified active invoice.

  - `include` (string)
    Any of the below associations can be included in your request by providing the `include` param, e.g. `include=association1,association2`.
- `active_submission` (ExpenseReportSubmission) - The active expense report the expense is submitted in. The response will include `active_submission_id`, which references the data in the `expense_report_submissions` top-level key.
- `expense_budget` (ExpenseBudget) - Retrieves the expense budget the expense is logged to. The response will include `expense_budget_id`, which references the data in the `expense_budgets` top-level key.
- `expense_category` (ExpenseCategory) - The category associated with the expense. The response will include `expense_category`, which references the data in the `expense_categories` top-level key.
- `external_references` (ExternalReference) - Includes references to external integrations for this object.
- `receipt` (Attachments::ReceiptAttachment) - Information about receipts associated with this expense. The response will include `receipt_id`, which references the data in the `attachments` top-level key.
- `recent_submission` (ExpenseReportSubmission) - The most recent expense report the expense was submitted in, including any rejected or cancelled reports. The response will include `recent_submission_id`, which references the data in the `expense_report_submissions` top-level key.
- `role` (Role) - The role of the user. The response will include `role_id`, which references the data in the `roles` top-level key.
- `story` (Story) - Linked task. The response will include `story_id`, which references the data in the `stories` top-level key.
- `user` (User) - The user who created the expense. The response will include `user_id`, which references the data in the `users` top-level key.
- `vendor` (Vendor) - The party to which the expense is payable. The response will include `vendor_id`, which references the data in the `vendors` top-level key.
- `workspace` (Workspace) - The project to which this expense belongs. The response will include `workspace_id`, which references the data in the `workspaces` top-level key.

  - `invoiced` (boolean)
    Include expenses that have been invoiced.

  - `mine` (boolean)
    Filter for expenses created by the user.

  - `on_my_account` (boolean)
    Only include expenses that are on internal projects. On my account false will include internal and external expenses.

  - `only` (string)
    Allows you to request one or more resources directly by ID. Multiple IDs can be supplied
in a comma separated list, like `GET /api/v1/workspaces.json?only=5,6,7`.

  - `optional_fields` (array)
    Allows you to request one or more optional fields as an array.

  - `order` (string)
    Supply `order` with the name of a valid sort field for the endpoint and a direction.

Valid values: `amount:asc`, `amount:desc`, `category:asc`, `category:desc`, `created_at:asc`, `created_at:desc`, `date:asc`, `date:desc`, `notes:asc`, `notes:desc`, `vendor_name:asc`, and `vendor_name:desc`.

  - `page` (integer)

  - `per_page` (integer)

  - `reimbursable` (boolean)
    Filter for expenses that are reimbursable based on the provided value.

  - `submitted` (boolean)
    Filter for expenses that have been submitted.

  - `uninvoiced` (boolean)
    Filter for expenses that have not been invoiced.

  - `unsubmitted` (boolean)
    Filter for expenses that have not been submitted.

  - `updated_after` (string)
    Filter for records updated after a specified datetime. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `updated_before` (string)
    Filter for records updated before a specified datetime. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `with_expense_approvals` (boolean)

  - `with_expense_report_id` (integer)
    Filter for expenses associated with the specified expense report ID. If the
        report was canceled or rejected, no result is returned.

  - `with_recent_expense_report_ids` (string)
    Filter for expenses associated with the specified expense report IDs, including from canceled and rejected reports.
        Give multiple report IDs in a comma separated list.

        **Note**: Expenses are only associated with the most recent reports they were submitted in (`recent_submission`).
        If you re-submit an expense from a canceled or rejected report in a new report, the expense will only be returned
        in association with that most recent submission`.

  - `without_external_reference_service_name` (string)
    Exclude by the existence of an external reference with the specified service name.

  - `workspace_id` (integer)
    Filter for expenses associated with the specified project ID.

## Response 200 fields (application/json):

  - `count` (integer)

  - `meta` (object)

  - `meta.count` (integer)

  - `meta.page_count` (integer)

  - `meta.page_number` (integer)

  - `meta.page_size` (integer)

  - `results` (array)

  - `results.key` (string)

  - `results.id` (string)

## Response 400 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 401 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 403 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 404 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 422 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 503 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

