Skip to main content

Overview

WebRun provides two ways to receive responses:

REST API Response Formats

Inline Results (< 50 seconds)

Both /run-task and /send-message wait up to 50 seconds for task completion. If the task finishes in time, you get the result immediately. Structure:
Response Fields:

Pending Results (> 50 seconds)

For longer tasks, the response returns immediately with a poll URL. Structure:
Response Fields:

Polling Responses

Poll GET /task/:sessionId/:taskId until pending: false or a final type is returned.

Still Running

Response Fields:

Task Completed

Response Fields:

Guardrail Triggered

Response Fields: Next Steps: Respond with guardrail message via POST /start/send-message:

Task Failed

Response Fields:

Session Creation Response

POST /start/start-session returns session details and streaming configuration.
Response Fields:

State Control Response

POST /start/send-message with actionType: "state", "interaction", or "guardrail" returns immediate confirmation.
Response Fields:

WebSocket Event Formats

Connect via Socket.IO and listen for message events:

Event: agent

Live agent thoughts and reasoning during task execution.
Fields:

Event: action

Browser action performed by the agent.
Fields:

Event: response_update

Status update during task execution.
Fields:

Event: task_completed

Task finished successfully.
Fields:

Event: guardrail_trigger

Agent needs human input to continue.
Fields: Respond with:

Event: error

Task failed with error.
Fields:

Connection Events

connect

Socket connected successfully.

disconnect

Socket disconnected.

error

Socket error occurred.

end_session

Session terminated by server.
Possible Reasons:
  • "completed" - Task completed
  • "terminated" - Manually terminated
  • "expired" - Session expired due to inactivity
  • "terminateOnCompletion" - Auto-terminated after task
  • "instance_lost" - Instance connection lost

instance:disconnected

Instance connection lost. Session enters grace period for reconnection.

instance:reconnected

Instance connection recovered.

OpenAI-Compatible Response Formats

Non-Streaming Response

POST /v1/chat/completions with stream: false (default).
Response Fields:

Streaming Response (SSE)

POST /v1/chat/completions with stream: true returns Server-Sent Events. Stream Format:
Chunk Structure: Handling Streams:

Error Response Format

All errors follow this standard format:
Common HTTP Status Codes: See Rate Limits for handling 429 errors.

Usage Object Structure

The usage object appears in many responses and provides token and cost information:
Example:

Complete Event Reference Table


Next Steps

Endpoints

Complete endpoint reference

Parameters

Parameter documentation

Events & Responses

Detailed event handling guide

WebSocket Integration

WebSocket integration guide