---
title: "Execute command"
method: POST
path: "/controlplane/agent_command"
tags: ["Agent"]
---

# Execute command

`POST /controlplane/agent_command`

Executes a command on a specific agent.

## Request body

- AgentCommandRequest
  - `command` object — Describes the command the agent will execute.
    - `type` 'exec' | 'refresh-sources' — The command type of the agent. > . `exec`: Executes a command line with optional environment variables and arguments. > > . `refresh-sources`: Refreshes the agent's sources. This command does not require additional data.
    - `data` object — The command line and environment variables.
      - `cmdline` string — The command line to be executed. > **Note**: The path to the command line should point to the folder where the agent is installed.
      - `environment` object — The environment variables for the command. > **Note**: The environment variables should be in the format `KEY: VALUE`.
      - `arguments` string[] — The arguments to be passed to the command line.
  - `selector` object — The selector for the agent.

## Response `200`

Command executed successfully.

- AgentCommandResponse
  - `selector` object — The selector for the agent.
  - `command` object — Describes the command the agent will execute.
    - `type` 'exec' — The command type of the agent.
    - `data` object — The command line and environment variables.
      - `cmdline` string — The command line to be executed. > **Note**: The path to the command line should point to the folder where the agent is installed.
      - `environment` object — The environment variables for the command. > **Note**: The environment variables should be in the format `key: value`.
      - `arguments` string[] — The arguments to be passed to the command line.

## Other responses

- `4XX` — Client error responses due to invalid input or missing parameters.
- `5XX` — Server error responses indicating an issue on the API side.

---

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