Request

Response

    WebSockets for When Callbacks Aren’t an Option

    Note: WebSockets are not supported with the Fusion engine.

    When using the Automation API directly from a client device (such as a desktop computer, mobile phone, or laptop), you cannot set up onComplete or onProgress callbacks that point back to the client device. This limitation forces applications to make repeated GET requests to check workitem progress, which is inefficient and increases energy consumption. To address this issue, the Automation API provides WebSocket endpoints that enable real-time communication.

    Setup and Connection

    The WebSocket API works with any client that can issue standard WebSocket requests. You can use it from a browser with the standard WebSocket API, from the command line using tools like wscat, or with any other WebSocket library or toolset.

    The WebSocket host is websockets.forgedesignautomation.io.

    To connect using wscat, use this command:

    wscat -c wss://websockets.forgedesignautomation.io
    

    Once connected, wscat will display:

    connected (press CTRL+C to quit)
    >
    

    Authentication

    You need a valid authentication token to make requests through the WebSocket API. Obtain your token following the same steps used for HTTP requests.

    The examples below use 2-legged tokens for simplicity. For production scenarios, use 3-legged tokens instead. Review the background information for guidance on using 3-legged tokens with the Automation API.

    Making Requests

    All WebSocket messages must be valid JSON. If you send invalid JSON, you’ll receive an error response:

    > hello
    < {"action":"error","data":"Invalid payload. Unexpected character
      encountered while parsing value: h. Path '', line 0, position 0."}
    

    To submit a workitem, send a properly formatted JSON request with your authentication token (replace <your token> with your actual bearer token):

    > { "action" : "post-workitem", "data" : { "activityId" :
      "Autodesk.Nop+Latest"}, "headers": {"Authorization": "Bearer <your
      token>"}}
    

    You’ll immediately receive a status response indicating the workitem is queued:

    < {"action":"status","data":{"status":"pending","stats":{"timeQueued":"2021-02-20T16:36:00.5367829Z"},"id":"6e13bd3b520142f6887e7333b8251e84"}}
    

    When the workitem completes, you’ll automatically receive the final result:

    {"status":"success","reportUrl":"https://dasprod-store.s3.amazonaws.com/workItem/CokbOqRvp41DVunD7lBO2ciiwJpltTAf/6e13bd3b520142f6887e7333b8251e84/report.txt?AWSAccessKeyId=...","stats":{"timeQueued":"2021-02-20T16:36:00.655Z","timeDownloadStarted":"2021-02-20T16:36:00.7227303Z","timeInstructionsStarted":"2021-02-20T16:36:01.1628287Z","timeInstructionsEnded":"2021-02-20T16:36:04.4070839Z","timeUploadEnded":"2021-02-20T16:36:04.7794786Z","bytesDownloaded":100,"bytesUploaded":100},"id":"6e13bd3b520142f6887e7333b8251e84"}
    

    Additional Resources

    For complete API details and advanced usage scenarios, see the WebSocket reference documentation.