---
title: "Merge Subgroups"
method: POST
path: "/claims/{claim_id}/expenditures/subgroups/merge"
tags: ["expenditures"]
---

# Merge Subgroups

`POST /claims/{claim_id}/expenditures/subgroups/merge`

## Request

- Base URL: `https://api.claimkit.co` (the document declares no server; this is the origin it was published from)
- URL: `https://api.claimkit.co/claims/{claim_id}/expenditures/subgroups/merge`
- Auth: none declared

Merge every item in ``source`` into ``target``. Each moved item picks
up ``target.category`` + ``target.subgroup_key`` and is flagged
``manual_override=True``.

Linked refunds are excluded from the sweep (derived rows) and instead follow
their original via the mirror — in both directions: the mirror here re-flows
the merged originals onto their refunds, and ``reverse_subgroup_merge`` mirrors
again on restore so the refunds come back out of the target too.

Records an :class:`AURDExpenditureSubgroupMergeEvent` capturing each
moved item's pre-merge tuple so an admin can later reverse the merge.

## Path parameters

- `claim_id` integer, required

## Request body

- MergeSubgroupRequest: Move every item in ``source`` into ``target``. After this completes, ``source`` no longer appears in the grouped view (no items left with that ``(category, subgroup_key)`` pair) and ``target`` absorbs the items.
  - `source` SubgroupRef, required: A single (category, subgroup_key) pair. ``subgroup_key`` is required — the salaries bucket uses synthesised keys per identity and isn't a valid merge target on either side.
    - `category` string, required
    - `subgroup_key` string, required
  - `target` SubgroupRef, required: A single (category, subgroup_key) pair. ``subgroup_key`` is required — the salaries bucket uses synthesised keys per identity and isn't a valid merge target on either side.
    - `category` string, required
    - `subgroup_key` string, required

## Response `200`

Successful Response

- BulkUpdateResponse
  - `updated_count` integer, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/claimkit/apis/claimkit-api.md) - [All operations](https://skmtc.dev/claimkit/apis/claimkit-api/llms.txt) - [OpenAPI document](https://skmtc.dev/claimkit/apis/claimkit-api/revisions/94dc85ba5326?raw)
