Execute command

  • POST
  • /workspaces
  • /:workspace
  • /targets
  • /:target_id
  • /execs

Execute a command against the target. The command kind is determined by the target type; currently supports MySQL targets only (command carries the SQL).

Request

REQUIRED SCOPES
TARGET_USE
URL PARAMETERS
workspacerequiredstring
The human-readable ID of the workspace

Example: "my-company"

target_idrequiredstring
Target unique identifier (hash ID)

Example: "tgt-1234567890abcdef"

BODY PARAMETERS
commandstring
The command to execute against the target. The command kind is determined by the target type; for MySQL targets this is the SQL to run.

Response

RESPONSE BODY
urlread-onlystring
API endpoint to GET this object
html_urlread-onlystring
Web URL to view this object in Buddy.works
execution_idstring
The ID of the execution
target_idstring
The ID of the target
target_typestring enum
The type of the target
Allowed enum:
FTP,
SSH,
MATCH,
MATCH_ID,
VULTR,
DIGITAL_OCEAN,
UPCLOUD,
GIT,
ARTIFACT_VERSION,
GKE,
EKS,
AKS,
DOKS,
K8S_CLUSTER,
EC2,
AGENT,
SANDBOX,
MYSQL,
PROJECT_REPO,
POSTGRESQL,
MONGO,
MSSQL,
RDS_MSSQL
invokerMemberView
User/member reference
cancelled_byMemberView
User/member reference
proxy_target_idstring
The ID of the proxy target used to tunnel the connection
commandstring
The executed command
started_atstring
The date and time when the execution started
finished_atstring
The date and time when the execution finished
statusstring
The status of the execution. One of: INPROGRESS, SUCCESSFUL, FAILED, CANCELLED
failure_reasonstring
Platform-level reason a FAILED execution failed (absent for an ordinary non-zero exit): TIMEOUT (hard time cap reached), SPAWN_FAILED (execution could not be started), BASTION_FAILED (SSH bastion tunnel failed)
exit_codeinteger
The exit code of the executed command
bytes_outinteger
The size of the execution output in bytes
truncatedboolean
Indicates if the execution output was truncated
error_messagestring
The error message if the execution failed
log_urlstring
The URL to fetch the execution log

Last modified on Aug 13, 2026

Examples

Example: MySQL execution request

curl -X POST "https://api.buddy.works/workspaces/:workspace/targets/:target_id/execs" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "command": "SELECT 1 AS ok, NOW() AS ts" }'

Example: SSH execution request

curl -X POST "https://api.buddy.works/workspaces/:workspace/targets/:target_id/execs" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "command": "uptime" }'
EXAMPLE RESPONSE
{ "url": "https://api.buddy.works/workspaces/my-workspace/targets/execs/9214386e-7633-4d2b-ac66-fcfbaf5ea99b", "log_url": "https://api.buddy.works/workspaces/my-workspace/targets/execs/9214386e-7633-4d2b-ac66-fcfbaf5ea99b/log", "execution_id": "9214386e-7633-4d2b-ac66-fcfbaf5ea99b", "target_id": "tg-b185vd3ct4chv", "target_type": "MYSQL", "invoker": { "url": "https://api.buddy.works/workspaces/my-workspace/members/1", "id": 1, "name": "John Doe" }, "command": "mysql sql=SELECT 1 AS ok, NOW() AS ts", "started_at": "2026-05-28T08:00:09.820Z", "status": "INPROGRESS" }
STATUS
200 Execution accepted and started; row carries `status: RUNNING` until poll endpoints flip to terminal