---
title: "Run ad-hoc command on sprouts"
method: POST
path: "/api/v1/cmd"
tags: ["cmd"]
---

# Run ad-hoc command on sprouts

`POST /api/v1/cmd`

Execute a command on one or more targeted sprouts.
The request body is a `TargetedAction` with a `CmdRun` action
payload containing the command, arguments, working directory,
optional runas user, environment variables, and timeout.

## Request body

- TargetedAction — A targeted action request containing a list of sprout targets and an action payload. Used by cook, cmd.run, and test.ping endpoints.
  - `target` object[], required — List of sprouts to target
    - `id` string, required — Sprout identifier
  - `action` unknown, required

## Response `200`

Command results per sprout

- NATSEnvelope — Standard NATS proxy response envelope. On success, `result` contains the response data. On error, `error` contains a message string.
  - `result` unknown
  - `error` string — Error message (present only on failure)

## Other responses

- `400` — Invalid request body
- `502` — NATS communication error — farmer unreachable or returned an error

## Changes

- **2026-03-21** `011f9b67b17a` — 3 breaking, 1 warning, 2 info
  - added the new required request property `target/items/id`
  - the `action` request property type/format changed from `object`/`` to ``/``
  - the response's body type/format changed from ``/`` to `object`/`` for status `200`
  - removed the request property `target/items/sprout_id`
  - …2 more
- **2026-03-20** `bdf58e0441c6` — 1 info
  - endpoint added
- **2026-03-15** `1aab0676c2b4` — 1 breaking
  - api path removed without deprecation
- **2026-03-13** `26871a2f667f` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/gogrlx/apis/grlx-cli-api/changes/api/v1/cmd/post.md)

---

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