Hi.
I’m trying to use the API to run the “ls” command from within a live instance. I followed the API documentation and put together the following command:
This endpoint expects you to first open a websocket and then communicate using the struct mentioned in the documentation.
Here is an example:
$ websocat wss://app.koyeb.com/v1/streams/instances/exec -H="Sec-WebSocket-Protocol: Bearer, my-bearer-token" # Once you enter this, the websocket is opened and you can input the next line
{"id":"my-instance-id","body":{"command":["/bin/ls"]}}
{"data":"G1swOzBtbmV4dC5jb25maWcuanMbW20gIBtbMTszNG1ub2RlX21vZHVsZXMbW20gICAgG1swOzBtcGFja2FnZS5qc29uG1ttICAgIBtbMTszNG1wdWJsaWMbW20NCg=="},"stderr":null,"exited":false,"exit_code":0}}
# ^ This is the response you get
The API documentation was quite unclear -openAPI does not seem like a good fit for websocket documentation. I’ve added some specifics to the endpoint description in order to make it clearer: Koyeb API reference - Koyeb.
$ koyeb instances list
ID SERVICE STATUS REGION DATACENTER CREATED AT
132a4486 xxx/fra HEALTHY fra fra1 06 Oct 22 16:18 UTC
(...)
$ koyeb instances exec 132a4486 ls
next.config.js node_modules package.json public