> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hoplynk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Command

> Dispatch a command to an asset. Returns a task that tracks execution status.

<ParamField path="kit_id" type="string" required>
  UUID of the kit.
</ParamField>

<ParamField path="asset_id" type="string" required>
  UUID of the asset.
</ParamField>

<ParamField path="command_name" type="string" required>
  Name of the command to dispatch (e.g. `arm`, `ptz_move`, `reboot`). Must match a command returned by [List Commands](/api-reference/assets/commands).
</ParamField>

## Body

<ParamField body="payload" type="object">
  Command-specific parameters. Must conform to the command's `input_schema`. Pass `{}` or omit for commands that take no parameters.
</ParamField>

## Response

Returns a **task** object. The task is immediately dispatched to the connector via MQTT and also available for polling.

<ResponseField name="id" type="string">Task UUID. Use this to poll for status.</ResponseField>
<ResponseField name="asset_id" type="string">UUID of the target asset.</ResponseField>
<ResponseField name="command_name" type="string">The command that was dispatched.</ResponseField>
<ResponseField name="payload" type="object">The payload that was sent.</ResponseField>
<ResponseField name="status" type="string">Initial status: always `pending`.</ResponseField>
<ResponseField name="requested_by" type="string">UUID of the user who issued the command.</ResponseField>
<ResponseField name="created_at" type="string">ISO 8601 UTC timestamp.</ResponseField>

## Task lifecycle

Tasks move through these statuses as the connector processes them:

| Status      | Meaning                                              |
| ----------- | ---------------------------------------------------- |
| `pending`   | Created, waiting to be picked up by the connector    |
| `running`   | Connector has started execution                      |
| `completed` | Command succeeded. Check `result` for output.        |
| `failed`    | Command failed. Check `result.error` for the reason. |

## Example

<CodeGroup>
  ```python Python theme={null}
  import time

  # Send a command
  task = client.send_command(kit_id, asset_id, "set_mode", payload={"mode": "GUIDED"})
  print(f"Task {task['id']} — status: {task['status']}")

  # Fly to a waypoint
  task = client.send_command(
      kit_id, asset_id, "goto_waypoint",
      payload={"lat": 31.1234, "lon": -93.4567, "alt_m": 50.0},
  )

  # PTZ camera move
  task = client.send_command(
      kit_id, camera_id, "ptz_move",
      payload={"direction": "left", "speed": 25},
  )

  # Commands with no payload
  client.send_command(kit_id, asset_id, "return_home")
  client.send_command(kit_id, asset_id, "disarm")
  ```

  ```javascript JavaScript theme={null}
  // Set flight mode
  const task = await client.sendCommand(kitId, assetId, 'set_mode', {
    payload: { mode: 'GUIDED' },
  })
  console.log(task.id, task.status)

  // PTZ move
  await client.sendCommand(kitId, cameraId, 'ptz_move', {
    payload: { direction: 'left', speed: 25 },
  })

  // No-payload command
  await client.sendCommand(kitId, assetId, 'return_home')
  ```

  ```bash cURL theme={null}
  # Fly to waypoint
  curl -X POST \
    "https://argus.hoplynk.com/api/kits/$KIT_ID/assets/$ASSET_ID/commands/goto_waypoint" \
    -H "X-API-Key: hlk_..." \
    -H "Content-Type: application/json" \
    -d '{"payload": {"lat": 31.1234, "lon": -93.4567, "alt_m": 50.0}}'

  # PTZ move (no payload body needed for commands with no params)
  curl -X POST \
    "https://argus.hoplynk.com/api/kits/$KIT_ID/assets/$CAMERA_ID/commands/ptz_move" \
    -H "X-API-Key: hlk_..." \
    -H "Content-Type: application/json" \
    -d '{"payload": {"direction": "left", "speed": 25}}'
  ```
</CodeGroup>

```json Response theme={null}
{
  "id": "e5f6g7h8-0000-0000-0000-000000000001",
  "asset_id": "cf210dda-fad8-4e69-ac9c-fe88f42f06a7",
  "command_name": "set_mode",
  "payload": { "mode": "GUIDED" },
  "status": "pending",
  "result": {},
  "requested_by": "a1b2c3d4-0000-0000-0000-000000000001",
  "created_at": "2026-05-18T14:30:00Z"
}
```

## Common commands by asset type

**Drone (MAVLink)**

| Command         | Payload                                                         |
| --------------- | --------------------------------------------------------------- |
| `arm`           | —                                                               |
| `disarm`        | —                                                               |
| `return_home`   | —                                                               |
| `set_mode`      | `{ "mode": "GUIDED" \| "AUTO" \| "LOITER" \| "RTL" \| "LAND" }` |
| `goto_waypoint` | `{ "lat": 31.1234, "lon": -93.4567, "alt_m": 50.0 }`            |

**Camera (Reolink)**

| Command                | Payload                                                                         |
| ---------------------- | ------------------------------------------------------------------------------- |
| `ptz_move`             | `{ "direction": "up" \| "down" \| "left" \| "right" \| "stop", "speed": 1–64 }` |
| `ptz_preset`           | `{ "preset_id": 1 }`                                                            |
| `set_motion_detection` | `{ "enabled": true }`                                                           |
| `reboot`               | —                                                                               |

**Camera (ONVIF)**

| Command      | Payload                                                                            |
| ------------ | ---------------------------------------------------------------------------------- |
| `ptz_move`   | `{ "direction": "up" \| "down" \| "left" \| "right" \| "stop", "speed": 0.0–1.0 }` |
| `ptz_preset` | `{ "preset_token": "1" }`                                                          |
