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

# Tasks

> SDK reference for the Tasks resource (TypeScript & Python)

## Run a Task

`POST /v2/tasks/{taskId}/run` — runTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, Tasks } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await Tasks.runTask({
    path: {
      taskId: 'your-taskId'
    },
    body: {
      input_params: {}
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks.run_task(
      "your-task-id",
      input_params={},
  )
  print(result)
  ```
</CodeGroup>

## Get Task Run Status

`GET /v2/tasks/runs/{runId}/status` — getTaskRunStatus

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, Tasks } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await Tasks.getTaskRunStatus({
    path: {
      runId: 'your-runId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks.get_task_run_status(
      "your-run-id",
  )
  print(result)
  ```
</CodeGroup>

## Generate a Task

`POST /v2/tasks/generate` — generateTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, Tasks } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await Tasks.generateTask({
    body: {
      taskName: 'string',
      taskPrompt: 'string'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks.generate_task(
      task_name="string",
      task_prompt="string",
  )
  print(result)
  ```
</CodeGroup>

## Get Task Generation Status

`GET /v2/tasks/{taskId}/generation-status` — getTaskGenerationStatus

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, Tasks } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await Tasks.getTaskGenerationStatus({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks.get_task_generation_status(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

***

# Legacy task methods

The methods below call the legacy v1 task API and are exposed through the `TasksLegacy` class. Prefer the `Tasks` methods above for new integrations.

## Create Task (Legacy)

`POST /v1/task` — createTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.createTask({
    body: {
      name: 'string',
      language: 'typescript'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.create_task(
      name="string",
      language="typescript",
  )
  print(result)
  ```
</CodeGroup>

## List Tasks (Legacy)

`GET /v1/task` — listTasks

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.listTasks();
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.list_tasks()
  print(result)
  ```
</CodeGroup>

## Run Task (Legacy)

`POST /v1/task/run` — runAdhocTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.runAdhocTask({
    body: {
      taskId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.run_adhoc_task(
      task_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  )
  print(result)
  ```
</CodeGroup>

## Run Task by Name (Legacy)

`POST /v1/task/run/{taskName}` — runTaskByName

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.runTaskByName({
    path: {
      taskName: 'your-taskName'
    },
    body: {}
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.run_task_by_name(
      "your-task-name",
  )
  print(result)
  ```
</CodeGroup>

## Get Task Metadata (Legacy)

`GET /v1/task/{taskId}` — getTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.getTask({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.get_task(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Update Task Metadata (Legacy)

`PUT /v1/task/{taskId}` — updateTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.updateTask({
    path: {
      taskId: 'your-taskId'
    },
    body: {}
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.update_task(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Delete Task (Legacy)

`DELETE /v1/task/{taskId}` — deleteTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.deleteTask({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.delete_task(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## List Task Versions (Legacy)

`GET /v1/task/{taskId}/versions` — listTaskVersions

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.listTaskVersions({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.list_task_versions(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Get Latest Task Version (Legacy)

`GET /v1/task/{taskId}/latest` — getLatestTaskVersion

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.getLatestTaskVersion({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.get_latest_task_version(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Get Task Draft (Legacy)

`GET /v1/task/{taskId}/draft` — getTaskDraft

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.getTaskDraft({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.get_task_draft(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Create or Update Task Draft (Legacy)

`POST /v1/task/{taskId}/draft` — saveTaskDraft

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.saveTaskDraft({
    path: {
      taskId: 'your-taskId'
    },
    body: {
      code: 'string'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.save_task_draft(
      "your-task-id",
      code="string",
  )
  print(result)
  ```
</CodeGroup>

## Deploy Task (Legacy)

`POST /v1/task/{taskId}/deploy` — deployTask

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.deployTask({
    path: {
      taskId: 'your-taskId'
    },
    body: {}
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.deploy_task(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## List Task Executions (Legacy)

`GET /v1/task/{taskId}/executions` — listTaskExecutions

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.listTaskExecutions({
    path: {
      taskId: 'your-taskId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.list_task_executions(
      "your-task-id",
  )
  print(result)
  ```
</CodeGroup>

## Get Task Execution Result (Legacy)

`GET /v1/task/{taskId}/executions/{executionId}` — getTaskExecution

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.getTaskExecution({
    path: {
      taskId: 'your-taskId',
      executionId: 'your-executionId'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.get_task_execution(
      "your-task-id",
      "your-execution-id",
  )
  print(result)
  ```
</CodeGroup>

## Get Task Version (Legacy)

`GET /v1/task/{taskId}/{taskVersion}` — getTaskVersion

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.getTaskVersion({
    path: {
      taskId: 'your-taskId',
      taskVersion: 'your-taskVersion'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.get_task_version(
      "your-task-id",
      "your-task-version",
  )
  print(result)
  ```
</CodeGroup>

## Publish Task Version (Legacy)

`POST /v1/task/{taskId}/{taskVersion}` — publishTaskVersion

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.publishTaskVersion({
    path: {
      taskId: 'your-taskId',
      taskVersion: 'your-taskVersion'
    },
    body: {}
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.publish_task_version(
      "your-task-id",
      "your-task-version",
  )
  print(result)
  ```
</CodeGroup>

## Delete Task Version (Legacy)

`DELETE /v1/task/{taskId}/{taskVersion}` — deleteTaskVersion

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { client, TasksLegacy } from 'anchorbrowser';

  // ANCHORBROWSER_API_KEY is read from the environment by default;
  // set it explicitly like this:
  client.setConfig({ auth: () => 'your-api-key' });

  const result = await TasksLegacy.deleteTaskVersion({
    path: {
      taskId: 'your-taskId',
      taskVersion: 'your-taskVersion'
    }
  });
  console.log(result);
  ```

  ```python Python theme={null}
  from anchorbrowser import Anchorbrowser

  # ANCHORBROWSER_API_KEY is read from the environment by default;
  # set it explicitly with Anchorbrowser(api_key="your-api-key")
  client = Anchorbrowser()

  result = client.tasks_legacy.delete_task_version(
      "your-task-id",
      "your-task-version",
  )
  print(result)
  ```
</CodeGroup>
