---
title: "Retrieve spending analysis by categories, projects and accounts"
method: POST
path: "/spending-analysis"
tags: ["spending analysis"]
---

# Retrieve spending analysis by categories, projects and accounts

`POST /spending-analysis`

Defaults to all categories and accounts if none specified.
<br />The categories field in the response has a breakdown of the total by categories for the given periods. You can expect to also receive the breakdown for income and transfer categories.
<br />The 'total' field in the response calculates the total outgoing expenditure for the given periods. This calculation do not include income and transfers.
<br /> Categories under the transfer group are the only ones that can appear twice showing income and expenditure separately
<br />Requires **spending_analysis:read** scope.

## Request body

- SpendingAnalysisPost
  - `dates` object[], required — List of date ranges to calculate spending analysis for. This allows retrieving spending analysis of up to three different date ranges in one request.
    - `name` string, [a-zA-Z0-9_-]{1,50}, required — Descriptive name for the date range. The name will be used in the response payload to identify it.
    - `from` string, date, required — Start date to perform spending analysis.
    - `to` string, date, required — End date to perform spending analysis.
  - `accountIds` string[]
  - `categoryIds` string[]
  - `projectIds` string[]

## Response `200`

Successful Spending Analysis Response

- object
  - `data` SpendingAnalysis
    - `categories` object[], required — Array of categories showing the outgoing expenditure for the given period requested
      - `categoryId` string — Category Id
      - `categoryGroup` string — Category group where the category group belongs to
    - `total` object, required — Total outgoing expenditure for the given periods. This calculation do not include income and transfers
  - `links` Links
    - `next` string, uri — The url to retrieve the next page of results from
    - `prev` string, uri — The url to retrieve the previous page of results from
    - `self` string, uri, required — The url of the current resource(s)
  - `meta` object

## Other responses

- `400` — Unsuccessful Response - Bad request - Missing body properties
- `401` — Unsuccessful Response - Not authorised - Missing authorization header - Invalid access Token
- `403` — Unsuccessful Response - Forbidden - Invalid scopes

---

[API](https://skmtc.net/moneyhub/apis/moneyhub-data-api.md) · [All operations](https://skmtc.net/moneyhub/apis/moneyhub-data-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/moneyhub/moneyhub-data-api/revisions/f2eb965eb9af/schema)
