---
title: "Execute a command against the target. The command kind is determined by the target type; currently supports MySQL targets only (`command` carries the SQL)."
method: POST
path: "/workspaces/{workspace_domain}/targets/{id}/execs"
tags: ["Target API"]
---

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

`POST /workspaces/{workspace_domain}/targets/{id}/execs`

## Path parameters

- `workspace_domain` string, required
- `id` string, required

## Request body

- TargetExecRequest
  - `command` string — 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 `200`

Execution accepted and started; row carries `status: RUNNING` until poll endpoints flip to terminal

- TargetExecView
  - `url` string — API endpoint to GET this object
  - `html_url` string — Web URL to view this object in Buddy.works
  - `execution_id` string — The ID of the execution
  - `target_id` string — The ID of the target
  - `target_type` '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' — The type of the target
  - `invoker` MemberView — User/member reference
    - `url` string — API endpoint to GET this object
    - `html_url` string — Web URL to view this object in Buddy.works
    - `id` integer — The ID of the user
    - `name` string — The name of the user
    - `avatar_url` string — The avatar URL of the user
    - `email` string — The email address of the user
    - `admin` boolean — Whether the user has admin privileges
    - `workspace_owner` boolean — Whether the user is workspace owner
  - `cancelled_by` MemberView — User/member reference
    - `url` string — API endpoint to GET this object
    - `html_url` string — Web URL to view this object in Buddy.works
    - `id` integer — The ID of the user
    - `name` string — The name of the user
    - `avatar_url` string — The avatar URL of the user
    - `email` string — The email address of the user
    - `admin` boolean — Whether the user has admin privileges
    - `workspace_owner` boolean — Whether the user is workspace owner
  - `proxy_target_id` string — The ID of the proxy target used to tunnel the connection
  - `command` string — The executed command
  - `started_at` string, date-time — The date and time when the execution started
  - `finished_at` string, date-time — The date and time when the execution finished
  - `status` string — The status of the execution. One of: INPROGRESS, SUCCESSFUL, FAILED, CANCELLED
  - `failure_reason` string — 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_code` integer — The exit code of the executed command
  - `bytes_out` integer — The size of the execution output in bytes
  - `truncated` boolean — Indicates if the execution output was truncated
  - `error_message` string — The error message if the execution failed
  - `log_url` string — The URL to fetch the execution log

## Other responses

- `400` — Validation failed (e.g. target type does not support execution)
- `404` — Target not found
- `409` — Another execution against the same target by the same user is currently running

## Changes

> 8 revisions in range; 2 could not be searched.

- **2026-07-31** `bf56ba86dd4d` — 1 info
  - added the optional property `failure_reason` to the response with the `200` status

[Change history](https://skmtc.dev/buddy/apis/buddy-api/changes/workspaces/:workspace_domain/targets/:id/execs/post.md)

---

[API](https://skmtc.dev/buddy/apis/buddy-api.md) · [All operations](https://skmtc.dev/buddy/apis/buddy-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/buddy/buddy-api/revisions/fa785a68f09d/schema)
