app-server.md +298 −39
1# Codex App Server1# Codex App Server
2 2
3Embed Codex into your product with the app-server protocol
4
5Codex app-server is the interface Codex uses to power rich clients (for example, the Codex VS Code extension). Use it when you want a deep integration inside your own product: authentication, conversation history, approvals, and streamed agent events. The app-server implementation is open source in the Codex GitHub repository ([openai/codex/codex-rs/app-server](https://github.com/openai/codex/tree/main/codex-rs/app-server)). See the [Open Source](https://developers.openai.com/codex/open-source) page for the full list of open-source Codex components.3Codex app-server is the interface Codex uses to power rich clients (for example, the Codex VS Code extension). Use it when you want a deep integration inside your own product: authentication, conversation history, approvals, and streamed agent events. The app-server implementation is open source in the Codex GitHub repository ([openai/codex/codex-rs/app-server](https://github.com/openai/codex/tree/main/codex-rs/app-server)). See the [Open Source](https://developers.openai.com/codex/open-source) page for the full list of open-source Codex components.
6 4
7If you are automating jobs or running Codex in CI, use the5If you are automating jobs or running Codex in CI, use the
23Requests include `method`, `params`, and `id`:21Requests include `method`, `params`, and `id`:
24 22
25```json23```json
2624{ "method": "thread/start", "id": 10, "params": { "model": "gpt-5.1-codex" } }{ "method": "thread/start", "id": 10, "params": { "model": "gpt-5.4" } }
27```25```
28 26
29Responses echo the `id` with either `result` or `error`:27Responses echo the `id` with either `result` or `error`:
101 },99 },
102});100});
103send({ method: "initialized", params: {} });101send({ method: "initialized", params: {} });
104102send({ method: "thread/start", id: 1, params: { model: "gpt-5.1-codex" } });send({ method: "thread/start", id: 1, params: { model: "gpt-5.4" } });
105```103```
106 104
107## Core primitives105## Core primitives
118- **Start (or resume) a thread**: Call `thread/start` for a new conversation, `thread/resume` to continue an existing one, or `thread/fork` to branch history into a new thread id.116- **Start (or resume) a thread**: Call `thread/start` for a new conversation, `thread/resume` to continue an existing one, or `thread/fork` to branch history into a new thread id.
119- **Begin a turn**: Call `turn/start` with the target `threadId` and user input. Optional fields override model, personality, `cwd`, sandbox policy, and more.117- **Begin a turn**: Call `turn/start` with the target `threadId` and user input. Optional fields override model, personality, `cwd`, sandbox policy, and more.
120- **Steer an active turn**: Call `turn/steer` to append user input to the currently in-flight turn without creating a new turn.118- **Steer an active turn**: Call `turn/steer` to append user input to the currently in-flight turn without creating a new turn.
121119- **Stream events**: After `turn/start`, keep reading notifications on stdout: `item/started`, `item/completed`, `item/agentMessage/delta`, tool progress, and other updates.- **Stream events**: After `turn/start`, keep reading notifications on stdout: `thread/archived`, `thread/unarchived`, `item/started`, `item/completed`, `item/agentMessage/delta`, tool progress, and other updates.
122- **Finish the turn**: The server emits `turn/completed` with final status when the model finishes or after a `turn/interrupt` cancellation.120- **Finish the turn**: The server emits `turn/completed` with final status when the model finishes or after a `turn/interrupt` cancellation.
123 121
124## Initialization122## Initialization
125 123
126Clients must send a single `initialize` request per transport connection before invoking any other method on that connection, then acknowledge with an `initialized` notification. Requests sent before initialization receive a `Not initialized` error, and repeated `initialize` calls on the same connection return `Already initialized`.124Clients must send a single `initialize` request per transport connection before invoking any other method on that connection, then acknowledge with an `initialized` notification. Requests sent before initialization receive a `Not initialized` error, and repeated `initialize` calls on the same connection return `Already initialized`.
127 125
128126The server returns the user agent string it will present to upstream services. Set `clientInfo` to identify your integration.The server returns the user agent string it will present to upstream services plus `platformFamily` and `platformOs` values that describe the runtime target. Set `clientInfo` to identify your integration.
129 127
130`initialize.params.capabilities` also supports per-connection notification opt-out via `optOutNotificationMethods`, which is a list of exact method names to suppress for that connection. Matching is exact (no wildcards/prefixes). Unknown method names are accepted and ignored.128`initialize.params.capabilities` also supports per-connection notification opt-out via `optOutNotificationMethods`, which is a list of exact method names to suppress for that connection. Matching is exact (no wildcards/prefixes). Unknown method names are accepted and ignored.
131 129
161 },159 },
162 "capabilities": {160 "capabilities": {
163 "experimentalApi": true,161 "experimentalApi": true,
164162 "optOutNotificationMethods": [ "optOutNotificationMethods": ["thread/started", "item/agentMessage/delta"]
165 "codex/event/session_configured",
166 "item/agentMessage/delta"
167 ]
168 }163 }
169 }164 }
170}165}
203- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.198- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.
204- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.199- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.
205- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread.200- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread.
206201- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history.- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history. Returned `thread` objects include runtime `status`.
207202- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filters.- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filters. Returned `thread` objects include runtime `status`.
208- `thread/loaded/list` - list the thread ids currently loaded in memory.203- `thread/loaded/list` - list the thread ids currently loaded in memory.
209204- `thread/archive` - move a thread’s log file into the archived directory; returns `{}` on success.- `thread/name/set` - set or update a thread's user-facing name for a loaded thread or a persisted rollout; emits `thread/name/updated`.
210205- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread`.- `thread/archive` - move a thread's log file into the archived directory; returns `{}` on success and emits `thread/archived`.
206- `thread/unsubscribe` - unsubscribe this connection from thread turn/item events. If this was the last subscriber, the server unloads the thread and emits `thread/closed`.
207- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread` and emits `thread/unarchived`.
208- `thread/status/changed` - notification emitted when a loaded thread's runtime `status` changes.
211- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.209- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.
212- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.210- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.
213- `turn/start` - add user input to a thread and begin Codex generation; responds with the initial `turn` and streams events. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode."211- `turn/start` - add user input to a thread and begin Codex generation; responds with the initial `turn` and streams events. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode."
215- `turn/interrupt` - request cancellation of an in-flight turn; success is `{}` and the turn ends with `status: "interrupted"`.213- `turn/interrupt` - request cancellation of an in-flight turn; success is `{}` and the turn ends with `status: "interrupted"`.
216- `review/start` - kick off the Codex reviewer for a thread; emits `enteredReviewMode` and `exitedReviewMode` items.214- `review/start` - kick off the Codex reviewer for a thread; emits `enteredReviewMode` and `exitedReviewMode` items.
217- `command/exec` - run a single command under the server sandbox without starting a thread/turn.215- `command/exec` - run a single command under the server sandbox without starting a thread/turn.
216- `command/exec/write` - write stdin bytes to a running `command/exec` session or close stdin.
217- `command/exec/resize` - resize a running PTY-backed `command/exec` session.
218- `command/exec/terminate` - terminate a running `command/exec` session.
218- `model/list` - list available models (set `includeHidden: true` to include entries with `hidden: true`) with effort options, optional `upgrade`, and `inputModalities`.219- `model/list` - list available models (set `includeHidden: true` to include entries with `hidden: true`) with effort options, optional `upgrade`, and `inputModalities`.
219- `experimentalFeature/list` - list feature flags with lifecycle stage metadata and cursor pagination.220- `experimentalFeature/list` - list feature flags with lifecycle stage metadata and cursor pagination.
220- `collaborationMode/list` - list collaboration mode presets (experimental, no pagination).221- `collaborationMode/list` - list collaboration mode presets (experimental, no pagination).
221- `skills/list` - list skills for one or more `cwd` values (supports `forceReload` and optional `perCwdExtraUserRoots`).222- `skills/list` - list skills for one or more `cwd` values (supports `forceReload` and optional `perCwdExtraUserRoots`).
223- `plugin/list` - list discovered plugin marketplaces and plugin state, including install/auth policy metadata.
224- `plugin/read` - read one plugin by marketplace path and plugin name, including bundled skills, apps, and MCP server names.
222- `app/list` - list available apps (connectors) with pagination plus accessibility/enabled metadata.225- `app/list` - list available apps (connectors) with pagination plus accessibility/enabled metadata.
223- `skills/config/write` - enable or disable skills by path.226- `skills/config/write` - enable or disable skills by path.
224- `mcpServer/oauth/login` - start an OAuth login for a configured MCP server; returns an authorization URL and emits `mcpServer/oauthLogin/completed` on completion.227- `mcpServer/oauth/login` - start an OAuth login for a configured MCP server; returns an authorization URL and emits `mcpServer/oauthLogin/completed` on completion.
225- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.228- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.
226- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.229- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.
227- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination).230- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination).
228231- `feedback/upload` - submit a feedback report (classification + optional reason/logs + conversation id).- `windowsSandbox/setupStart` - start Windows sandbox setup for `elevated` or `unelevated` mode; returns quickly and later emits `windowsSandbox/setupCompleted`.
232- `feedback/upload` - submit a feedback report (classification + optional reason/logs + conversation id, plus optional `extraLogFiles` attachments).
229- `config/read` - fetch the effective configuration on disk after resolving configuration layering.233- `config/read` - fetch the effective configuration on disk after resolving configuration layering.
234- `externalAgentConfig/detect` - detect migratable external-agent artifacts with `includeHome` and optional `cwds`; each detected item includes `cwd` (`null` for home).
235- `externalAgentConfig/import` - apply selected external-agent migration items by passing explicit `migrationItems` with `cwd` (`null` for home).
230- `config/value/write` - write a single configuration key/value to the user's `config.toml` on disk.236- `config/value/write` - write a single configuration key/value to the user's `config.toml` on disk.
231- `config/batchWrite` - apply configuration edits atomically to the user's `config.toml` on disk.237- `config/batchWrite` - apply configuration edits atomically to the user's `config.toml` on disk.
232238- `configRequirements/read` - fetch requirements from `requirements.toml` and/or MDM, including allow-lists and residency requirements (or `null` if you haven’t set any up).- `configRequirements/read` - fetch requirements from `requirements.toml` and/or MDM, including allow-lists, pinned `featureRequirements`, and residency/network requirements (or `null` if you haven't set any up).
239- `fs/readFile`, `fs/writeFile`, `fs/createDirectory`, `fs/getMetadata`, `fs/readDirectory`, `fs/remove`, and `fs/copy` - operate on absolute filesystem paths through the app-server v2 filesystem API.
233 240
234## Models241## Models
235 242
241{ "method": "model/list", "id": 6, "params": { "limit": 20, "includeHidden": false } }248{ "method": "model/list", "id": 6, "params": { "limit": 20, "includeHidden": false } }
242{ "id": 6, "result": {249{ "id": 6, "result": {
243 "data": [{250 "data": [{
244251 "id": "gpt-5.2-codex", "id": "gpt-5.4",
245252 "model": "gpt-5.2-codex", "model": "gpt-5.4",
246253 "upgrade": "gpt-5.3-codex", "displayName": "GPT-5.4",
247 "displayName": "GPT-5.2 Codex",
248 "hidden": false,254 "hidden": false,
249 "defaultReasoningEffort": "medium",255 "defaultReasoningEffort": "medium",
250256 "reasoningEffort": [{ "supportedReasoningEfforts": [{
251257 "effort": "low", "reasoningEffort": "low",
252 "description": "Lower latency"258 "description": "Lower latency"
253 }],259 }],
254 "inputModalities": ["text", "image"],260 "inputModalities": ["text", "image"],
261 267
262Each model entry can include:268Each model entry can include:
263 269
264270- `reasoningEffort` - supported effort options for the model.- `supportedReasoningEfforts` - supported effort options for the model.
265- `defaultReasoningEffort` - suggested default effort for clients.271- `defaultReasoningEffort` - suggested default effort for clients.
266- `upgrade` - optional recommended upgrade model id for migration prompts in clients.272- `upgrade` - optional recommended upgrade model id for migration prompts in clients.
273- `upgradeInfo` - optional upgrade metadata for migration prompts in clients.
267- `hidden` - whether the model is hidden from the default picker list.274- `hidden` - whether the model is hidden from the default picker list.
268- `inputModalities` - supported input types for the model (for example `text`, `image`).275- `inputModalities` - supported input types for the model (for example `text`, `image`).
269- `supportsPersonality` - whether the model supports personality-specific instructions such as `/personality`.276- `supportsPersonality` - whether the model supports personality-specific instructions such as `/personality`.
301- `thread/list` supports cursor pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filtering.308- `thread/list` supports cursor pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filtering.
302- `thread/loaded/list` returns the thread IDs currently in memory.309- `thread/loaded/list` returns the thread IDs currently in memory.
303- `thread/archive` moves the thread's persisted JSONL log into the archived directory.310- `thread/archive` moves the thread's persisted JSONL log into the archived directory.
311- `thread/unsubscribe` unsubscribes the current connection from a loaded thread and can trigger `thread/closed`.
304- `thread/unarchive` restores an archived thread rollout back into the active sessions directory.312- `thread/unarchive` restores an archived thread rollout back into the active sessions directory.
305- `thread/compact/start` triggers compaction and returns `{}` immediately.313- `thread/compact/start` triggers compaction and returns `{}` immediately.
306- `thread/rollback` drops the last N turns from the in-memory context and records a rollback marker in the thread's persisted JSONL log.314- `thread/rollback` drops the last N turns from the in-memory context and records a rollback marker in the thread's persisted JSONL log.
311 319
312```json320```json
313{ "method": "thread/start", "id": 10, "params": {321{ "method": "thread/start", "id": 10, "params": {
314322 "model": "gpt-5.1-codex", "model": "gpt-5.4",
315 "cwd": "/Users/me/project",323 "cwd": "/Users/me/project",
316 "approvalPolicy": "never",324 "approvalPolicy": "never",
317 "sandbox": "workspaceWrite",325 "sandbox": "workspaceWrite",
318326 "personality": "friendly" "personality": "friendly",
327 "serviceName": "my_app_server_client"
319} }328} }
320{ "id": 10, "result": {329{ "id": 10, "result": {
321 "thread": {330 "thread": {
322 "id": "thr_123",331 "id": "thr_123",
323 "preview": "",332 "preview": "",
333 "ephemeral": false,
324 "modelProvider": "openai",334 "modelProvider": "openai",
325 "createdAt": 1730910000335 "createdAt": 1730910000
326 }336 }
328{ "method": "thread/started", "params": { "thread": { "id": "thr_123" } } }338{ "method": "thread/started", "params": { "thread": { "id": "thr_123" } } }
329```339```
330 340
341`serviceName` is optional. Set it when you want app-server to tag thread-level metrics with your integration's service name.
342
331To continue a stored session, call `thread/resume` with the `thread.id` you recorded earlier. The response shape matches `thread/start`. You can also pass the same configuration overrides supported by `thread/start`, such as `personality`:343To continue a stored session, call `thread/resume` with the `thread.id` you recorded earlier. The response shape matches `thread/start`. You can also pass the same configuration overrides supported by `thread/start`, such as `personality`:
332 344
333```json345```json
335 "threadId": "thr_123",347 "threadId": "thr_123",
336 "personality": "friendly"348 "personality": "friendly"
337} }349} }
338350{ "id": 11, "result": { "thread": { "id": "thr_123" } } }{ "id": 11, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "ephemeral": false } } }
339```351```
340 352
341Resuming a thread doesn't update `thread.updatedAt` (or the rollout file's modified time) by itself. The timestamp updates when you start a turn.353Resuming a thread doesn't update `thread.updatedAt` (or the rollout file's modified time) by itself. The timestamp updates when you start a turn.
354{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }366{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }
355```367```
356 368
369When a user-facing thread title has been set, app-server hydrates `thread.name` on `thread/list`, `thread/read`, `thread/resume`, `thread/unarchive`, and `thread/rollback` responses. `thread/start` and `thread/fork` may omit `name` (or return `null`) until a title is set later.
370
357### Read a stored thread (without resuming)371### Read a stored thread (without resuming)
358 372
359Use `thread/read` when you want stored thread data but don't want to resume the thread or subscribe to its events.373Use `thread/read` when you want stored thread data but don't want to resume the thread or subscribe to its events.
360 374
361- `includeTurns` - when `true`, the response includes the thread's turns; when `false` or omitted, you get the thread summary only.375- `includeTurns` - when `true`, the response includes the thread's turns; when `false` or omitted, you get the thread summary only.
376- Returned `thread` objects include runtime `status` (`notLoaded`, `idle`, `systemError`, or `active` with `activeFlags`).
362 377
363```json378```json
364{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }379{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }
365380{ "id": 19, "result": { "thread": { "id": "thr_123", "turns": [] } } }{ "id": 19, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "ephemeral": false, "status": { "type": "notLoaded" }, "turns": [] } } }
366```381```
367 382
368Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.383Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.
402} }417} }
403{ "id": 20, "result": {418{ "id": 20, "result": {
404 "data": [419 "data": [
405420 { "id": "thr_a", "preview": "Create a TUI", "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111 }, { "id": "thr_a", "preview": "Create a TUI", "ephemeral": false, "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111, "name": "TUI prototype", "status": { "type": "notLoaded" } },
406421 { "id": "thr_b", "preview": "Fix tests", "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000 } { "id": "thr_b", "preview": "Fix tests", "ephemeral": true, "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000, "status": { "type": "notLoaded" } }
407 ],422 ],
408 "nextCursor": "opaque-token-or-null"423 "nextCursor": "opaque-token-or-null"
409} }424} }
411 426
412When `nextCursor` is `null`, you have reached the final page.427When `nextCursor` is `null`, you have reached the final page.
413 428
429### Track thread status changes
430
431`thread/status/changed` is emitted whenever a loaded thread's runtime status changes. The payload includes `threadId` and the new `status`.
432
433```json
434{
435 "method": "thread/status/changed",
436 "params": {
437 "threadId": "thr_123",
438 "status": { "type": "active", "activeFlags": ["waitingOnApproval"] }
439 }
440}
441```
442
414### List loaded threads443### List loaded threads
415 444
416`thread/loaded/list` returns thread IDs currently loaded in memory.445`thread/loaded/list` returns thread IDs currently loaded in memory.
420{ "id": 21, "result": { "data": ["thr_123", "thr_456"] } }449{ "id": 21, "result": { "data": ["thr_123", "thr_456"] } }
421```450```
422 451
452### Unsubscribe from a loaded thread
453
454`thread/unsubscribe` removes the current connection's subscription to a thread. The response status is one of:
455
456- `unsubscribed` when the connection was subscribed and is now removed.
457- `notSubscribed` when the connection was not subscribed to that thread.
458- `notLoaded` when the thread is not loaded.
459
460If this was the last subscriber, the server unloads the thread and emits a `thread/status/changed` transition to `notLoaded` plus `thread/closed`.
461
462```json
463{ "method": "thread/unsubscribe", "id": 22, "params": { "threadId": "thr_123" } }
464{ "id": 22, "result": { "status": "unsubscribed" } }
465{ "method": "thread/status/changed", "params": {
466 "threadId": "thr_123",
467 "status": { "type": "notLoaded" }
468} }
469{ "method": "thread/closed", "params": { "threadId": "thr_123" } }
470```
471
423### Archive a thread472### Archive a thread
424 473
425Use `thread/archive` to move the persisted thread log (stored as a JSONL file on disk) into the archived sessions directory.474Use `thread/archive` to move the persisted thread log (stored as a JSONL file on disk) into the archived sessions directory.
427```json476```json
428{ "method": "thread/archive", "id": 22, "params": { "threadId": "thr_b" } }477{ "method": "thread/archive", "id": 22, "params": { "threadId": "thr_b" } }
429{ "id": 22, "result": {} }478{ "id": 22, "result": {} }
479{ "method": "thread/archived", "params": { "threadId": "thr_b" } }
430```480```
431 481
432Archived threads won't appear in future calls to `thread/list` unless you pass `archived: true`.482Archived threads won't appear in future calls to `thread/list` unless you pass `archived: true`.
437 487
438```json488```json
439{ "method": "thread/unarchive", "id": 24, "params": { "threadId": "thr_b" } }489{ "method": "thread/unarchive", "id": 24, "params": { "threadId": "thr_b" } }
440490{ "id": 24, "result": { "thread": { "id": "thr_b" } } }{ "id": 24, "result": { "thread": { "id": "thr_b", "name": "Bug bash notes" } } }
491{ "method": "thread/unarchived", "params": { "threadId": "thr_b" } }
441```492```
442 493
443### Trigger thread compaction494### Trigger thread compaction
451{ "id": 25, "result": {} }502{ "id": 25, "result": {} }
452```503```
453 504
505### Roll back recent turns
506
507Use `thread/rollback` to remove the last `numTurns` entries from the in-memory context and persist a rollback marker in the rollout log. The returned `thread` includes `turns` populated after the rollback.
508
509```json
510{ "method": "thread/rollback", "id": 26, "params": { "threadId": "thr_b", "numTurns": 1 } }
511{ "id": 26, "result": { "thread": { "id": "thr_b", "name": "Bug bash notes", "ephemeral": false } } }
512```
513
454## Turns514## Turns
455 515
456The `input` field accepts a list of items:516The `input` field accepts a list of items:
480}540}
481```541```
482 542
543On macOS, `includePlatformDefaults: true` appends a curated platform-default Seatbelt policy for restricted-read sessions. This improves tool compatibility without broadly allowing all of `/System`.
544
483Examples:545Examples:
484 546
485```json547```json
512 "writableRoots": ["/Users/me/project"],574 "writableRoots": ["/Users/me/project"],
513 "networkAccess": true575 "networkAccess": true
514 },576 },
515577 "model": "gpt-5.1-codex", "model": "gpt-5.4",
516 "effort": "medium",578 "effort": "medium",
517 "summary": "concise",579 "summary": "concise",
518 "personality": "friendly",580 "personality": "friendly",
655- The server rejects empty `command` arrays.717- The server rejects empty `command` arrays.
656- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).718- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).
657- When omitted, `timeoutMs` falls back to the server default.719- When omitted, `timeoutMs` falls back to the server default.
720- Set `tty: true` for PTY-backed sessions, and use `processId` when you plan to follow up with `command/exec/write`, `command/exec/resize`, or `command/exec/terminate`.
721- Set `streamStdoutStderr: true` to receive `command/exec/outputDelta` notifications while the command is running.
722
723### Read admin requirements (`configRequirements/read`)
724
725Use `configRequirements/read` to inspect the effective admin requirements loaded from `requirements.toml` and/or MDM.
726
727```json
728{ "method": "configRequirements/read", "id": 52, "params": {} }
729{ "id": 52, "result": {
730 "requirements": {
731 "allowedApprovalPolicies": ["onRequest", "unlessTrusted"],
732 "allowedSandboxModes": ["readOnly", "workspaceWrite"],
733 "featureRequirements": {
734 "personality": true,
735 "unified_exec": false
736 },
737 "network": {
738 "enabled": true,
739 "allowedDomains": ["api.openai.com"],
740 "allowUnixSockets": ["/tmp/example.sock"],
741 "dangerouslyAllowAllUnixSockets": false
742 }
743 }
744} }
745```
746
747`result.requirements` is `null` when no requirements are configured. See the docs on [`requirements.toml`](https://developers.openai.com/codex/config-reference#requirementstoml) for details on supported keys and values.
748
749### Windows sandbox setup (`windowsSandbox/setupStart`)
750
751Custom Windows clients can trigger sandbox setup asynchronously instead of blocking on startup checks.
752
753```json
754{ "method": "windowsSandbox/setupStart", "id": 53, "params": { "mode": "elevated" } }
755{ "id": 53, "result": { "started": true } }
756```
757
758App-server starts setup in the background and later emits a completion notification:
759
760```json
761{
762 "method": "windowsSandbox/setupCompleted",
763 "params": { "mode": "elevated", "success": true, "error": null }
764}
765```
766
767Modes:
768
769- `elevated` - run the elevated Windows sandbox setup path.
770- `unelevated` - run the legacy setup/preflight path.
658 771
659## Events772## Events
660 773
661774Event notifications are the server-initiated stream for thread lifecycles, turn lifecycles, and the items within them. After you start or resume a thread, keep reading the active transport stream for `thread/started`, `turn/*`, and `item/*` notifications.Event notifications are the server-initiated stream for thread lifecycles, turn lifecycles, and the items within them. After you start or resume a thread, keep reading the active transport stream for `thread/started`, `thread/archived`, `thread/unarchived`, `thread/closed`, `thread/status/changed`, `turn/*`, `item/*`, and `serverRequest/resolved` notifications.
662 775
663### Notification opt-out776### Notification opt-out
664 777
666 779
667- Exact-match only: `item/agentMessage/delta` suppresses only that method.780- Exact-match only: `item/agentMessage/delta` suppresses only that method.
668- Unknown method names are ignored.781- Unknown method names are ignored.
669782- Applies to both legacy (`codex/event/*`) and v2 (`thread/*`, `turn/*`, `item/*`, etc.) notifications.- Applies to the current `thread/*`, `turn/*`, `item/*`, and related v2 notifications.
670- Doesn't apply to requests, responses, or errors.783- Doesn't apply to requests, responses, or errors.
671 784
672### Fuzzy file search events (experimental)785### Fuzzy file search events (experimental)
676- `fuzzyFileSearch/sessionUpdated` - `{ sessionId, query, files }` with the current matches for the active query.789- `fuzzyFileSearch/sessionUpdated` - `{ sessionId, query, files }` with the current matches for the active query.
677- `fuzzyFileSearch/sessionCompleted` - `{ sessionId }` once indexing and matching for that query completes.790- `fuzzyFileSearch/sessionCompleted` - `{ sessionId }` once indexing and matching for that query completes.
678 791
792### Windows sandbox setup events
793
794- `windowsSandbox/setupCompleted` - `{ mode, success, error }` emitted after a `windowsSandbox/setupStart` request finishes.
795
679### Turn events796### Turn events
680 797
681- `turn/started` - `{ turn }` with the turn id, empty `items`, and `status: "inProgress"`.798- `turn/started` - `{ turn }` with the turn id, empty `items`, and `status: "inProgress"`.
691`ThreadItem` is the tagged union carried in turn responses and `item/*` notifications. Common item types include:808`ThreadItem` is the tagged union carried in turn responses and `item/*` notifications. Common item types include:
692 809
693- `userMessage` - `{id, content}` where `content` is a list of user inputs (`text`, `image`, or `localImage`).810- `userMessage` - `{id, content}` where `content` is a list of user inputs (`text`, `image`, or `localImage`).
694811- `agentMessage` - `{id, text}` containing the accumulated agent reply.- `agentMessage` - `{id, text, phase?}` containing the accumulated agent reply. When present, `phase` uses Responses API wire values (`commentary`, `final_answer`).
695- `plan` - `{id, text}` containing proposed plan text in plan mode. Treat the final `plan` item from `item/completed` as authoritative.812- `plan` - `{id, text}` containing proposed plan text in plan mode. Treat the final `plan` item from `item/completed` as authoritative.
696- `reasoning` - `{id, summary, content}` where `summary` holds streamed reasoning summaries and `content` holds raw reasoning blocks.813- `reasoning` - `{id, summary, content}` where `summary` holds streamed reasoning summaries and `content` holds raw reasoning blocks.
697- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.814- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.
698- `fileChange` - `{id, changes, status}` describing proposed edits; `changes` list `{path, kind, diff}`.815- `fileChange` - `{id, changes, status}` describing proposed edits; `changes` list `{path, kind, diff}`.
699- `mcpToolCall` - `{id, server, tool, status, arguments, result?, error?}`.816- `mcpToolCall` - `{id, server, tool, status, arguments, result?, error?}`.
817- `dynamicToolCall` - `{id, tool, arguments, status, contentItems?, success?, durationMs?}` for client-executed dynamic tool invocations.
700- `collabToolCall` - `{id, tool, status, senderThreadId, receiverThreadId?, newThreadId?, prompt?, agentStatus?}`.818- `collabToolCall` - `{id, tool, status, senderThreadId, receiverThreadId?, newThreadId?, prompt?, agentStatus?}`.
701- `webSearch` - `{id, query, action?}` for web search requests issued by the agent.819- `webSearch` - `{id, query, action?}` for web search requests issued by the agent.
702- `imageView` - `{id, path}` emitted when the agent invokes the image viewer tool.820- `imageView` - `{id, path}` emitted when the agent invokes the image viewer tool.
753Order of messages:871Order of messages:
754 872
7551. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.8731. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.
7568742. `item/commandExecution/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, optional `command`, optional `cwd`, optional `commandActions`, and optional `proposedExecpolicyAmendment`.2. `item/commandExecution/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, optional `command`, optional `cwd`, optional `commandActions`, optional `proposedExecpolicyAmendment`, optional `networkApprovalContext`, and optional `availableDecisions`. When `initialize.params.capabilities.experimentalApi = true`, the payload can also include experimental `additionalPermissions` describing requested per-command sandbox access. Any filesystem paths inside `additionalPermissions` are absolute on the wire.
7573. Client responds with one of the command execution approval decisions above.8753. Client responds with one of the command execution approval decisions above.
7588764. `item/completed` returns the final `commandExecution` item with `status: completed | failed | declined`.4. `serverRequest/resolved` confirms that the pending request has been answered or cleared.
8775. `item/completed` returns the final `commandExecution` item with `status: completed | failed | declined`.
878
879When `networkApprovalContext` is present, the prompt is for managed network access (not a general shell-command approval). The current v2 schema exposes the target `host` and `protocol`; clients should render a network-specific prompt and not rely on `command` being a user-meaningful shell command preview.
880
881Codex groups concurrent network approval prompts by destination (`host`, protocol, and port). The app-server may therefore send one prompt that unblocks multiple queued requests to the same destination, while different ports on the same host are treated separately.
759 882
760### File change approvals883### File change approvals
761 884
7641. `item/started` emits a `fileChange` item with proposed `changes` and `status: "inProgress"`.8871. `item/started` emits a `fileChange` item with proposed `changes` and `status: "inProgress"`.
7652. `item/fileChange/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, and optional `grantRoot`.8882. `item/fileChange/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, and optional `grantRoot`.
7663. Client responds with one of the file change approval decisions above.8893. Client responds with one of the file change approval decisions above.
7678904. `item/completed` returns the final `fileChange` item with `status: completed | failed | declined`.4. `serverRequest/resolved` confirms that the pending request has been answered or cleared.
8915. `item/completed` returns the final `fileChange` item with `status: completed | failed | declined`.
892
893### `tool/requestUserInput`
894
895When the client responds to `item/tool/requestUserInput`, app-server emits `serverRequest/resolved` with `{ threadId, requestId }`. If the pending request is cleared by turn start, turn completion, or turn interruption before the client answers, the server emits the same notification for that cleanup.
896
897### Dynamic tool calls (experimental)
898
899`dynamicTools` on `thread/start` and the corresponding `item/tool/call` request or response flow are experimental APIs.
900
901When a dynamic tool is invoked during a turn, app-server emits:
902
9031. `item/started` with `item.type = "dynamicToolCall"`, `status = "inProgress"`, plus `tool` and `arguments`.
9042. `item/tool/call` as a server request to the client.
9053. The client response payload with returned content items.
9064. `item/completed` with `item.type = "dynamicToolCall"`, the final `status`, and any returned `contentItems` or `success` value.
768 907
769### MCP tool-call approvals (apps)908### MCP tool-call approvals (apps)
770 909
771910App (connector) tool calls can also require approval. When an app tool call has side effects, the server may elicit approval with `tool/requestUserInput` and options such as **Accept**, **Decline**, and **Cancel**. If the user declines or cancels, the related `mcpToolCall` item completes with an error instead of running the tool.App (connector) tool calls can also require approval. When an app tool call has side effects, the server may elicit approval with `tool/requestUserInput` and options such as **Accept**, **Decline**, and **Cancel**. Destructive tool annotations always trigger approval even when the tool also advertises less-privileged hints. If the user declines or cancels, the related `mcpToolCall` item completes with an error instead of running the tool.
772 911
773## Skills912## Skills
774 913
865 1004
866## Apps (connectors)1005## Apps (connectors)
867 1006
8681007Use `app/list` to fetch available apps. In the CLI/TUI, `/apps` is the user-facing picker; in custom clients, call `app/list` directly. Each entry includes both `isAccessible` (available to the user) and `isEnabled` (enabled in `config.toml`) so clients can distinguish install/access from local enabled state.Use `app/list` to fetch available apps. In the CLI/TUI, `/apps` is the user-facing picker; in custom clients, call `app/list` directly. Each entry includes both `isAccessible` (available to the user) and `isEnabled` (enabled in `config.toml`) so clients can distinguish install/access from local enabled state. App entries can also include optional `branding`, `appMetadata`, and `labels` fields.
869 1008
870```json1009```json
871{ "method": "app/list", "id": 50, "params": {1010{ "method": "app/list", "id": 50, "params": {
881 "name": "Demo App",1020 "name": "Demo App",
882 "description": "Example connector for documentation.",1021 "description": "Example connector for documentation.",
883 "logoUrl": "https://example.com/demo-app.png",1022 "logoUrl": "https://example.com/demo-app.png",
1023 "logoUrlDark": null,
1024 "distributionChannel": null,
1025 "branding": null,
1026 "appMetadata": null,
1027 "labels": null,
884 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",1028 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",
885 "isAccessible": true,1029 "isAccessible": true,
886 "isEnabled": true1030 "isEnabled": true
906 "name": "Demo App",1050 "name": "Demo App",
907 "description": "Example connector for documentation.",1051 "description": "Example connector for documentation.",
908 "logoUrl": "https://example.com/demo-app.png",1052 "logoUrl": "https://example.com/demo-app.png",
1053 "logoUrlDark": null,
1054 "distributionChannel": null,
1055 "branding": null,
1056 "appMetadata": null,
1057 "labels": null,
909 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",1058 "installUrl": "https://chatgpt.com/apps/demo-app/demo-app",
910 "isAccessible": true,1059 "isAccessible": true,
911 "isEnabled": true1060 "isEnabled": true
938}1087}
939```1088```
940 1089
1090### Config RPC examples for app settings
1091
1092Use `config/read`, `config/value/write`, and `config/batchWrite` to inspect or update app controls in `config.toml`.
1093
1094Read the effective app config shape (including `_default` and per-tool overrides):
1095
1096```json
1097{ "method": "config/read", "id": 60, "params": { "includeLayers": false } }
1098{ "id": 60, "result": {
1099 "config": {
1100 "apps": {
1101 "_default": {
1102 "enabled": true,
1103 "destructive_enabled": true,
1104 "open_world_enabled": true
1105 },
1106 "google_drive": {
1107 "enabled": true,
1108 "destructive_enabled": false,
1109 "default_tools_approval_mode": "prompt",
1110 "tools": {
1111 "files/delete": { "enabled": false, "approval_mode": "approve" }
1112 }
1113 }
1114 }
1115 }
1116} }
1117```
1118
1119Update a single app setting:
1120
1121```json
1122{
1123 "method": "config/value/write",
1124 "id": 61,
1125 "params": {
1126 "keyPath": "apps.google_drive.default_tools_approval_mode",
1127 "value": "prompt",
1128 "mergeStrategy": "replace"
1129 }
1130}
1131```
1132
1133Apply multiple app edits atomically:
1134
1135```json
1136{
1137 "method": "config/batchWrite",
1138 "id": 62,
1139 "params": {
1140 "edits": [
1141 {
1142 "keyPath": "apps._default.destructive_enabled",
1143 "value": false,
1144 "mergeStrategy": "upsert"
1145 },
1146 {
1147 "keyPath": "apps.google_drive.tools.files/delete.approval_mode",
1148 "value": "approve",
1149 "mergeStrategy": "upsert"
1150 }
1151 ]
1152 }
1153}
1154```
1155
1156### Detect and import external agent config
1157
1158Use `externalAgentConfig/detect` to discover migratable external-agent artifacts, then pass the selected entries to `externalAgentConfig/import`.
1159
1160Detection example:
1161
1162```json
1163{ "method": "externalAgentConfig/detect", "id": 63, "params": {
1164 "includeHome": true,
1165 "cwds": ["/Users/me/project"]
1166} }
1167{ "id": 63, "result": {
1168 "items": [
1169 {
1170 "itemType": "AGENTS_MD",
1171 "description": "Import /Users/me/project/CLAUDE.md to /Users/me/project/AGENTS.md.",
1172 "cwd": "/Users/me/project"
1173 },
1174 {
1175 "itemType": "SKILLS",
1176 "description": "Copy skill folders from /Users/me/.claude/skills to /Users/me/.agents/skills.",
1177 "cwd": null
1178 }
1179 ]
1180} }
1181```
1182
1183Import example:
1184
1185```json
1186{ "method": "externalAgentConfig/import", "id": 64, "params": {
1187 "migrationItems": [
1188 {
1189 "itemType": "AGENTS_MD",
1190 "description": "Import /Users/me/project/CLAUDE.md to /Users/me/project/AGENTS.md.",
1191 "cwd": "/Users/me/project"
1192 }
1193 ]
1194} }
1195{ "id": 64, "result": {} }
1196```
1197
1198Supported `itemType` values are `AGENTS_MD`, `CONFIG`, `SKILLS`, and `MCP_SERVER_CONFIG`. Detection returns only items that still have work to do. For example, AGENTS migration is skipped when `AGENTS.md` already exists and is non-empty, and skill imports do not overwrite existing skill directories.
1199
941## Auth endpoints1200## Auth endpoints
942 1201
943The JSON-RPC auth/account surface exposes request/response methods plus server-initiated notifications (no `id`). Use these to determine auth state, start or cancel logins, logout, and inspect ChatGPT rate limits.1202The JSON-RPC auth/account surface exposes request/response methods plus server-initiated notifications (no `id`). Use these to determine auth state, start or cancel logins, logout, and inspect ChatGPT rate limits.