Requirements
Network inspection must be enabled for the device’s hosting pool. Contact Mobilerun support at contact@mobilerun.ai if you need access.
true. The capability is granted when a device is placed in an enabled pool. Disabling inspection for that pool also prevents new sessions and stops active sessions.
Endpoints
Use your Mobilerun API key for the REST endpoints. The WebSocket uses the session-scoped viewer token returned in
stream.token; always connect to the returned stream.url instead of constructing it yourself.
Start an inspection session
Create a session with a uniqueIdempotency-Key so retrying the same request does not start another session:
expiresInSeconds can be 60–14400 seconds and defaults to 3600. maxBodyBytes can be 0–10485760 bytes and defaults to 1048576. Set it to 0 to receive request and response metadata without body content.
Only one session can be starting, active, or stopping for a device at a time. Starting another returns 409 TRAFFIC_ALREADY_ACTIVE.
Wait until the session is active
Starting inspection is asynchronous. Poll the status endpoint until the device producer is ready:starting or active. The token is restricted to this owner, device, and session. Use it only for the returned stream URL; do not substitute your Mobilerun API key.
Stream events with websocat
Open the returned WebSocket URL with the viewer token and required subprotocol:hello; subsequent event types are:
Request and response bodies appear as
request_body_base64 and response_body_base64. WebSocket payloads appear as payload_base64. Headers remain arrays of name-value pairs so repeated headers are preserved.
For example, decode response bodies with jq:
Stop the session
Stop inspection when you are finished so the device can restore its normal routing and temporary trust changes:202 Accepted while cleanup runs. Repeating it is safe. Sessions also stop automatically when they expire.
Troubleshooting
TRAFFIC_NOT_SUPPORTED— The device image does not support network inspection.TRAFFIC_NOT_ENTITLED—capabilities.trafficInspectionisfalse; create a device in an enabled pool or contact support.TRAFFIC_ALREADY_ACTIVE— Another session is starting, active, or stopping. Use the session ID indetails.sessionId, or list sessions withGET /devices/{deviceId}/traffic/sessions.TRAFFIC_DEVICE_NOT_READY— Wait until the device reaches thereadystate and retry with the same idempotency key.401 Unauthorizedon the WebSocket — Use a fresh.stream.tokenfrom the session status response, not the Mobilerun API key.- WebSocket subprotocol error — Send
Sec-WebSocket-Protocol: mobilerun.traffic.v1in addition to the viewer token. - The viewer token expired or the socket closed with
1013— Read the session status again to mint a fresh token, then reconnect. Missed events are not replayed.