palbaseDocs

Palbase Machines · API

POST/machines/{name}/exec

Run a command in a machine

Runs one command in a ready copy of the machine as it serves — the machine woken first if asleep — with no terminal and no input, under /bin/sh, and answers what it printed with its exit code: ending exited (exit_code is the command's), killed (it ran past 60 s and was killed), or failed (it did not run: reason says why — no /bin/sh in the image, no copy ready, the machine not woken). Every secret and platform key the machine is started with, and a password in an address, is written over with *** in stdout, stderr and the command kept; stdout and stderr together are 1 MiB at most (truncated). Who ran what, and how it ended, is kept (ListMachineExecs); the output is not. A person runs one in any environment — signed in, or with their account token; in a production environment's machine no one else does, not a key, an organization's token or an environment's (403 exec_not_in_production). 409 when the machine is bound to another environment than the one called, or moving. 429 when the project's machine time for the period is used up.

Called by your server, with the project's secret key.

Path

namestring · requiredThe machine's name: lowercase letters, digits and dashes, starting with a letter and not ending with a dash, 32 at most.

Request body

commandstring[] · requiredThe command: the program and its arguments, as exec takes them — 1 to 64 items, 4096 bytes each, 16 KiB together, no NUL. For a shell's words, sh -c: ["sh", "-c", "ls /tmp | wc -l"].
curl
curl -X POST "https://<your-ref>.palbase.studio/machines/<name>/exec" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"command":["string"]}'

Responses

200How the command ended, and what it printed

400Validation failed or a required field is missing

401Missing or invalid API key

403Not the project's secret key; or the request requires elevated owner authentication (`owner_only`, `insufficient_user_authentication`).

404The project has no machine of this name

409The project already has a machine of this name, or has as many machines as it may

429Over the project's request limit, or its machine time for this period is used up

503Temporarily unavailable; retrying is safe after Retry-After

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation ExecInMachine of machines's contract.