---
title: "Merge Chat To Production"
method: POST
path: "/api/context-agent/chats/{chat_id}/merge"
tags: ["context-agent"]
---

# Merge Chat To Production

`POST /api/context-agent/chats/{chat_id}/merge`

## Request

- Base URL: `https://app.getdot.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://app.getdot.ai/api/context-agent/chats/{chat_id}/merge`
- Auth: one of:
  - API key in header `X-API-KEY`
  - API key in cookie `Authorization`
  - OAuth 2 (password, token URL `/api/auth/token`)

Merge session worktree changes to main production branch.

Supports selective merge: if selected_files is provided, only those files
are merged. Otherwise, performs a full git merge of the session branch.

Body:
    confirm: Must be true (CSRF protection)
    selected_files: Optional list of file paths to merge selectively
    expected_session_head: The diff's session_head the reviewer saw; 409 if it moved
    recheck_first: Re-check a training's unmeasured changes first; the merge lands once it passes

Returns:
    {"status": "success"} or {"status": "conflict", "conflicts": [...], "message": "..."}

## Path parameters

- `chat_id` string, required

## Request body

- BodyMergeChatToProductionApiContextAgentChatsChatIdMergePost
  - `confirm` boolean, required
  - `selected_files` string[], nullable
  - `expected_merge_target` 'production' | 'environment', nullable
  - `expected_main_head` string, nullable
  - `expected_environment_head` string, nullable
  - `expected_training_head` string, nullable
  - `expected_session_head` string, nullable
  - `confirm_below_threshold` boolean
  - `recheck_first` boolean

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/getdot/apis/dot-api-2.md) · [All operations](https://skmtc.dev/getdot/apis/dot-api-2/llms.txt) · [OpenAPI document](https://skmtc.dev/getdot/apis/dot-api-2/revisions/d26fe7163a7f?raw)
