HTTP API

Commands

5 routes your API key can call. Each says who may call it; every example assumes KEY is your API key. What only the dashboard does (signing in, making API keys, connecting accounts) isn't listed here: it's in the full OpenAPI spec.

POST/v1/workspaces/{wid}/sandboxes/{id}/commands

Run a shell command in a running sandbox

People and API keys

Starts the command and answers 201 at once, with status running. With ?wait=N (0 to 60 seconds) it holds the request until the command ends or N seconds pass; if it ended, output carries the first 64 KiB of stdout and stderr together, and truncated says whether there is more (read it from …/output). A stopped sandbox is 409 "sandbox is stopped".

ParameterInTypeAbout
widInpathTypestringAboutWorkspace id
idInpathTypestringAbout
wait?InqueryTypeintegerAboutSeconds to wait for it to finish

Body

  • commandstringrequired

    Run by the sandbox shell, e.g. "npm test; echo done"

  • cwdstring

    Absolute; the provider's home directory when left out

  • envobject

    Names are letters, digits and _, not starting with a digit

  • timeout_secondsinteger

    Killed after this; no limit when left out

Answer · 201

  • commandCommandrequired
    • idstring
    • sandboxstring

      Id of the sandbox it runs in

    • commandstring
    • status"running" | "exited" | "timed_out" | "failed"

      failed: killed by a signal, lost, or never started

    • exit_codeinteger | null
    • started_atstring
    • ended_atstring | null
    • outputstring | null

      The first 64 KiB of output, only when ?wait= saw it end

    • truncatedboolean

      There is more output than output holds

Terminal
curl -X POST 'https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes/id/commands' \
  -H 'Authorization: Bearer anx_live_…' \
  -H 'Content-Type: application/json' \
  -d '{"command":"…"}'
GET/v1/workspaces/{wid}/sandboxes/{id}/commands/{cid}

Where a command is now, asked of the provider. output is always null here.

People and API keys

ParameterInTypeAbout
widInpathTypestringAboutWorkspace id
idInpathTypestringAbout
cidInpathTypestringAboutCommand id

Answer · 200

  • commandCommandrequired
    • idstring
    • sandboxstring

      Id of the sandbox it runs in

    • commandstring
    • status"running" | "exited" | "timed_out" | "failed"

      failed: killed by a signal, lost, or never started

    • exit_codeinteger | null
    • started_atstring
    • ended_atstring | null
    • outputstring | null

      The first 64 KiB of output, only when ?wait= saw it end

    • truncatedboolean

      There is more output than output holds

Terminal
curl -X GET 'https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes/id/commands/cid' \
  -H 'Authorization: Bearer anx_live_…'
POST/v1/workspaces/{wid}/sandboxes/{id}/commands/{cid}/cancel

Stop a running command, as Ctrl+C would

People and API keys

Sends the command and everything it started SIGINT, then SIGTERM 2 s later, then SIGKILL 2 s after that, and answers the command as it is then: usually ended, with the exit code its signal gave it (130, 143 or 137). 409 command_ended once it has ended; 409 command_unstoppable for a command started before commands could be stopped, or in a sandbox whose /tmp isn't writable.

ParameterInTypeAbout
widInpathTypestringAboutWorkspace id
idInpathTypestringAbout
cidInpathTypestringAboutCommand id

Answer · 200

  • commandCommandrequired
    • idstring
    • sandboxstring

      Id of the sandbox it runs in

    • commandstring
    • status"running" | "exited" | "timed_out" | "failed"

      failed: killed by a signal, lost, or never started

    • exit_codeinteger | null
    • started_atstring
    • ended_atstring | null
    • outputstring | null

      The first 64 KiB of output, only when ?wait= saw it end

    • truncatedboolean

      There is more output than output holds

Terminal
curl -X POST 'https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes/id/commands/cid/cancel' \
  -H 'Authorization: Bearer anx_live_…'
GET/v1/workspaces/{wid}/sandboxes/{id}/commands/{cid}/output

One page of a command's output, by cursor

People and API keys

Pages by cursor, not page number: output is a log that grows while the command runs and the provider drops its oldest lines, so there is no stable total. Start without cursor, then pass meta.next_cursor. meta.done is true once the command has ended and nothing follows; an empty page that isn't done means you have caught up with a command still running.

ParameterInTypeAbout
widInpathTypestringAboutWorkspace id
idInpathTypestringAbout
cidInpathTypestringAboutCommand id
cursor?InqueryTypestringAboutmeta.next_cursor of the page before; empty for the start
perPage?InqueryTypeintegerAboutChunks of output

Answer · 200

  • outputOutputChunk[]required
    • stream"stdout" | "stderr"
    • textstring

      A chunk as written

  • metaobjectrequired
    • next_cursorstring
    • doneboolean
    • perPageinteger
Terminal
curl -X GET 'https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes/id/commands/cid/output' \
  -H 'Authorization: Bearer anx_live_…'
GET/v1/workspaces/{wid}/sandboxes/{id}/commands/{cid}/stream

A command's output as Server-Sent Events, live

People and API keys

An "output" event per chunk of output (data is an OutputChunk; its id is a cursor), then one "exit" event whose data is the Command as it ended, and the stream closes. Reconnect with Last-Event-ID to resume after the last chunk you got. If the stream breaks after it opened, an "error" event says so. If the sandbox ended while it was open (stopped, or lost: code sandbox_lost with replaced_by and replacement_resume), one "gone" event whose data is the Error says so and the stream closes: don't reconnect. Errors before it opens (404, 409, 429, 503) are ordinary JSON. A workspace may have 8 of these open at once and a person or API key 4 (429 too_many_requests); 503 unavailable when the server is holding as many calls into sandboxes as it allows (retry shortly).

ParameterInTypeAbout
widInpathTypestringAboutWorkspace id
idInpathTypestringAbout
cidInpathTypestringAboutCommand id
Last-Event-ID?InheaderTypestringAbout

Answer · 200

event: output, data: {"stream":"stdout","text":"hi\n"} … event: exit, data: {Command}, or event: gone, data: {Error}

Terminal
curl -X GET 'https://annex.eversonder.com/v1/workspaces/wsp_…/sandboxes/id/commands/cid/stream' \
  -H 'Authorization: Bearer anx_live_…'