---
title: "Connect to script output stream (WebSocket)"
method: GET
path: "/v1/script-executions/output/{token}"
tags: ["Objects"]
---

# Connect to script output stream (WebSocket)

`GET /v1/script-executions/output/{token}`

WebSocket endpoint for running an ad-hoc script and receiving its output.
The token is obtained from POST /v1/objects/{object-id}/execute-script or POST /v1/execute-script with stream=true.
Token is single-use and expires after 30 seconds. Script execution starts when the connection is established.

Server sends JSON text frames:
- `{"type":"output","data":"..."}` - output chunk
- `{"type":"result","data":...}` - script return value, formatted the same way as `result` in synchronous mode (honors `resultAsMap`)
- `{"type":"completed"}` - execution finished successfully (always follows `result`)
- `{"type":"stopped"}` - execution was stopped on request
- `{"type":"error","message":"...","diagnostic":{...}}` - execution failed; `diagnostic` holds NXSL error details

Server closes the connection after `completed`, `stopped` or `error` message.

Client can send JSON text frames:
- `{"type":"stop"}` - stop script execution

Closing the connection by the client stops the script.

## Path parameters

- `token` string, uuid, required

## Other responses

- `101` — Switching protocols to WebSocket. If the token is invalid, expired or already used, the connection is closed right after the upgrade with WebSocket close code 1008 (Policy Violation) - no HTTP error status is returned in that case.
- `426` — Upgrade required - request did not ask for a protocol upgrade to WebSocket.

## Changes

- **2026-09-30** `2bd10b4f2d50` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/netxms/apis/netxms-api/changes/v1/script-executions/output/:token/get.md)

---

[API](https://skmtc.dev/netxms/apis/netxms-api.md) · [All operations](https://skmtc.dev/netxms/apis/netxms-api/llms.txt) · [OpenAPI document](https://skmtc.dev/netxms/apis/netxms-api/revisions/129789f8868f?raw)
