# Endpoint điều khiển

> Proxy cung cấp /__control để chuyển đổi chế độ theo lập trình giữa transparent, record, và replay.

Canonical: <https://test-proxy-recorder.dev/vi/docs/guides/control-endpoint/>
Docs index: <https://test-proxy-recorder.dev/docs/> · All docs as one file: <https://test-proxy-recorder.dev/llms-full.txt>

---

Proxy cung cấp `/__control` để chuyển đổi chế độ theo lập trình.

```bash
# Lấy trạng thái hiện tại
curl http://localhost:8100/__control

# Chuyển đổi chế độ
curl -X POST http://localhost:8100/__control \
  -H "Content-Type: application/json" \
  -d '{"mode": "record", "id": "my-test-1"}'
```

```typescript
interface ControlRequest {
  mode?: 'transparent' | 'record' | 'replay'; // bắt buộc trừ khi cleanup là true
  id?: string;       // bắt buộc cho record/replay (và cho cleanup)
  timeout?: number;  // timeout tự reset tính bằng ms (mặc định: 120000)
  cleanup?: boolean; // khi true, dọn dẹp session thay vì chuyển chế độ
  websocket?: WebSocketReplayConfig; // ghi đè nhịp phát lại WebSocket theo từng session
}
```

Trong hầu hết các thiết lập, bạn không gọi trực tiếp endpoint này — `playwrightProxy.before()` và `setProxyMode()` (xem [tham chiếu API](/vi/docs/reference/api/readme/)) thay bạn POST tới nó. Dùng `/__control` khi điều khiển proxy từ shell, một bước CI, hoặc một AI agent.
