---
title: "Merge 2-10 contexts into a single target (admin scope)"
method: POST
path: "/api/contexts/merge"
tags: ["Contexts"]
---

# Merge 2-10 contexts into a single target (admin scope)

`POST /api/contexts/merge`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/contexts/merge`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

Archives every source context (except the target, if it is also a source) and unions their tags + outbound links onto the target. Destructive — admin scope only.

## Request body

- object
  - `sourceIds` integer[], required: Must be distinct ids.
  - `targetId` integer: Defaults to the first (or otherwise chosen) sourceId when omitted.
  - `strategy` 'union'
  - `nameOverride` string
  - `descriptionOverride` string

## Response `200`

Merge result.

- object
  - `target` object
    - `id` integer
    - `name` string
    - `type` string
    - `lifecycle` string
    - `updatedAt` string, date-time
    - `tagCount` integer
    - `linkCount` integer
  - `archived` integer[]
  - `mergedTagsAdded` integer
  - `mergedLinksAdded` integer

## Other responses

- `400`: Validation failure (bad id count, duplicate ids, or a cross-tenant/nonexistent id).
- `401`: Missing or invalid credentials.

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
