Why JSON-RPC 2.0 over SSE
Traditional REST APIs expect an immediate response, which does not fit a workflow where a law firm may spend hours reviewing a contract. Lexera solves this with Server-Sent Events (SSE): a persistent HTTP connection that the server uses to push status updates, results, and errors back to your system. JSON-RPC 2.0 provides a lightweight, structured message format for invoking tools and correlating responses.JSON-RPC 2.0 message format
Every tool call is a JSON-RPC 2.0 request. The envelope is predictable and easy to generate from any language.Server-Sent Events transport
Lexera streams three kinds of information over SSE:- Session initialization — After you open the stream, the server sends an
event: endpointcontaining your unique session URL. You must extract this URL to dispatch any RPC. - Execution results — Once you POST a tool call, the eventual result (for example,
DISPATCH_SUCCESSor a completed order payload) arrives as a later SSE message on the same connection. - Errors — Validation failures, wallet issues, and authentication problems are also streamed as JSON-RPC error payloads over SSE.
The event: endpoint handshake
Immediately after opening the SSE stream, the server pushes a session assignment. The event looks like this:
data line, prepend https://lexera.dev, and use the resulting URL for every subsequent JSON-RPC POST. Without this step, the server cannot correlate your tool calls with your open stream.
All SSE traffic, including the initial session assignment, requires a valid Bearer token. See Authentication for how to obtain and pass your API key.
Next steps
- Learn the exact three-step flow in Execution Lifecycle
- See the full list of available MCP tools in Tools Overview