Protocol
The App Server uses bidirectional JSON-RPC 2.0 communication with the"jsonrpc":"2.0" header omitted on the wire for efficiency.
Supported Transports
stdio
Default transport using newline-delimited JSON (JSONL)
WebSocket
Experimental transport (unsupported for production)
Core Primitives
The API exposes three top-level primitives representing interactions between a user and Codex:Thread
Thread
A conversation between a user and the Codex agent. Each thread contains multiple turns.Key Operations:
thread/start- Create a new threadthread/resume- Continue an existing threadthread/fork- Branch from an existing threadthread/list- List stored threadsthread/archive- Archive a thread
Turn
Turn
One turn of the conversation, typically starting with a user message and finishing with an agent message. Each turn contains multiple items.Key Operations:
turn/start- Send user input and begin generationturn/interrupt- Cancel an in-flight turnturn/steer- Add input to an active turn
Item
Item
Represents user inputs and agent outputs as part of a turn, persisted and used as context for future conversations.Item Types:
userMessage- User text/image inputagentMessage- Agent responsereasoning- Agent reasoning tracescommandExecution- Shell commandsfileChange- File editsmcpToolCall- MCP tool invocationswebSearch- Web search requests
Message Schema
You can generate TypeScript or JSON Schema definitions for the current version:Backpressure Behavior
The server uses bounded queues between transport ingress, request processing, and outbound writes.When request ingress is saturated, new requests are rejected with JSON-RPC error code
-32001 and message "Server overloaded; retry later."Clients should treat this as retryable and use exponential backoff with jitter.Tracing & Logging
Controls log filtering and verbosity
Set to
json to emit structured logs to stderrNext Steps
Initialization
Learn how to initialize a connection
Threads
Manage conversation threads
Turns
Start and control conversation turns
Items
Understand item types and notifications