# コントロールエンドポイント

> プロキシは /__control を公開し、transparent・record・replay のモードをプログラムから切り替えられます。

Canonical: <https://test-proxy-recorder.dev/ja/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>

---

プロキシはプログラムからモードを切り替えるために `/__control` を公開しています。

```bash
# Get current state
curl http://localhost:8100/__control

# Switch modes
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'; // required unless cleanup is true
  id?: string;       // required for record/replay (and for cleanup)
  timeout?: number;  // auto-reset timeout in ms (default: 120000)
  cleanup?: boolean; // when true, clean up the session instead of switching mode
  websocket?: WebSocketReplayConfig; // per-session WebSocket replay pacing override
}
```

ほとんどのセットアップでは、これを直接呼ぶことはありません — `playwrightProxy.before()` と `setProxyMode()`（[API リファレンス](/docs/reference/api/readme/)参照）が代わりに POST します。シェル、CI のステップ、AI エージェントからプロキシを操作するときに `/__control` を使ってください。
