Skip to main content
Every interaction with the Lexera Protocol follows the same asynchronous lifecycle. You open a persistent Server-Sent Events connection, the server assigns you a session, you POST a JSON-RPC tool call, and the result streams back over the same connection. This design keeps your agent or enterprise system responsive while human attorneys perform verification.
1

Initialize the SSE stream

Open a persistent GET request to the MCP server endpoint. Include your Bearer token in the Authorization header. The connection stays open for the duration of the session.
2

Receive the session ID

The server streams an event: endpoint message containing your unique session URL. Parse the data line to extract the path and prepend the base URL.
Your session URL becomes:
3

Dispatch the JSON-RPC call

POST your JSON-RPC 2.0 payload to the session URL. The server immediately returns HTTP 202 Accepted. The actual result, such as a DISPATCH_SUCCESS payload or a completed order, arrives later as an SSE message on the open stream.

JavaScript example: opening the stream and extracting the session URL

The following example uses the native fetch API to open the SSE stream, read chunks, and extract the session URL with a regular expression.
Keep the SSE connection open until the final result arrives. Closing the stream prematurely disconnects your session and you will not receive the tool call result.

What happens after dispatch

After the POST returns 202 Accepted, the server processes the request asynchronously. For a human-in-the-loop tool such as lexera_route_to_specialist, this means:
  1. The server places a temporary AED wallet hold.
  2. The document enters the assigned law firm’s triage queue.
  3. Once the attorney completes review, the server streams the finalized payload back over your open SSE connection.
Because the result arrives as an SSE event, your integration should listen continuously after every dispatch.

Next steps