app-server.md +527 −62
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.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.
4 4
5If you are automating jobs or running Codex in CI, use the5If you are automating jobs or running Codex in CI, use the
66[Codex SDK](https://developers.openai.com/codex/sdk) instead. <a href="/codex/sdk">Codex SDK</a> instead.
7 7
8## Protocol8## Protocol
9 9
12Supported transports:12Supported transports:
13 13
14- `stdio` (`--listen stdio://`, default): newline-delimited JSON (JSONL).14- `stdio` (`--listen stdio://`, default): newline-delimited JSON (JSONL).
1515- `websocket` (`--listen ws://IP:PORT`, experimental): one JSON-RPC message per WebSocket text frame.- `websocket` (`--listen ws://IP:PORT`, experimental and unsupported): one
1616 JSON-RPC message per WebSocket text frame.
1717In WebSocket mode, app-server uses bounded queues. When request ingress is full, the server rejects new requests with JSON-RPC error code `-32001` and message `"Server overloaded; retry later."` Clients should retry with an exponentially increasing delay and jitter.- Unix socket (`--listen unix://` or `--listen unix://PATH`): WebSocket
18 connections over Codex's default app-server control socket or a custom Unix
19 socket path, using the standard HTTP Upgrade handshake.
20- `off` (`--listen off`): don't expose a local transport.
21
22When you run with `--listen ws://IP:PORT`, the same listener also serves basic
23HTTP health probes:
24
25- `GET /readyz` returns `200 OK` once the listener accepts new connections.
26- `GET /healthz` returns `200 OK` when the request doesn't include an `Origin`
27 header.
28- Requests with an `Origin` header are rejected with `403 Forbidden`.
29
30WebSocket transport is experimental and unsupported. Local listeners such as
31`ws://127.0.0.1:PORT` are appropriate for localhost and SSH port-forwarding
32workflows. Non-loopback WebSocket listeners currently allow unauthenticated
33connections by default during rollout, so configure WebSocket auth before
34exposing one remotely.
35
36Supported WebSocket auth flags:
37
38- `--ws-auth capability-token --ws-token-file /absolute/path`
39- `--ws-auth capability-token --ws-token-sha256 HEX`
40- `--ws-auth signed-bearer-token --ws-shared-secret-file /absolute/path`
41
42For signed bearer tokens, you can also set `--ws-issuer`, `--ws-audience`, and
43`--ws-max-clock-skew-seconds`. Clients present the credential as
44`Authorization: Bearer <token>` during the WebSocket handshake, and app-server
45enforces auth before JSON-RPC `initialize`.
46
47Prefer `--ws-token-file` over passing raw bearer tokens on the command line. Use
48`--ws-token-sha256` only when the client keeps the raw high-entropy token in a
49separate local secret store; the hash is only a verifier, and clients still need
50the original token.
51
52In WebSocket mode, app-server uses bounded queues. When request ingress is full,
53the server rejects new requests with JSON-RPC error code `-32001` and message
54`"Server overloaded; retry later."` Clients should retry with an exponentially
55increasing delay and jitter.
18 56
19## Message schema57## Message schema
20 58
21Requests include `method`, `params`, and `id`:59Requests include `method`, `params`, and `id`:
22 60
23```json61```json
2462{ "method": "thread/start", "id": 10, "params": { "model": "gpt-5.1-codex" } }{ "method": "thread/start", "id": 10, "params": { "model": "gpt-5.4" } }
25```63```
26 64
27Responses echo the `id` with either `result` or `error`:65Responses echo the `id` with either `result` or `error`:
49 87
50## Getting started88## Getting started
51 89
52901. Start the server with `codex app-server` (default stdio transport) or `codex app-server --listen ws://127.0.0.1:4500` (experimental WebSocket transport).1. Start the server with `codex app-server` (default stdio transport),
91 `codex app-server --listen ws://127.0.0.1:4500` (TCP WebSocket), or
92 `codex app-server --listen unix://` (default Unix socket).
532. Connect a client over the selected transport, then send `initialize` followed by the `initialized` notification.932. Connect a client over the selected transport, then send `initialize` followed by the `initialized` notification.
543. Start a thread and a turn, then keep reading notifications from the active transport stream.943. Start a thread and a turn, then keep reading notifications from the active transport stream.
55 95
56Example (Node.js / TypeScript):96Example (Node.js / TypeScript):
57 97
58```ts98```ts
5999import { spawn } from "node:child_process";
60100import readline from "node:readline";
61 101
62const proc = spawn("codex", ["app-server"], {102const proc = spawn("codex", ["app-server"], {
63 stdio: ["pipe", "pipe", "inherit"],103 stdio: ["pipe", "pipe", "inherit"],
99 },139 },
100});140});
101send({ method: "initialized", params: {} });141send({ method: "initialized", params: {} });
102142send({ method: "thread/start", id: 1, params: { model: "gpt-5.1-codex" } });send({ method: "thread/start", id: 1, params: { model: "gpt-5.4" } });
103```143```
104 144
105## Core primitives145## Core primitives
123 163
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`.164Clients 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`.
125 165
126166The 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.
127 167
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.168`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.
129 169
159 },199 },
160 "capabilities": {200 "capabilities": {
161 "experimentalApi": true,201 "experimentalApi": true,
162202 "optOutNotificationMethods": [ "optOutNotificationMethods": ["thread/started", "item/agentMessage/delta"]
163 "codex/event/session_configured",
164 "item/agentMessage/delta"
165 ]
166 }203 }
167 }204 }
168}205}
200 237
201- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.238- `thread/start` - create a new thread; emits `thread/started` and automatically subscribes you to turn/item events for that thread.
202- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.239- `thread/resume` - reopen an existing thread by id so later `turn/start` calls append to it.
203240- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread.- `thread/fork` - fork a thread into a new thread id by copying stored history; emits `thread/started` for the new thread. Returned threads include `forkedFromId` when available.
204- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history. Returned `thread` objects include runtime `status`.241- `thread/read` - read a stored thread by id without resuming it; set `includeTurns` to return full turn history. Returned `thread` objects include runtime `status`.
205242- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filters. Returned `thread` objects include runtime `status`.- `thread/list` - page through stored thread logs; supports cursor-based pagination plus `modelProviders`, `sourceKinds`, `archived`, `cwd`, and `searchTerm` filters. Returned `thread` objects include runtime `status`.
243- `thread/turns/list` - page through a stored thread's turn history without resuming it. `itemsView` controls whether turn items are omitted, summarized, or fully loaded.
244- `thread/turns/items/list` - reserved for paged turn-item loading; currently returns unsupported.
206- `thread/loaded/list` - list the thread ids currently loaded in memory.245- `thread/loaded/list` - list the thread ids currently loaded in memory.
246- `thread/name/set` - set or update a thread's user-facing name for a loaded thread or a persisted rollout; emits `thread/name/updated`.
247- `thread/goal/set` - set the goal for a loaded thread (experimental; requires `capabilities.experimentalApi`); emits `thread/goal/updated`.
248- `thread/goal/get` - read the current goal for a loaded thread (experimental; requires `capabilities.experimentalApi`).
249- `thread/goal/clear` - clear the goal for a loaded thread (experimental; requires `capabilities.experimentalApi`); emits `thread/goal/cleared`.
250- `thread/metadata/update` - patch SQLite-backed stored thread metadata; currently supports persisted `gitInfo`.
207- `thread/archive` - move a thread's log file into the archived directory; returns `{}` on success and emits `thread/archived`.251- `thread/archive` - move a thread's log file into the archived directory; returns `{}` on success and emits `thread/archived`.
252- `thread/unsubscribe` - unsubscribe this connection from thread turn/item events. If this was the last subscriber, the server unloads the thread after a no-subscriber inactivity grace period and emits `thread/closed`.
208- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread` and emits `thread/unarchived`.253- `thread/unarchive` - restore an archived thread rollout back into the active sessions directory; returns the restored `thread` and emits `thread/unarchived`.
209- `thread/status/changed` - notification emitted when a loaded thread's runtime `status` changes.254- `thread/status/changed` - notification emitted when a loaded thread's runtime `status` changes.
210- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.255- `thread/compact/start` - trigger conversation history compaction for a thread; returns `{}` immediately while progress streams via `turn/*` and `item/*` notifications.
256- `thread/shellCommand` - run a user-initiated shell command against a thread. This runs outside the sandbox with full access and doesn't inherit the thread sandbox policy.
257- `thread/backgroundTerminals/clean` - stop all running background terminals for a thread (experimental; requires `capabilities.experimentalApi`).
211- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.258- `thread/rollback` - drop the last N turns from the in-memory context and persist a rollback marker; returns the updated `thread`.
212- `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."259- `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."
260- `thread/inject_items` - append raw Responses API items to a loaded thread's model-visible history without starting a user turn.
213- `turn/steer` - append user input to the active in-flight turn for a thread; returns the accepted `turnId`.261- `turn/steer` - append user input to the active in-flight turn for a thread; returns the accepted `turnId`.
214- `turn/interrupt` - request cancellation of an in-flight turn; success is `{}` and the turn ends with `status: "interrupted"`.262- `turn/interrupt` - request cancellation of an in-flight turn; success is `{}` and the turn ends with `status: "interrupted"`.
215- `review/start` - kick off the Codex reviewer for a thread; emits `enteredReviewMode` and `exitedReviewMode` items.263- `review/start` - kick off the Codex reviewer for a thread; emits `enteredReviewMode` and `exitedReviewMode` items.
216- `command/exec` - run a single command under the server sandbox without starting a thread/turn.264- `command/exec` - run a single command under the server sandbox without starting a thread/turn.
265- `command/exec/write` - write `stdin` bytes to a running `command/exec` session or close `stdin`.
266- `command/exec/resize` - resize a running PTY-backed `command/exec` session.
267- `command/exec/terminate` - stop a running `command/exec` session.
268- `command/exec/outputDelta` (notify) - emitted for base64-encoded stdout/stderr chunks from a streaming `command/exec` session.
269- `process/spawn` - start an explicit process session outside Codex's sandbox (experimental; requires `capabilities.experimentalApi`).
270- `process/writeStdin` - write stdin bytes to a running `process/spawn` session or close stdin (experimental).
271- `process/resizePty` - resize a running PTY-backed process session (experimental).
272- `process/kill` - terminate a running process session (experimental).
273- `process/outputDelta` and `process/exited` (notify) - emitted for streaming process output and process exit status (experimental).
217- `model/list` - list available models (set `includeHidden: true` to include entries with `hidden: true`) with effort options, optional `upgrade`, and `inputModalities`.274- `model/list` - list available models (set `includeHidden: true` to include entries with `hidden: true`) with effort options, optional `upgrade`, and `inputModalities`.
275- `modelProvider/capabilities/read` - read provider capability bounds for model/provider combinations (experimental; requires `capabilities.experimentalApi`).
218- `experimentalFeature/list` - list feature flags with lifecycle stage metadata and cursor pagination.276- `experimentalFeature/list` - list feature flags with lifecycle stage metadata and cursor pagination.
277- `experimentalFeature/enablement/set` - patch in-memory runtime settings for supported feature keys such as `apps` and `plugins`.
219- `collaborationMode/list` - list collaboration mode presets (experimental, no pagination).278- `collaborationMode/list` - list collaboration mode presets (experimental, no pagination).
220- `skills/list` - list skills for one or more `cwd` values (supports `forceReload` and optional `perCwdExtraUserRoots`).279- `skills/list` - list skills for one or more `cwd` values (supports `forceReload` and optional `perCwdExtraUserRoots`).
280- `skills/changed` (notify) - emitted when watched local skill files change.
281- `marketplace/add` - add a remote plugin marketplace and persist it into the user's marketplace config.
282- `marketplace/upgrade` - refresh a configured Git marketplace, or all configured Git marketplaces when you omit the marketplace name.
283- `plugin/list` - list discovered plugin marketplaces and plugin state, including install/auth policy metadata, marketplace load errors, featured plugin ids, and local, Git, or remote plugin source metadata.
284- `plugin/read` - read one plugin by marketplace path or remote marketplace name and plugin name, including bundled skills, apps, and MCP server names when those details are available.
285- `plugin/install` - install a plugin from a marketplace path or remote marketplace name.
286- `plugin/uninstall` - uninstall an installed plugin.
221- `app/list` - list available apps (connectors) with pagination plus accessibility/enabled metadata.287- `app/list` - list available apps (connectors) with pagination plus accessibility/enabled metadata.
222- `skills/config/write` - enable or disable skills by path.288- `skills/config/write` - enable or disable skills by path.
223- `mcpServer/oauth/login` - start an OAuth login for a configured MCP server; returns an authorization URL and emits `mcpServer/oauthLogin/completed` on completion.289- `mcpServer/oauth/login` - start an OAuth login for a configured MCP server; returns an authorization URL and emits `mcpServer/oauthLogin/completed` on completion.
224- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.290- `tool/requestUserInput` - prompt the user with 1-3 short questions for a tool call (experimental); questions can set `isOther` for a free-form option.
225- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.291- `config/mcpServer/reload` - reload MCP server configuration from disk and queue a refresh for loaded threads.
226292- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination).- `mcpServerStatus/list` - list MCP servers, tools, resources, and auth status (cursor + limit pagination). Use `detail: "full"` for full data or `detail: "toolsAndAuthOnly"` to omit resources.
293- `mcpServer/resource/read` - read a single MCP resource through an initialized MCP server.
294- `mcpServer/tool/call` - call a tool on a thread's configured MCP server.
295- `mcpServer/startupStatus/updated` (notify) - emitted when a configured MCP server's startup status changes for a loaded thread.
227- `windowsSandbox/setupStart` - start Windows sandbox setup for `elevated` or `unelevated` mode; returns quickly and later emits `windowsSandbox/setupCompleted`.296- `windowsSandbox/setupStart` - start Windows sandbox setup for `elevated` or `unelevated` mode; returns quickly and later emits `windowsSandbox/setupCompleted`.
228- `feedback/upload` - submit a feedback report (classification + optional reason/logs + conversation id, plus optional `extraLogFiles` attachments).297- `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.298- `config/read` - fetch the effective configuration on disk after resolving configuration layering.
299- `externalAgentConfig/detect` - detect external-agent artifacts that can be migrated with `includeHome` and optional `cwds`; each detected item includes `cwd` (`null` for home).
300- `externalAgentConfig/import` - apply selected external-agent migration items by passing explicit `migrationItems` with `cwd` (`null` for home). Supported item types include config, skills, `AGENTS.md`, plugins, MCP server config, subagents, hooks, commands, and sessions; plugin imports emit `externalAgentConfig/import/completed`.
230- `config/value/write` - write a single configuration key/value to the user's `config.toml` on disk.301- `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.302- `config/batchWrite` - apply configuration edits atomically to the user's `config.toml` on disk.
232303- `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).
304- `fs/readFile`, `fs/writeFile`, `fs/createDirectory`, `fs/getMetadata`, `fs/readDirectory`, `fs/remove`, `fs/copy`, `fs/watch`, `fs/unwatch`, and `fs/changed` (notify) - operate on absolute filesystem paths through the app-server v2 filesystem API.
305
306Plugin summaries include a `source` union. Local plugins return
307`{ "type": "local", "path": ... }`, Git-backed marketplace entries return
308`{ "type": "git", "url": ..., "path": ..., "refName": ..., "sha": ... }`,
309and remote catalog entries return `{ "type": "remote" }`. For remote-only
310catalog entries, `PluginMarketplaceEntry.path` can be `null`; pass
311`remoteMarketplaceName` instead of `marketplacePath` when reading or installing
312those plugins.
233 313
234## Models314## Models
235 315
241{ "method": "model/list", "id": 6, "params": { "limit": 20, "includeHidden": false } }321{ "method": "model/list", "id": 6, "params": { "limit": 20, "includeHidden": false } }
242{ "id": 6, "result": {322{ "id": 6, "result": {
243 "data": [{323 "data": [{
244324 "id": "gpt-5.2-codex", "id": "gpt-5.4",
245325 "model": "gpt-5.2-codex", "model": "gpt-5.4",
246326 "upgrade": "gpt-5.3-codex", "displayName": "GPT-5.4",
247 "displayName": "GPT-5.2 Codex",
248 "hidden": false,327 "hidden": false,
249 "defaultReasoningEffort": "medium",328 "defaultReasoningEffort": "medium",
250329 "reasoningEffort": [{ "supportedReasoningEfforts": [{
251330 "effort": "low", "reasoningEffort": "low",
252 "description": "Lower latency"331 "description": "Lower latency"
253 }],332 }],
254 "inputModalities": ["text", "image"],333 "inputModalities": ["text", "image"],
261 340
262Each model entry can include:341Each model entry can include:
263 342
264343- `reasoningEffort` - supported effort options for the model.- `supportedReasoningEfforts` - supported effort options for the model.
265- `defaultReasoningEffort` - suggested default effort for clients.344- `defaultReasoningEffort` - suggested default effort for clients.
266- `upgrade` - optional recommended upgrade model id for migration prompts in clients.345- `upgrade` - optional recommended upgrade model id for migration prompts in clients.
346- `upgradeInfo` - optional upgrade metadata for migration prompts in clients.
267- `hidden` - whether the model is hidden from the default picker list.347- `hidden` - whether the model is hidden from the default picker list.
268- `inputModalities` - supported input types for the model (for example `text`, `image`).348- `inputModalities` - supported input types for the model (for example `text`, `image`).
269- `supportsPersonality` - whether the model supports personality-specific instructions such as `/personality`.349- `supportsPersonality` - whether the model supports personality-specific instructions such as `/personality`.
298## Threads378## Threads
299 379
300- `thread/read` reads a stored thread without subscribing to it; set `includeTurns` to include turns.380- `thread/read` reads a stored thread without subscribing to it; set `includeTurns` to include turns.
301381- `thread/list` supports cursor pagination plus `modelProviders`, `sourceKinds`, `archived`, and `cwd` filtering.- `thread/turns/list` pages through a stored thread's turn history without
382 resuming it. Use `itemsView` to choose whether turn items are omitted,
383 summarized, or fully loaded.
384- `thread/list` supports cursor pagination plus `modelProviders`, `sourceKinds`, `archived`, `cwd`, and `searchTerm` filtering.
302- `thread/loaded/list` returns the thread IDs currently in memory.385- `thread/loaded/list` returns the thread IDs currently in memory.
303- `thread/archive` moves the thread's persisted JSONL log into the archived directory.386- `thread/archive` moves the thread's persisted JSONL log into the archived directory.
387- `thread/metadata/update` patches stored thread metadata, currently including persisted `gitInfo`.
388- `thread/unsubscribe` unsubscribes the current connection from a loaded thread and can trigger `thread/closed` after an inactivity grace period.
304- `thread/unarchive` restores an archived thread rollout back into the active sessions directory.389- `thread/unarchive` restores an archived thread rollout back into the active sessions directory.
305- `thread/compact/start` triggers compaction and returns `{}` immediately.390- `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.391- `thread/rollback` drops the last N turns from the in-memory context and records a rollback marker in the thread's persisted JSONL log.
392- `thread/inject_items` appends raw Responses API items to a loaded thread's model-visible history without starting a user turn.
307 393
308### Start or resume a thread394### Start or resume a thread
309 395
311 397
312```json398```json
313{ "method": "thread/start", "id": 10, "params": {399{ "method": "thread/start", "id": 10, "params": {
314400 "model": "gpt-5.1-codex", "model": "gpt-5.4",
315 "cwd": "/Users/me/project",401 "cwd": "/Users/me/project",
316 "approvalPolicy": "never",402 "approvalPolicy": "never",
317 "sandbox": "workspaceWrite",403 "sandbox": "workspaceWrite",
318404 "personality": "friendly" "personality": "friendly",
405 "serviceName": "my_app_server_client"
319} }406} }
320{ "id": 10, "result": {407{ "id": 10, "result": {
321 "thread": {408 "thread": {
322 "id": "thr_123",409 "id": "thr_123",
410 "sessionId": "thr_123",
323 "preview": "",411 "preview": "",
412 "ephemeral": false,
324 "modelProvider": "openai",413 "modelProvider": "openai",
325 "createdAt": 1730910000414 "createdAt": 1730910000
326 }415 }
328{ "method": "thread/started", "params": { "thread": { "id": "thr_123" } } }417{ "method": "thread/started", "params": { "thread": { "id": "thr_123" } } }
329```418```
330 419
420`serviceName` is optional. Set it when you want app-server to tag thread-level metrics with your integration's service name.
421
422`thread.sessionId` identifies the current live session tree root. Root threads
423use their own thread id as the session id; forked threads keep the session id
424of the root they came from. Clients should read the session id from
425`thread.sessionId` instead of deriving it from the thread id.
426
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`:427To 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 428
333```json429```json
335 "threadId": "thr_123",431 "threadId": "thr_123",
336 "personality": "friendly"432 "personality": "friendly"
337} }433} }
338434{ "id": 11, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes" } } }{ "id": 11, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "ephemeral": false } } }
339```435```
340 436
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.437Resuming a thread doesn't update `thread.updatedAt` (or the rollout file's modified time) by itself. The timestamp updates when you start a turn.
346 442
347If you resume with a different model than the one recorded in the rollout, Codex emits a warning and applies a one-time model-switch instruction on the next turn.443If you resume with a different model than the one recorded in the rollout, Codex emits a warning and applies a one-time model-switch instruction on the next turn.
348 444
445### Manage a thread goal
446
447`thread/goal/set`, `thread/goal/get`, and `thread/goal/clear` are experimental
448and require `capabilities.experimentalApi = true` plus the `goals` feature. Use
449them for the same persisted goal state surfaced by `/goal` in the TUI.
450
451```json
452{ "method": "thread/goal/set", "id": 13, "params": {
453 "threadId": "thr_123",
454 "objective": "Finish the migration and keep tests green",
455 "status": "active",
456 "tokenBudget": 40000
457} }
458{ "id": 13, "result": { "goal": {
459 "threadId": "thr_123",
460 "objective": "Finish the migration and keep tests green",
461 "status": "active",
462 "tokenBudget": 40000,
463 "tokensUsed": 0,
464 "timeUsedSeconds": 0
465} } }
466{ "method": "thread/goal/updated", "params": {
467 "threadId": "thr_123",
468 "goal": {
469 "threadId": "thr_123",
470 "objective": "Finish the migration and keep tests green",
471 "status": "active",
472 "tokenBudget": 40000,
473 "tokensUsed": 0,
474 "timeUsedSeconds": 0
475 }
476} }
477```
478
479Goal objectives must be non-empty and at most 4,000 characters. Supplying a new
480objective replaces the goal and resets usage accounting. Supplying the current
481non-terminal objective, or omitting `objective`, updates status or token budget
482while preserving usage history.
483
349To branch from a stored session, call `thread/fork` with the `thread.id`. This creates a new thread id and emits a `thread/started` notification for it:484To branch from a stored session, call `thread/fork` with the `thread.id`. This creates a new thread id and emits a `thread/started` notification for it:
350 485
351```json486```json
352{ "method": "thread/fork", "id": 12, "params": { "threadId": "thr_123" } }487{ "method": "thread/fork", "id": 12, "params": { "threadId": "thr_123" } }
353488{ "id": 12, "result": { "thread": { "id": "thr_456" } } }{ "id": 12, "result": { "thread": { "id": "thr_456", "sessionId": "thr_123", "forkedFromId": "thr_123" } } }
354{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }489{ "method": "thread/started", "params": { "thread": { "id": "thr_456" } } }
355```490```
356 491
365 500
366```json501```json
367{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }502{ "method": "thread/read", "id": 19, "params": { "threadId": "thr_123", "includeTurns": true } }
368503{ "id": 19, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "status": { "type": "notLoaded" }, "turns": [] } } }{ "id": 19, "result": { "thread": { "id": "thr_123", "name": "Bug bash notes", "ephemeral": false, "status": { "type": "notLoaded" }, "turns": [] } } }
369```504```
370 505
371Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.506Unlike `thread/resume`, `thread/read` doesn't load the thread into memory or emit `thread/started`.
372 507
508### List thread turns
509
510Use `thread/turns/list` to page a stored thread's turn history without resuming it. Results default to newest-first so clients can fetch older turns with `nextCursor`. The response also includes `backwardsCursor`; pass it as `cursor` with `sortDirection: "asc"` to fetch turns newer than the first item from the earlier page.
511
512`itemsView` controls how much turn-item data the response includes:
513
514- `notLoaded` omits items.
515- `summary` returns summarized item data and is the default when omitted.
516- `full` returns full item data.
517
518```json
519{ "method": "thread/turns/list", "id": 20, "params": {
520 "threadId": "thr_123",
521 "limit": 50,
522 "sortDirection": "desc",
523 "itemsView": "summary"
524} }
525{ "id": 20, "result": {
526 "data": [],
527 "nextCursor": "older-turns-cursor-or-null",
528 "backwardsCursor": "newer-turns-cursor-or-null"
529} }
530```
531
532`thread/turns/items/list` is reserved for paged turn-item loading, but the
533current server returns an unsupported-method error.
534
373### List threads (with pagination & filters)535### List threads (with pagination & filters)
374 536
375`thread/list` lets you render a history UI. Results default to newest-first by `createdAt`. Filters apply before pagination. Pass any combination of:537`thread/list` lets you render a history UI. Results default to newest-first by `createdAt`. Filters apply before pagination. Pass any combination of:
381- `sourceKinds` - restrict results to specific thread sources. When omitted or `[]`, the server defaults to interactive sources only: `cli` and `vscode`.543- `sourceKinds` - restrict results to specific thread sources. When omitted or `[]`, the server defaults to interactive sources only: `cli` and `vscode`.
382- `archived` - when `true`, list archived threads only. When `false` or omitted, list non-archived threads (default).544- `archived` - when `true`, list archived threads only. When `false` or omitted, list non-archived threads (default).
383- `cwd` - restrict results to threads whose session current working directory exactly matches this path.545- `cwd` - restrict results to threads whose session current working directory exactly matches this path.
546- `searchTerm` - search stored thread summaries and metadata before pagination.
384 547
385`sourceKinds` accepts the following values:548`sourceKinds` accepts the following values:
386 549
405} }568} }
406{ "id": 20, "result": {569{ "id": 20, "result": {
407 "data": [570 "data": [
408571 { "id": "thr_a", "preview": "Create a TUI", "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111, "name": "TUI prototype", "status": { "type": "notLoaded" } }, { "id": "thr_a", "preview": "Create a TUI", "ephemeral": false, "modelProvider": "openai", "createdAt": 1730831111, "updatedAt": 1730831111, "name": "TUI prototype", "status": { "type": "notLoaded" } },
409572 { "id": "thr_b", "preview": "Fix tests", "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000, "status": { "type": "notLoaded" } } { "id": "thr_b", "preview": "Fix tests", "ephemeral": true, "modelProvider": "openai", "createdAt": 1730750000, "updatedAt": 1730750000, "status": { "type": "notLoaded" } }
410 ],573 ],
411 "nextCursor": "opaque-token-or-null"574 "nextCursor": "opaque-token-or-null"
412} }575} }
414 577
415When `nextCursor` is `null`, you have reached the final page.578When `nextCursor` is `null`, you have reached the final page.
416 579
580### Update stored thread metadata
581
582Use `thread/metadata/update` to patch stored thread metadata without resuming the thread. Today this supports persisted `gitInfo`; omitted fields are left unchanged, and explicit `null` clears a stored value.
583
584```json
585{ "method": "thread/metadata/update", "id": 21, "params": {
586 "threadId": "thr_123",
587 "gitInfo": { "branch": "feature/sidebar-pr" }
588} }
589{ "id": 21, "result": {
590 "thread": {
591 "id": "thr_123",
592 "gitInfo": { "sha": null, "branch": "feature/sidebar-pr", "originUrl": null }
593 }
594} }
595```
596
417### Track thread status changes597### Track thread status changes
418 598
419`thread/status/changed` is emitted whenever a loaded thread's runtime status changes. The payload includes `threadId` and the new `status`.599`thread/status/changed` is emitted whenever a loaded thread's runtime status changes. The payload includes `threadId` and the new `status`.
437{ "id": 21, "result": { "data": ["thr_123", "thr_456"] } }617{ "id": 21, "result": { "data": ["thr_123", "thr_456"] } }
438```618```
439 619
620### Unsubscribe from a loaded thread
621
622`thread/unsubscribe` removes the current connection's subscription to a thread. The response status is one of:
623
624- `unsubscribed` when the connection was subscribed and is now removed.
625- `notSubscribed` when the connection wasn't subscribed to that thread.
626- `notLoaded` when the thread isn't loaded.
627
628If this was the last subscriber, the server keeps the thread loaded until it has no subscribers and no thread activity for 30 minutes. When the grace period expires, app-server unloads the thread and emits a `thread/status/changed` transition to `notLoaded` plus `thread/closed`.
629
630```json
631{ "method": "thread/unsubscribe", "id": 22, "params": { "threadId": "thr_123" } }
632{ "id": 22, "result": { "status": "unsubscribed" } }
633```
634
635If the thread later expires:
636
637```json
638{ "method": "thread/status/changed", "params": {
639 "threadId": "thr_123",
640 "status": { "type": "notLoaded" }
641} }
642{ "method": "thread/closed", "params": { "threadId": "thr_123" } }
643```
644
440### Archive a thread645### Archive a thread
441 646
442Use `thread/archive` to move the persisted thread log (stored as a JSONL file on disk) into the archived sessions directory.647Use `thread/archive` to move the persisted thread log (stored as a JSONL file on disk) into the archived sessions directory.
470{ "id": 25, "result": {} }675{ "id": 25, "result": {} }
471```676```
472 677
678### Run a thread shell command
679
680Use `thread/shellCommand` for user-initiated shell commands that belong to a thread. The request returns immediately with `{}` while progress streams through standard `turn/*` and `item/*` notifications.
681
682This API runs outside the sandbox with full access and doesn't inherit the thread sandbox policy. Clients should expose it only for explicit user-initiated commands.
683
684If the thread already has an active turn, the command runs as an auxiliary action on that turn and its formatted output is injected into the turn's message stream. If the thread is idle, app-server starts a standalone turn for the shell command.
685
686```json
687{ "method": "thread/shellCommand", "id": 26, "params": { "threadId": "thr_b", "command": "git status --short" } }
688{ "id": 26, "result": {} }
689```
690
691### Clean background terminals
692
693Use `thread/backgroundTerminals/clean` to stop all running background terminals associated with a thread. This method is experimental and requires `capabilities.experimentalApi = true`.
694
695```json
696{ "method": "thread/backgroundTerminals/clean", "id": 27, "params": { "threadId": "thr_b" } }
697{ "id": 27, "result": {} }
698```
699
700### Roll back recent turns
701
702Use `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.
703
704```json
705{ "method": "thread/rollback", "id": 28, "params": { "threadId": "thr_b", "numTurns": 1 } }
706{ "id": 28, "result": { "thread": { "id": "thr_b", "name": "Bug bash notes", "ephemeral": false } } }
707```
708
473## Turns709## Turns
474 710
475The `input` field accepts a list of items:711The `input` field accepts a list of items:
533 "writableRoots": ["/Users/me/project"],769 "writableRoots": ["/Users/me/project"],
534 "networkAccess": true770 "networkAccess": true
535 },771 },
536772 "model": "gpt-5.1-codex", "model": "gpt-5.4",
537 "effort": "medium",773 "effort": "medium",
538 "summary": "concise",774 "summary": "concise",
539 "personality": "friendly",775 "personality": "friendly",
547{ "id": 30, "result": { "turn": { "id": "turn_456", "status": "inProgress", "items": [], "error": null } } }783{ "id": 30, "result": { "turn": { "id": "turn_456", "status": "inProgress", "items": [], "error": null } } }
548```784```
549 785
786### Inject items into a thread
787
788Use `thread/inject_items` to append prebuilt Responses API items to a loaded thread's prompt history without starting a user turn. These items are persisted to the rollout and included in subsequent model requests.
789
790```json
791{ "method": "thread/inject_items", "id": 31, "params": {
792 "threadId": "thr_123",
793 "items": [
794 {
795 "type": "message",
796 "role": "assistant",
797 "content": [{ "type": "output_text", "text": "Previously computed context." }]
798 }
799 ]
800} }
801{ "id": 31, "result": {} }
802```
803
550### Steer an active turn804### Steer an active turn
551 805
552Use `turn/steer` to append more user input to the active in-flight turn.806Use `turn/steer` to append more user input to the active in-flight turn.
655 909
656Use this notification to render the reviewer output in your client.910Use this notification to render the reviewer output in your client.
657 911
912## Process execution
913
914`process/*` is an experimental, explicit process-control API. It requires
915`capabilities.experimentalApi = true` and runs outside Codex's sandbox. Use it
916only when your client intentionally exposes local process control without a
917sandbox.
918
919Start a process with `process/spawn` and provide a `processHandle`, then use
920that handle for stdin, resize, and kill requests. Output streams through
921`process/outputDelta` notifications and completion streams through
922`process/exited`.
923
924```json
925{ "method": "process/spawn", "id": 48, "params": {
926 "command": ["python3", "-m", "pytest", "-q"],
927 "processHandle": "pytest-1",
928 "cwd": "/Users/me/project",
929 "tty": true
930} }
931{ "id": 48, "result": {} }
932{ "method": "process/outputDelta", "params": {
933 "processHandle": "pytest-1",
934 "stream": "stdout",
935 "deltaBase64": "Li4u"
936} }
937{ "method": "process/exited", "params": {
938 "processHandle": "pytest-1",
939 "exitCode": 0
940} }
941```
942
943Use `process/writeStdin` with `deltaBase64`, `closeStdin`, or both to send
944input. Use `process/resizePty` for PTY resize events and `process/kill` to
945terminate a running process.
946
658## Command execution947## Command execution
659 948
660`command/exec` runs a single command (`argv` array) under the server sandbox without creating a thread.949`command/exec` runs a single command (`argv` array) under the server sandbox without creating a thread.
676- The server rejects empty `command` arrays.965- The server rejects empty `command` arrays.
677- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).966- `sandboxPolicy` accepts the same shape used by `turn/start` (for example, `dangerFullAccess`, `readOnly`, `workspaceWrite`, `externalSandbox`).
678- When omitted, `timeoutMs` falls back to the server default.967- When omitted, `timeoutMs` falls back to the server default.
968- 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`.
969- Set `streamStdoutStderr: true` to receive `command/exec/outputDelta` notifications while the command is running.
679 970
680### Read admin requirements (`configRequirements/read`)971### Read admin requirements (`configRequirements/read`)
681 972
687 "requirements": {978 "requirements": {
688 "allowedApprovalPolicies": ["onRequest", "unlessTrusted"],979 "allowedApprovalPolicies": ["onRequest", "unlessTrusted"],
689 "allowedSandboxModes": ["readOnly", "workspaceWrite"],980 "allowedSandboxModes": ["readOnly", "workspaceWrite"],
981 "featureRequirements": {
982 "personality": true,
983 "unified_exec": false
984 },
690 "network": {985 "network": {
691 "enabled": true,986 "enabled": true,
692 "allowedDomains": ["api.openai.com"],987 "allowedDomains": ["api.openai.com"],
697} }992} }
698```993```
699 994
700995`result.requirements` is `null` when no requirements are configured. When present, the optional `network` object carries managed proxy constraints (domain rules, proxy settings, and unix-socket policy).`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.
701 996
702### Windows sandbox setup (`windowsSandbox/setupStart`)997### Windows sandbox setup (`windowsSandbox/setupStart`)
703 998
722- `elevated` - run the elevated Windows sandbox setup path.1017- `elevated` - run the elevated Windows sandbox setup path.
723- `unelevated` - run the legacy setup/preflight path.1018- `unelevated` - run the legacy setup/preflight path.
724 1019
1020## Filesystem
1021
1022The v2 filesystem APIs operate on absolute paths. Use `fs/watch` when a client needs to invalidate UI state after a file or directory changes.
1023
1024```json
1025{ "method": "fs/watch", "id": 54, "params": {
1026 "watchId": "0195ec6b-1d6f-7c2e-8c7a-56f2c4a8b9d1",
1027 "path": "/Users/me/project/.git/HEAD"
1028} }
1029{ "id": 54, "result": { "path": "/Users/me/project/.git/HEAD" } }
1030{ "method": "fs/changed", "params": {
1031 "watchId": "0195ec6b-1d6f-7c2e-8c7a-56f2c4a8b9d1",
1032 "changedPaths": ["/Users/me/project/.git/HEAD"]
1033} }
1034{ "method": "fs/unwatch", "id": 55, "params": {
1035 "watchId": "0195ec6b-1d6f-7c2e-8c7a-56f2c4a8b9d1"
1036} }
1037{ "id": 55, "result": {} }
1038```
1039
1040Watching a file emits `fs/changed` for that file path, including updates delivered by replace or rename operations.
1041
725## Events1042## Events
726 1043
7271044Event 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/status/changed`, `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.
728 1045
729### Notification opt-out1046### Notification opt-out
730 1047
732 1049
733- Exact-match only: `item/agentMessage/delta` suppresses only that method.1050- Exact-match only: `item/agentMessage/delta` suppresses only that method.
734- Unknown method names are ignored.1051- Unknown method names are ignored.
7351052- Applies to both legacy (`codex/event/*`) and v2 (`thread/*`, `turn/*`, `item/*`, etc.) notifications.- Applies to the current `thread/*`, `turn/*`, `item/*`, and related v2 notifications.
736- Doesn't apply to requests, responses, or errors.1053- Doesn't apply to requests, responses, or errors.
737 1054
738### Fuzzy file search events (experimental)1055### Fuzzy file search events (experimental)
767- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.1084- `commandExecution` - `{id, command, cwd, status, commandActions, aggregatedOutput?, exitCode?, durationMs?}`.
768- `fileChange` - `{id, changes, status}` describing proposed edits; `changes` list `{path, kind, diff}`.1085- `fileChange` - `{id, changes, status}` describing proposed edits; `changes` list `{path, kind, diff}`.
769- `mcpToolCall` - `{id, server, tool, status, arguments, result?, error?}`.1086- `mcpToolCall` - `{id, server, tool, status, arguments, result?, error?}`.
1087- `dynamicToolCall` - `{id, tool, arguments, status, contentItems?, success?, durationMs?}` for client-executed dynamic tool invocations.
770- `collabToolCall` - `{id, tool, status, senderThreadId, receiverThreadId?, newThreadId?, prompt?, agentStatus?}`.1088- `collabToolCall` - `{id, tool, status, senderThreadId, receiverThreadId?, newThreadId?, prompt?, agentStatus?}`.
771- `webSearch` - `{id, query, action?}` for web search requests issued by the agent.1089- `webSearch` - `{id, query, action?}` for web search requests issued by the agent.
772- `imageView` - `{id, path}` emitted when the agent invokes the image viewer tool.1090- `imageView` - `{id, path}` emitted when the agent invokes the image viewer tool.
791- `item/reasoning/summaryPartAdded` - marks a boundary between reasoning summary sections.1109- `item/reasoning/summaryPartAdded` - marks a boundary between reasoning summary sections.
792- `item/reasoning/textDelta` - streams raw reasoning text (when supported by the model).1110- `item/reasoning/textDelta` - streams raw reasoning text (when supported by the model).
793- `item/commandExecution/outputDelta` - streams stdout/stderr for a command; append deltas in order.1111- `item/commandExecution/outputDelta` - streams stdout/stderr for a command; append deltas in order.
7941112- `item/fileChange/outputDelta` - contains the tool call response of the underlying `apply_patch` tool call.- `item/fileChange/outputDelta` - deprecated compatibility notification for legacy `apply_patch` text output. Current app-server versions no longer emit it; use `fileChange` items and `turn/diff/updated` instead.
795 1113
796## Errors1114## Errors
797 1115
823Order of messages:1142Order of messages:
824 1143
8251. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.11441. `item/started` shows the pending `commandExecution` item with `command`, `cwd`, and other fields.
82611452. `item/commandExecution/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, optional `command`, optional `cwd`, optional `commandActions`, optional `proposedExecpolicyAmendment`, and optional `networkApprovalContext`.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.
8273. Client responds with one of the command execution approval decisions above.11463. Client responds with one of the command execution approval decisions above.
82811474. `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.
11485. `item/completed` returns the final `commandExecution` item with `status: completed | failed | declined`.
829 1149
830When `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.1150When `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.
831 1151
8321152Codex deduplicates 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.Codex 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.
833 1153
834### File change approvals1154### File change approvals
835 1155
8381. `item/started` emits a `fileChange` item with proposed `changes` and `status: "inProgress"`.11581. `item/started` emits a `fileChange` item with proposed `changes` and `status: "inProgress"`.
8392. `item/fileChange/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, and optional `grantRoot`.11592. `item/fileChange/requestApproval` includes `itemId`, `threadId`, `turnId`, optional `reason`, and optional `grantRoot`.
8403. Client responds with one of the file change approval decisions above.11603. Client responds with one of the file change approval decisions above.
84111614. `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.
11625. `item/completed` returns the final `fileChange` item with `status: completed | failed | declined`.
1163
1164### `tool/requestUserInput`
1165
1166When 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.
1167
1168### Dynamic tool calls (experimental)
1169
1170`dynamicTools` on `thread/start` and the corresponding `item/tool/call` request or response flow are experimental APIs.
1171
1172Dynamic tool names and namespace names must follow Responses API naming
1173constraints. Avoid reserved namespace names used by built-in Codex tools.
1174
1175When a dynamic tool is invoked during a turn, app-server emits:
1176
11771. `item/started` with `item.type = "dynamicToolCall"`, `status = "inProgress"`, plus `tool` and `arguments`.
11782. `item/tool/call` as a server request to the client.
11793. The client response payload with returned content items.
11804. `item/completed` with `item.type = "dynamicToolCall"`, the final `status`, and any returned `contentItems` or `success` value.
842 1181
843### MCP tool-call approvals (apps)1182### MCP tool-call approvals (apps)
844 1183
924} }1263} }
925```1264```
926 1265
1266The server also emits `skills/changed` notifications when watched local skill files change. Treat this as an invalidation signal and rerun `skills/list` with your current params when needed.
1267
927To enable or disable a skill by path:1268To enable or disable a skill by path:
928 1269
929```json1270```json
1088}1429}
1089```1430```
1090 1431
1432### Detect and import external agent config
1433
1434Use `externalAgentConfig/detect` to discover external-agent artifacts that can be migrated, then pass the selected entries to `externalAgentConfig/import`.
1435
1436Detection example:
1437
1438```json
1439{ "method": "externalAgentConfig/detect", "id": 63, "params": {
1440 "includeHome": true,
1441 "cwds": ["/Users/me/project"]
1442} }
1443{ "id": 63, "result": {
1444 "items": [
1445 {
1446 "itemType": "AGENTS_MD",
1447 "description": "Import /Users/me/project/CLAUDE.md to /Users/me/project/AGENTS.md.",
1448 "cwd": "/Users/me/project"
1449 },
1450 {
1451 "itemType": "SKILLS",
1452 "description": "Copy skill folders from /Users/me/.claude/skills to /Users/me/.agents/skills.",
1453 "cwd": null
1454 }
1455 ]
1456} }
1457```
1458
1459Import example:
1460
1461```json
1462{ "method": "externalAgentConfig/import", "id": 64, "params": {
1463 "migrationItems": [
1464 {
1465 "itemType": "AGENTS_MD",
1466 "description": "Import /Users/me/project/CLAUDE.md to /Users/me/project/AGENTS.md.",
1467 "cwd": "/Users/me/project"
1468 }
1469 ]
1470} }
1471{ "id": 64, "result": {} }
1472```
1473
1474When a request includes plugin imports, the server emits `externalAgentConfig/import/completed` after the import finishes. This notification may arrive immediately after the response or after background remote imports complete.
1475
1476Supported `itemType` values are `AGENTS_MD`, `CONFIG`, `SKILLS`, `PLUGINS`,
1477and `MCP_SERVER_CONFIG`. For `PLUGINS` items, `details.plugins` lists each
1478`marketplaceName` and the `pluginNames` Codex can try to migrate. Detection
1479returns only items that still have work to do. For example, Codex skips AGENTS
1480migration when `AGENTS.md` already exists and is non-empty, and skill imports
1481don't overwrite existing skill directories.
1482
1483When detecting plugins from `.claude/settings.json`, Codex reads configured
1484marketplace sources from `extraKnownMarketplaces`. If `enabledPlugins` contains
1485plugins from `claude-plugins-official` but the marketplace source is missing,
1486Codex infers `anthropics/claude-plugins-official` as the source.
1487
1091## Auth endpoints1488## Auth endpoints
1092 1489
10931490The 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.The 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, inspect ChatGPT rate limits, and notify workspace owners about depleted credits or usage limits.
1094 1491
1095### Authentication modes1492### Authentication modes
1096 1493
10971494Codex supports three authentication modes. `account/updated.authMode` shows the active mode, and `account/read` also reports it.Codex supports these authentication modes. `account/updated.authMode` shows the active mode and includes the current ChatGPT `planType` when available. `account/read` also reports account and plan details.
1098 1495
10991496- **API key (`apikey`)** - the caller supplies an OpenAI API key and Codex stores it for API requests.- **API key (`apikey`)** - the caller supplies an OpenAI API key with `type: "apiKey"`, and Codex stores it for API requests.
11001497- **ChatGPT managed (`chatgpt`)** - Codex owns the ChatGPT OAuth flow, persists tokens, and refreshes them automatically.- **ChatGPT managed (`chatgpt`)** - Codex owns the ChatGPT OAuth flow, persists tokens, and refreshes them automatically. Start with `type: "chatgpt"` for the browser flow or `type: "chatgptDeviceCode"` for the device-code flow.
11011498- **ChatGPT external tokens (`chatgptAuthTokens`)** - a host app supplies `idToken` and `accessToken` directly. Codex stores these tokens in memory, and the host app must refresh them when asked.- **ChatGPT external tokens (`chatgptAuthTokens`)** - experimental and intended for host apps that already own the user's ChatGPT auth lifecycle. The host app supplies an `accessToken`, `chatgptAccountId`, and optional `chatgptPlanType` directly, and must refresh the token when asked.
1102 1499
1103### API overview1500### API overview
1104 1501
1105- `account/read` - fetch current account info; optionally refresh tokens.1502- `account/read` - fetch current account info; optionally refresh tokens.
11061503- `account/login/start` - begin login (`apiKey`, `chatgpt`, or `chatgptAuthTokens`).- `account/login/start` - begin login (`apiKey`, `chatgpt`, `chatgptDeviceCode`, or experimental `chatgptAuthTokens`).
1107- `account/login/completed` (notify) - emitted when a login attempt finishes (success or error).1504- `account/login/completed` (notify) - emitted when a login attempt finishes (success or error).
11081505- `account/login/cancel` - cancel a pending ChatGPT login by `loginId`.- `account/login/cancel` - cancel a pending managed ChatGPT login by `loginId`.
1109- `account/logout` - sign out; triggers `account/updated`.1506- `account/logout` - sign out; triggers `account/updated`.
11101507- `account/updated` (notify) - emitted whenever auth mode changes (`authMode`: `apikey`, `chatgpt`, `chatgptAuthTokens`, or `null`).- `account/updated` (notify) - emitted whenever auth mode changes (`authMode`: `apikey`, `chatgpt`, `chatgptAuthTokens`, or `null`) and includes `planType` when available.
1111- `account/chatgptAuthTokens/refresh` (server request) - request fresh externally managed ChatGPT tokens after an authorization error.1508- `account/chatgptAuthTokens/refresh` (server request) - request fresh externally managed ChatGPT tokens after an authorization error.
1112- `account/rateLimits/read` - fetch ChatGPT rate limits.1509- `account/rateLimits/read` - fetch ChatGPT rate limits.
1113- `account/rateLimits/updated` (notify) - emitted whenever a user's ChatGPT rate limits change.1510- `account/rateLimits/updated` (notify) - emitted whenever a user's ChatGPT rate limits change.
1511- `account/sendAddCreditsNudgeEmail` - ask ChatGPT to email a workspace owner about depleted credits or a reached usage limit.
1114- `mcpServer/oauthLogin/completed` (notify) - emitted after a `mcpServer/oauth/login` flow finishes; payload includes `{ name, success, error? }`.1512- `mcpServer/oauthLogin/completed` (notify) - emitted after a `mcpServer/oauth/login` flow finishes; payload includes `{ name, success, error? }`.
1513- `mcpServer/startupStatus/updated` (notify) - emitted when a configured MCP server's startup status changes for a loaded thread; payload includes `{ name, status, error }`.
1115 1514
1116### 1) Check auth state1515### 1) Check auth state
1117 1516
1183 ```1584 ```
1184 1585
1185 ```json1586 ```json
11861587 { "method": "account/updated", "params": { "authMode": "apikey" } } {
1588 "method": "account/updated",
1589 "params": { "authMode": "apikey", "planType": null }
1590 }
1187 ```1591 ```
1188 1592
1189### 3) Log in with ChatGPT (browser flow)1593### 3) Log in with ChatGPT (browser flow)
1215 ```1620 ```
1216 1621
1217 ```json1622 ```json
12181623 { "method": "account/updated", "params": { "authMode": "chatgpt" } } {
1624 "method": "account/updated",
1625 "params": { "authMode": "chatgpt", "planType": "plus" }
1626 }
1627 ```
1628
1629### 3b) Log in with ChatGPT (device-code flow)
1630
1631Use this flow when your client owns the sign-in ceremony or when a browser callback is brittle.
1632
16331. Start:
1634
1635 ```json
1636 {
1637 "method": "account/login/start",
1638 "id": 4,
1639 "params": { "type": "chatgptDeviceCode" }
1640 }
1641 ```
1642
1643 ```json
1644 {
1645 "id": 4,
1646 "result": {
1647 "type": "chatgptDeviceCode",
1648 "loginId": "<uuid>",
1649 "verificationUrl": "https://auth.openai.com/codex/device",
1650 "userCode": "ABCD-1234"
1651 }
1652 }
1653 ```
1654
16552. Show `verificationUrl` and `userCode` to the user; the frontend owns the UX.
16563. Wait for notifications:
1657
1658 ```json
1659 {
1660 "method": "account/login/completed",
1661 "params": { "loginId": "<uuid>", "success": true, "error": null }
1662 }
1663 ```
1664
1665 ```json
1666 {
1667 "method": "account/updated",
1668 "params": { "authMode": "chatgpt", "planType": "plus" }
1669 }
1219 ```1670 ```
1220 1671
12211672### 3b) Log in with externally managed ChatGPT tokens (`chatgptAuthTokens`)### 3c) Log in with externally managed ChatGPT tokens (`chatgptAuthTokens`)
1222 1673
12231674Use this mode when a host application owns the user’s ChatGPT auth lifecycle and supplies tokens directly.Use this experimental mode only when a host application owns the user's ChatGPT auth lifecycle and supplies tokens directly. Clients must set `capabilities.experimentalApi = true` during `initialize` before using this login type.
1224 1675
12251. Send:16761. Send:
1226 1677
1230 "id": 7,1681 "id": 7,
1231 "params": {1682 "params": {
1232 "type": "chatgptAuthTokens",1683 "type": "chatgptAuthTokens",
12331684 "idToken": "<jwt>", "accessToken": "<jwt>",
12341685 "accessToken": "<jwt>" "chatgptAccountId": "org-123",
1686 "chatgptPlanType": "business"
1235 }1687 }
1236 }1688 }
1237 ```1689 ```
1252 ```json1706 ```json
1253 {1707 {
1254 "method": "account/updated",1708 "method": "account/updated",
12551709 "params": { "authMode": "chatgptAuthTokens" } "params": { "authMode": "chatgptAuthTokens", "planType": "business" }
1256 }1710 }
1257 ```1711 ```
1258 1712
1264 "id": 8,1718 "id": 8,
1265 "params": { "reason": "unauthorized", "previousAccountId": "org-123" }1719 "params": { "reason": "unauthorized", "previousAccountId": "org-123" }
1266}1720}
12671721{ "id": 8, "result": { "idToken": "<jwt>", "accessToken": "<jwt>" } }{ "id": 8, "result": { "accessToken": "<jwt>", "chatgptAccountId": "org-123", "chatgptPlanType": "business" } }
1268```1722```
1269 1723
1270The server retries the original request after a successful refresh response. Requests time out after about 10 seconds.1724The server retries the original request after a successful refresh response. Requests time out after about 10 seconds.
1281```json1735```json
1282{ "method": "account/logout", "id": 5 }1736{ "method": "account/logout", "id": 5 }
1283{ "id": 5, "result": {} }1737{ "id": 5, "result": {} }
12841738{ "method": "account/updated", "params": { "authMode": null } }{ "method": "account/updated", "params": { "authMode": null, "planType": null } }
1285```1739```
1286 1740
1287### 6) Rate limits (ChatGPT)1741### 6) Rate limits (ChatGPT)
1293 "limitId": "codex",1747 "limitId": "codex",
1294 "limitName": null,1748 "limitName": null,
1295 "primary": { "usedPercent": 25, "windowDurationMins": 15, "resetsAt": 1730947200 },1749 "primary": { "usedPercent": 25, "windowDurationMins": 15, "resetsAt": 1730947200 },
12961750 "secondary": null "secondary": null,
1751 "rateLimitReachedType": null
1297 },1752 },
1298 "rateLimitsByLimitId": {1753 "rateLimitsByLimitId": {
1299 "codex": {1754 "codex": {
1300 "limitId": "codex",1755 "limitId": "codex",
1301 "limitName": null,1756 "limitName": null,
1302 "primary": { "usedPercent": 25, "windowDurationMins": 15, "resetsAt": 1730947200 },1757 "primary": { "usedPercent": 25, "windowDurationMins": 15, "resetsAt": 1730947200 },
13031758 "secondary": null "secondary": null,
1759 "rateLimitReachedType": null
1304 },1760 },
1305 "codex_other": {1761 "codex_other": {
1306 "limitId": "codex_other",1762 "limitId": "codex_other",
1307 "limitName": "codex_other",1763 "limitName": "codex_other",
1308 "primary": { "usedPercent": 42, "windowDurationMins": 60, "resetsAt": 1730950800 },1764 "primary": { "usedPercent": 42, "windowDurationMins": 60, "resetsAt": 1730950800 },
13091765 "secondary": null "secondary": null,
1766 "rateLimitReachedType": null
1310 }1767 }
1311 }1768 }
1312} }1769} }
1327- `usedPercent` is current usage within the quota window.1784- `usedPercent` is current usage within the quota window.
1328- `windowDurationMins` is the quota window length.1785- `windowDurationMins` is the quota window length.
1329- `resetsAt` is a Unix timestamp (seconds) for the next reset.1786- `resetsAt` is a Unix timestamp (seconds) for the next reset.
1787- `planType` is included when the server returns the ChatGPT plan associated with a bucket.
1788- `credits` is included when the server returns remaining workspace credit details.
1789- `rateLimitReachedType` identifies the server-classified limit state when one has been reached.
1790
1791### 7) Notify a workspace owner about a limit
1792
1793Use `account/sendAddCreditsNudgeEmail` to ask ChatGPT to email a workspace owner when credits are depleted or a usage limit has been reached.
1794
1795```json
1796{ "method": "account/sendAddCreditsNudgeEmail", "id": 7, "params": { "creditType": "credits" } }
1797{ "id": 7, "result": { "status": "sent" } }
1798```
1799
1800Use `creditType: "credits"` when workspace credits are depleted, or `creditType: "usage_limit"` when the workspace usage limit has been reached. If the owner was already notified recently, the response status is `cooldown_active`.