# TaskClient<!-- -->

Client for managing a specific Actor task.

Tasks are pre-configured Actor runs with saved input and options. This client provides methods to start, call, update, and delete tasks, as well as manage their runs and webhooks.

### Hierarchy

* ResourceClient
  * *TaskClient*

```
const client = new ApifyClient({ token: 'my-token' });

const taskClient = client.task('my-task-id');



// Start a task

const run = await taskClient.start();



// Call a task and wait for it to finish

const finishedRun = await taskClient.call();
```

See more at <https://docs.apify.com/platform/actors/running/tasks>

## Index[](#Index)

### Properties

* [apifyClient](#apifyClient)
* [baseUrl](#baseUrl)
* [httpClient](#httpClient)
* [id](#id)
* [params](#params)
* [publicBaseUrl](#publicBaseUrl)
* [resourcePath](#resourcePath)
* [safeId](#safeId)
* [url](#url)

### Methods

* [call](#call)
* [delete](#delete)
* [get](#get)
* [getInput](#getInput)
* [lastRun](#lastRun)
* [publish](#publish)
* [runs](#runs)
* [start](#start)
* [unpublish](#unpublish)
* [update](#update)
* [updateInput](#updateInput)
* [webhooks](#webhooks)

## Properties<!-- -->[](#Properties)

### [](#apifyClient)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L36)inheritedapifyClient

apifyClient: [ApifyClient](https://docs.apify.com/api/client/js/reference/class/ApifyClient.md)

Inherited from ResourceClient.apifyClient

### [](#baseUrl)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L28)inheritedbaseUrl

baseUrl: string

Inherited from ResourceClient.baseUrl

### [](#httpClient)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L38)inheritedhttpClient

httpClient: HttpClient

Inherited from ResourceClient.httpClient

### [](#id)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L24)optionalinheritedid

id?

<!-- -->

: string

Inherited from ResourceClient.id

### [](#params)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L40)optionalinheritedparams

params?

<!-- -->

: Record\<string, unknown>

Inherited from ResourceClient.params

### [](#publicBaseUrl)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L30)inheritedpublicBaseUrl

publicBaseUrl: string

Inherited from ResourceClient.publicBaseUrl

### [](#resourcePath)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L32)inheritedresourcePath

resourcePath: string

Inherited from ResourceClient.resourcePath

### [](#safeId)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L26)optionalinheritedsafeId

safeId?

<!-- -->

: string

Inherited from ResourceClient.safeId

### [](#url)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/base/api_client.ts#L34)inheritedurl

url: string

Inherited from ResourceClient.url

## Methods<!-- -->[](#Methods)

### [](#call)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L188)call

* **call**(input, options): Promise<[ActorRun](https://docs.apify.com/api/client/js/reference/interface/ActorRun.md)>

- Starts a task and waits for it to finish before returning the Run object. It waits indefinitely, unless the `waitSecs` option is provided.

  ***

  #### Parameters

  * ##### optionalinput: [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)

    Input overrides for the task. If not provided, the task's saved input is used.

  * ##### options: [TaskCallOptions](https://docs.apify.com/api/client/js/reference/interface/TaskCallOptions.md) = <!-- -->{}

    Run and wait options.

  #### Returns Promise<[ActorRun](https://docs.apify.com/api/client/js/reference/interface/ActorRun.md)>

  The Actor run object.

  See more at <https://docs.apify.com/api/v2/actor-task-runs-post>

### [](#delete)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L105)delete

* **delete**(): Promise\<void>

- Deletes the Task.

  ***

  #### Returns Promise\<void>

  See more at <https://docs.apify.com/api/v2/actor-task-delete>

### [](#get)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L53)get

* **get**(): Promise\<undefined | [Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

- Retrieves the Actor task.

  ***

  #### Returns Promise\<undefined | [Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

  The task object, or `undefined` if it does not exist.

  See more at <https://docs.apify.com/api/v2/actor-task-get>

### [](#getInput)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L220)getInput

* **getInput**(): Promise\<undefined | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary) | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)\[]>

- Retrieves the Actor task's input object.

  ***

  #### Returns Promise\<undefined | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary) | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)\[]>

  The Task's input, or `undefined` if it does not exist.

  See more at <https://docs.apify.com/api/v2/actor-task-input-get>

### [](#lastRun)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L263)lastRun

* **lastRun**(options): [RunClient](https://docs.apify.com/api/client/js/reference/class/RunClient.md)

- Returns a client for the last run of this task.

  ***

  #### Parameters

  * ##### options: [TaskLastRunOptions](https://docs.apify.com/api/client/js/reference/interface/TaskLastRunOptions.md) = <!-- -->{}

    Filter options for the last run.

  #### Returns [RunClient](https://docs.apify.com/api/client/js/reference/class/RunClient.md)

  A client for the last run.

  See more at <https://docs.apify.com/api/v2/actor-task-runs-last-get>

### [](#publish)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L81)publish

* **publish**(): Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

- Publishes the task on its public landing page, by setting `isPublic` through [TaskClient.update](https://docs.apify.com/api/client/js/reference/class/TaskClient.md#update).

  The task's Actor must be public and the task must have its public display configuration (`publicConfig`) set up first. Requires write permission to both the task and its Actor. Publishing an already published task does nothing.

  ***

  #### Returns Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

  The task object.

  See more at <https://docs.apify.com/api/v2/actor-task-put>

### [](#runs)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L287)runs

* **runs**(): [RunCollectionClient](https://docs.apify.com/api/client/js/reference/class/RunCollectionClient.md)

- Returns a client for the Runs of this Task.

  ***

  #### Returns [RunCollectionClient](https://docs.apify.com/api/client/js/reference/class/RunCollectionClient.md)

  A client for the task's runs.

  See more at <https://docs.apify.com/api/v2/actor-task-runs-get>

### [](#start)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L125)start

* **start**(input, options): Promise<[ActorRun](https://docs.apify.com/api/client/js/reference/interface/ActorRun.md)>

- Starts an Actor task and immediately returns the Run object.

  ***

  #### Parameters

  * ##### optionalinput: [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)

    Input overrides for the task. If not provided, the task's saved input is used.

  * ##### options: [TaskStartOptions](https://docs.apify.com/api/client/js/reference.md#TaskStartOptions) = <!-- -->{}

    Run options.

  #### Returns Promise<[ActorRun](https://docs.apify.com/api/client/js/reference/interface/ActorRun.md)>

  The Actor Run object.

  See more at <https://docs.apify.com/api/v2/actor-task-runs-post>

### [](#unpublish)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L96)unpublish

* **unpublish**(): Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

- Unpublishes the task from its public landing page, by setting `isPublic` through [TaskClient.update](https://docs.apify.com/api/client/js/reference/class/TaskClient.md#update).

  The public display configuration (`publicConfig`) is preserved, so the task can be published again without re-entering it. Requires write permission to both the task and its Actor. Unpublishing a task that is not published does nothing.

  ***

  #### Returns Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

  The task object.

  See more at <https://docs.apify.com/api/v2/actor-task-put>

### [](#update)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L64)update

* **update**(newFields): Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

- Updates the task with the specified fields.

  ***

  #### Parameters

  * ##### newFields: [TaskUpdateData](https://docs.apify.com/api/client/js/reference.md#TaskUpdateData)

    Fields to update.

  #### Returns Promise<[Task](https://docs.apify.com/api/client/js/reference/interface/Task.md)>

  The updated task object.

  See more at <https://docs.apify.com/api/v2/actor-task-put>

### [](#updateInput)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L243)updateInput

* **updateInput**(newFields): Promise<[Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary) | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)\[]>

- Updates the Actor task's input object.

  ***

  #### Parameters

  * ##### newFields: [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary) | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)\[]

    New input data for the task.

  #### Returns Promise<[Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary) | [Dictionary](https://docs.apify.com/api/client/js/reference.md#Dictionary)\[]>

  The updated task input.

  See more at <https://docs.apify.com/api/v2/actor-task-input-put>

### [](#webhooks)[](https://github.com/apify/apify-client-js/blob/99b6aa05a37cb5e573154cf0d7753ff5b206ef09/src/resource_clients/task.ts#L301)webhooks

* **webhooks**(): [WebhookCollectionClient](https://docs.apify.com/api/client/js/reference/class/WebhookCollectionClient.md)

- Returns a client for the Webhooks of this Task.

  ***

  #### Returns [WebhookCollectionClient](https://docs.apify.com/api/client/js/reference/class/WebhookCollectionClient.md)

  A client for the task's webhooks.

  See more at <https://docs.apify.com/api/v2/actor-task-webhooks-get>
