---
title: "Create Proposal Test Environment"
method: POST
path: "/api/context-agent/chats/{chat_id}/test_environment"
tags: ["context-agent"]
---

# Create Proposal Test Environment

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

## 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}/test_environment`
- Auth: one of:
  - API key in header `X-API-KEY`
  - API key in cookie `Authorization`
  - OAuth 2 (password, token URL `/api/auth/token`)

Open a private temporary environment holding this proposal's changes, forked
from current Production, so a reviewer can ask Dot before deciding. The proposal
still merges into Production. Returns the reviewer's existing one when it exists,
first merging in what the proposal and Production gained since (``refreshed``).
One that cannot take those changes answers 409 ``test_environment_outdated``, since
it may hold the reviewer's own work: with ``replace`` a new one is opened
(``created``) and the old one stays as it is. When a new one could not take them
either, it answers 409 ``proposal_conflicts`` (the proposal conflicts with
Production) or 503 (Production has a write waiting for its commit).

Body:
    replace: Optional. Open a new environment when the reviewer's own cannot be updated.

Returns:
    {"environment": {id, slug, name, color, ephemeral, created_by, exists},
     "created": bool, "refreshed": bool}

## Path parameters

- `chat_id` string, required

## Request body

- BodyCreateProposalTestEnvironmentApiContextAgentChatsChatIdTestEnvironmentPost
  - `replace` 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)
