---
title: "Merge an anonymous subjectId into a real one (T414, widget-kit login-merge)"
method: POST
path: "/api/subjects/merge"
tags: ["Subjects"]
---

# Merge an anonymous subjectId into a real one (T414, widget-kit login-merge)

`POST /api/subjects/merge`

## Request

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

Atomically re-keys every row tagged `fromSubjectId` onto `toSubjectId` — contexts, stored conversations, group memberships (deduped on collision), and the subjects registry row itself.

## Request body

- object
  - `fromSubjectId` string, required
  - `toSubjectId` string, required

## Response `200`

Merge complete.

- object
  - `message` string
  - `from_subject_id` string
  - `to_subject_id` string
  - `contexts_moved` integer
  - `conversations_moved` integer
  - `group_memberships_moved` integer
  - `group_memberships_deduped` integer
  - `subject_registry_merged` boolean

## Other responses

- `400`: Validation failure (e.g. fromSubjectId == toSubjectId, or one of them doesn't exist).
- `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)
