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

# Initialize Task

> Set up a task configuration in a VM environment

Initializes a task in the specified desktop environment. Sets up the VM with the task configuration, including running initialization scripts to prepare the environment for the task.

## Request Body

<ParamField body="vm_id" type="string" required>
  VM identifier from `/create_desktop`
</ParamField>

<ParamField body="task_config" type="object" required>
  Task configuration object containing:

  * `id` (string): Unique task identifier
  * `instruction` (string): Task instructions for the agent
  * `config` (array): Initialization configuration steps
  * `evaluator` (object): Evaluation configuration
</ParamField>

## Response

<ResponseField name="status" type="string">
  Result status (`success`)
</ResponseField>

<ResponseField name="message" type="string">
  Status message
</ResponseField>

<ResponseField name="vm_id" type="string">
  VM identifier
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "http://CONTROL_PLANE_IP:PORT/initialize_task" \
    -H "Content-Type: application/json" \
    -d '{
      "vm_id": "vm-abc123",
      "task_config": {
        "id": "task-001",
        "instruction": "Open the document and extract the sales data",
        "config": [
          {
            "type": "download",
            "parameters": {
              "url": "https://example.com/document.docx",
              "path": "/home/user/Documents/document.docx"
            }
          }
        ],
        "evaluator": {
          "type": "file_check",
          "expected": "/home/user/output.xlsx"
        }
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "status": "success",
    "message": "Task initialized successfully",
    "vm_id": "vm-abc123"
  }
  ```

  ```json Error Response theme={null}
  {
    "error": "Desktop environment not found for VM: vm-abc123. Call /create_desktop first."
  }
  ```
</ResponseExample>
